ayrat555 / frankenstein

Telegram bot API client for Rust
Do What The F*ck You Want To Public License
268 stars 28 forks source link

Fails to decode ChatMemberRestricted #164

Closed swbartosz closed 6 months ago

swbartosz commented 6 months ago

Example of update that contains a ChatMemberRestricted:

{"ok":true,"result":[{"update_id":1,
"chat_member":{"chat":{"id":-10000,"title":"a group","type":"supergroup"},"from":{"id":211,"is_bot":true,"first_name":"some name","username":"a_username"},"date":1714065911,"old_chat_member":{"user":{"id":645,"is_bot":false,"first_name":"John","last_name":"Smith"},"status":"left"},"new_chat_member":{"user":{"id":645,"is_bot":false,"first_name":"John","last_name":"Smith"},"status":"restricted","until_date":0,"can_send_messages":false,"can_send_media_messages":false,"can_send_audios":false,"can_send_documents":false,"can_send_photos":false,"can_send_videos":false,"can_send_video_notes":false,"can_send_voice_notes":false,"can_send_polls":false,"can_send_other_messages":false,"can_add_web_page_previews":false,"can_change_info":false,"can_invite_users":false,"can_pin_messages":false,"can_manage_topics":false,"is_member":false}}
}]}

returns with: Decode("Error(\"missing fieldstatus\", line: 2, column: 923) (column 923 being around the end).

Seems like the issue is caused by ChatMemberRestricted having a status field. No other ChatMember* has the status field. Removing it seems to work.

Programistich commented 6 months ago

I have issue for Failed to get updates: Decode("Error(\"missing field message_id\", line: 2, column: 746) :

ayrat555 commented 6 months ago

hello @Programistich . what kind of update it's failing for?

ayrat555 commented 6 months ago

@Programistich shared the json response that was failing. the issue is message_id should be optional in ExternalReplyInfo struct. (thanks!)

will make a pr with a fix now