@@ -30,6 +30,7 @@ use repo::tasks::Task;
30
30
use serde:: Deserialize ;
31
31
use serde:: Serialize ;
32
32
use teloxide:: dispatching:: dialogue:: GetChatId ;
33
+ use teloxide:: payloads;
33
34
use teloxide:: prelude:: * ;
34
35
use teloxide:: types:: InlineKeyboardButton ;
35
36
use teloxide:: types:: InlineKeyboardButtonKind ;
@@ -139,27 +140,17 @@ async fn answer(bot: Bot, msg: Message, bc: BCommand) -> ResponseResult<()> {
139
140
}
140
141
141
142
async fn handle_callback_query ( bot : Bot , query : CallbackQuery ) -> ResponseResult < ( ) > {
142
- match handle_callback_query_command_result ( & bot, & query) . await {
143
- Ok ( msg) => match get_chat_id_and_username_from_query ( & query) {
144
- Ok ( ( chat_id, username) ) => {
145
- bot. send_message ( chat_id, format ! ( "@{username} {msg}" ) )
146
- . await ?;
147
- Ok ( ( ) )
148
- }
149
- Err ( e) => {
150
- log:: error!( "callback query error: {e}" ) ;
151
- Ok ( ( ) )
152
- }
153
- } ,
154
- Err ( CommandError :: Normal ( e) ) => match get_chat_id_and_username_from_query ( & query) {
155
- Ok ( ( chat_id, username) ) => e. report_to_user ( & bot, chat_id, & username) . await ,
156
- Err ( _e) => {
157
- log:: error!( "callback query error: {e}" ) ;
158
- Ok ( ( ) )
159
- }
160
- } ,
161
- Err ( CommandError :: Teloxide ( e) ) => Err ( e) ,
162
- }
143
+ let result = handle_callback_query_command_result ( & bot, & query) . await ;
144
+ let ( message, alert) = match result {
145
+ Ok ( msg) => ( msg, false ) ,
146
+ Err ( CommandError :: Normal ( e) ) => ( format ! ( "{e}" ) , true ) ,
147
+ Err ( CommandError :: Teloxide ( e) ) => return Err ( e) ,
148
+ } ;
149
+ let answer = payloads:: AnswerCallbackQuery :: new ( query. id )
150
+ . text ( message)
151
+ . show_alert ( alert) ;
152
+ <Bot as Requester >:: AnswerCallbackQuery :: new ( bot, answer) . await ?;
153
+ Ok ( ( ) )
163
154
}
164
155
165
156
async fn handle_callback_query_command_result (
0 commit comments