/// Returns the Action for each Telegram Update (message, callback, inline query)
Returns the Action for each Telegram Update (message, callback, inline query)
Returns the Action for each Telegram Update ( message callback inline query )
pub fn parse_update(update: Update) -> (i64, Option<String>, Option<String>) {
        match update.kind {
            // User sent a message
            UpdateKind::Message(telegram_message) => {
                let id = telegram_message.chat.id().into();
                if let MessageKind::Text { data, .. } = telegram_message.kind {
                    if let MessageChat::Private(from_user) = telegram_message.chat {
                        return (id, from_user.username, Some(data));
                    }
                }
                (id, None, None)
            }
            // User clicked a button
            UpdateKind::CallbackQuery(query) => {
                let id = query.message.chat.id().into();
                if let MessageChat::Private(from_user) = query.message.chat {
                    return (id, from_user.username, Some(query.data));
                }
                (id, None, None)
            }
            // User sent an inline (@grinbot123 send...) query
            UpdateKind::InlineQuery(query) => {
                let id = query.from.id.into();
                (id, query.from.username, Some("/unsupported".to_string()))
            }
            _ => (-1, None, None),
        }
    }
pub fn parse_update ( update : Update ) -> ( i64 , Option < String > , Option < String > ) { match update . kind { // User sent a message UpdateKind :: Message ( telegram_message ) => { let id = telegram_message . chat . id ( ) . into ( ) ; if let MessageKind :: Text { data , .. } = telegram_message . kind { if let MessageChat :: Private ( from_user ) = telegram_message . chat { return ( id , from_user . username , Some ( data ) ) ; } } ( id , None , None ) } // User clicked a button UpdateKind :: CallbackQuery ( query ) => { let id = query . message . chat . id ( ) . into ( ) ; if let MessageChat :: Private ( from_user ) = query . message . chat { return ( id , from_user . username , Some ( query . data ) ) ; } ( id , None , None ) } // User sent an inline (@grinbot123 send...) query UpdateKind :: InlineQuery ( query ) => { let id = query . from . id . into ( ) ; ( id , query . from . username , Some ( " " . to_string ( ) ) ) } _ => ( - 1 , None , None ) , } }
Returns the Action for each Telegram Update (message, callback, inline query)
Returns the Action for each Telegram Update ( message callback inline query )
update
Update