Skip to content

Bug in TInjectTelegramBot.CopyMessageΒ #8

@DelphiMan68

Description

@DelphiMan68

Hello Sir,
When I try to use CopyMessage, the Execute command returns a Json value in the form of {"message_id":14} and naturally it cannot convert it to Int64 and an error occurs. To temporarily solve this problem, I have changed the TInjectTelegramBot.CopyMessage method located in the TInjectTelegram.Bot.Impl unit to the following form and decided to inform you about this bug.

function TInjectTelegramBot.CopyMessage(const ChatId, FromChatId: TtdUserLink;
const MessageId: Int64; const Caption: string; const ParseMode: TtdParseMode;
const CaptionEntities: TArray; const DisableWebPagePreview,
DisableNotification: Boolean; const ReplyToMessageId: Int64;
const AllowSendingWithoutReply: Boolean; ReplyMarkup: IReplyMarkup;
const ProtectContent: Boolean): Int64;
Var
LTmpJson: String;
LJsonResult : string;
LJsonObj : TJsonObject;
begin
Logger.Enter(Self, 'CopyMessage');
LTmpJson := TJsonUtils.ArrayToJString(CaptionEntities);
LJsonResult := GetRequest.SetMethod('copyMessage') //
.AddParameter('chat_id', ChatId, 0, True) //
.AddParameter('from_chat_id', FromChatId, 0, True) //
.AddParameter('message_id', MessageId, 0, True) //
.AddParameter('caption', Caption, '', False) //
.AddParameter('parse_mode', ParseMode.ToString, '', False) //
.AddParameter('caption_entities', LTmpJson, '', False) //
.AddParameter('disable_web_page_preview', DisableWebPagePreview, False, False) //
.AddParameter('disable_notification', DisableNotification, False, False) //
.AddParameter('reply_to_message_id', ReplyToMessageId, 0, False) //
.AddParameter('allow_sending_without_reply', AllowSendingWithoutReply, False, False) //
.AddParameter('protect_content ', ProtectContent, False, False) //
.AddParameter('reply_markup', TInterfacedObject(ReplyMarkup), nil, False) //
.Execute; // {"message_id":14}
LJsonObj := TJSONObject.ParseJSONValue(LJsonResult) As TJSONObject;
try
Result := LJsonObj.GetValue('message_id');
finally
LJsonObj.Free
end;
Logger.Leave(Self, 'CopyMessage');
end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions