grammers icon indicating copy to clipboard operation
grammers copied to clipboard

The is_bot flag is incorrectly interpreted for messages from a bot without a keyboard

Open taimast opened this issue 1 year ago • 4 comments
trafficstars

For messages without an attached keyboard that the bot sends, the Chat::User(user) type attached to the message has the flag user.is_bot() == False, although if the keyboard is attached, then user.is_bot() == True

taimast avatar Dec 01 '23 23:12 taimast

Are you sure the message wasn't sent @via inline? The library doesn't modify the bot flag returned by Telegram in any way: https://github.com/Lonami/grammers/blob/04d95775e01f52e8326e1d1e203ee1b5137ee518/lib/grammers-client/src/types/chat/user.rs#L247-L249

Lonami avatar Dec 02 '23 00:12 Lonami

Are you sure the message wasn't sent @via inline? The library doesn't modify the bot flag returned by Telegram in any way:

https://github.com/Lonami/grammers/blob/04d95775e01f52e8326e1d1e203ee1b5137ee518/lib/grammers-client/src/types/chat/user.rs#L247-L249

image Of this kind

taimast avatar Dec 02 '23 01:12 taimast

Can you check what value the min field has?

Lonami avatar Dec 02 '23 10:12 Lonami

Can you check what value the min field has?

impl ChatTypeFilter {
    pub(crate) async fn handle(&self, context: &ComponentContext<'_>) -> bool {
        if self.chat_types.len() == 0 {
            return false;
        }
        ChatTypeForFilter::is_contains(&self.chat_types, &context.message.chat())
    }
}

impl ChatTypeForFilter {
    pub fn is_contains(array: &Vec<Self>, chat: &Chat) -> bool {
        if array.len() == 0 {
            return false;
        }

        return match chat {
            Chat::User(user) => {
                println!("{}", user.is_bot());
                println!("{}", user.min());
                if user.is_bot() {
                    if array.contains(&ChatTypeForFilter::Bot) {
                        return true;
                    }
                } else {
                    if array.contains(&ChatTypeForFilter::Private) {
                        return true;
                    }
                }
                false
            }
            Chat::Group(_) => {
                if array.contains(&ChatTypeForFilter::Group) {
                    return true;
                }
                false
            }
            Chat::Channel(_) => {
                if array.contains(&ChatTypeForFilter::SuperGroup) {
                    return true;
                }
                false
            }
        };
    }
}
false
false

taimast avatar Dec 02 '23 15:12 taimast