tinjecttelegram_delphi icon indicating copy to clipboard operation
tinjecttelegram_delphi copied to clipboard

MyChatMember event not works + solution to fix

Open DelphiMan68 opened this issue 5 months ago • 0 comments

Regards, 🌺

Some events of the TInjectTelegramBotManager component do not work. With the checks I did, I realized that the problem is in the TtdUpdate.&Type method in the TinjectTelegram.Types.Impl unit, where some events are not managed. To solve this problem, it is enough to replace the corresponding method with the following code:

function TtdUpdate.&Type: TtdUpdateType;
begin
  if CallbackQuery <> nil then
    Result := TtdUpdateType.CallbackQueryUpdate
  else if ChannelPost <> nil then
    Result := (TtdUpdateType.ChannelPost)
  else if ChosenInlineResult <> nil then
    Result := (TtdUpdateType.ChosenInlineResultUpdate)
  else if EditedChannelPost <> nil then
    Result := (TtdUpdateType.EditedChannelPost)
  else if EditedMessage <> nil then
    Result := (TtdUpdateType.EditedMessage)
  else if InlineQuery <> nil then
    Result := (TtdUpdateType.InlineQueryUpdate)
  else if Message <> nil then
    Result := (TtdUpdateType.MessageUpdate)
  else if PreCheckoutQuery <> nil then
    Result := (TtdUpdateType.PreCheckoutQueryUpdate)
  else if ShippingQuery <> nil then
    Result := (TtdUpdateType.ShippingQueryUpdate)
  else if MyChatMember <> nil then                      // --> Add
    Result := (TtdUpdateType.MyChatMember)
  else if ChatMember <> nil then                        // --> Add
    Result := (TtdUpdateType.ChatMember)
  else if PollState <> nil then                         // --> Add
    Result := (TtdUpdateType.PollState)
  else if PollAnswer <> nil then                        // --> Add
    Result := (TtdUpdateType.PollAnswer)
  else if ChatJoinRequest <> nil then                   // --> Add
    Result := (TtdUpdateType.ChatJoinRequest)
  else if ChatBoost <> nil then                         // --> Add
    Result := (TtdUpdateType.ChatBoost)
//else if RemovedChatBoost <> nil then                  // --> Add
//  Result := (TtdUpdateType.RemovedChatBoost)
  else if MessageReaction <> nil then                   // --> Add
    Result := (TtdUpdateType.MessageReaction)
  else if MessageReactionCount <> nil then              // --> Add
    Result := (TtdUpdateType.MessageReactionCount)
  else
    Result := TtdUpdateType.UnknownUpdate;
end;

Thnaks ❤️

DelphiMan68 avatar Sep 13 '24 15:09 DelphiMan68