Closed marat93 closed 1 year ago
Hey @marat93
I agree but according to the official docs both old_chat_member
and new_chat_member
should be ChatMember
. I'm not sure why; maybe they expect to return more than just ChatMemberLeft
and ChatMemberMember
in future.
Thanks, @atipugin
if anyone needs it, I end up overriding the ChatMember
adding all the attributes chat member types have. I looked up this solution in telegram-bot-rb
# frozen_string_literal: true
module Telegram
module Bot
module Types
class ChatMember < Base
attribute :user, User
attribute :status, Types::String
attribute? :custom_title, Types::String
attribute? :is_anonymous, Types::Bool
attribute? :can_be_edited, Types::Bool
attribute? :can_manage_chat, Types::Bool
attribute? :can_post_messages, Types::Bool
attribute? :can_edit_messages, Types::Bool
attribute? :can_delete_messages, Types::Bool
attribute? :can_manage_voice_chats, Types::Bool
attribute? :can_restrict_members, Types::Bool
attribute? :can_promote_members, Types::Bool
attribute? :can_change_info, Types::Bool
attribute? :can_invite_users, Types::Bool
attribute? :can_pin_messages, Types::Bool
attribute? :is_member, Types::Bool
attribute? :can_send_messages, Types::Bool
attribute? :can_send_media_messages, Types::Bool
attribute? :can_send_polls, Types::Bool
attribute? :can_send_other_messages, Types::Bool
attribute? :can_add_web_page_previews, Types::Bool
attribute? :until_date, Types::Integer
end
end
end
end
@marat93 I've fixed it in #285 now.
It's a huge PR now, yeah. With global logic change and a lot of small API updates.
Specific ChatMember
changes are here: https://github.com/atipugin/telegram-bot-ruby/pull/285/commits/19baae0b7038089bf725eb73c0159a3d5fe3ff8d
@atipugin you can close this issue now, it accidentally has not been auto-closed by PR.
Maybe I'm doing something wrong but
old_chat_member
andnew_chat_member
fields inChatMemberUpdated
are always cast into justChatMember
regardless of thestatus
value.So that's what I get by calling
bot.api.getUpdates
when a user is added to the group:And that's what I get from
bot.listen
:I expect
old_chat_member
andnew_chat_member
to beChatMemberLeft
andChatMemberMember
objects respectively.