| 291 | } |
| 292 | |
| 293 | void ActivateBotCommand(ClickHandlerContext context, int row, int column) { |
| 294 | const auto strong = context.sessionWindow.get(); |
| 295 | if (!strong) { |
| 296 | return; |
| 297 | } |
| 298 | const auto controller = not_null{ strong }; |
| 299 | const auto item = controller->session().data().message(context.itemId); |
| 300 | if (!item) { |
| 301 | return; |
| 302 | } |
| 303 | const auto button = HistoryMessageMarkupButton::Get( |
| 304 | &item->history()->owner(), |
| 305 | item->fullId(), |
| 306 | row, |
| 307 | column); |
| 308 | if (!button) { |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | using ButtonType = HistoryMessageMarkupButton::Type; |
| 313 | switch (button->type) { |
| 314 | case ButtonType::Default: { |
| 315 | // Copy string before passing it to the sending method |
| 316 | // because the original button can be destroyed inside. |
| 317 | const auto replyTo = item->isRegular() |
| 318 | ? item->fullId() |
| 319 | : FullMsgId(); |
| 320 | controller->content()->sendBotCommand({ |
| 321 | .peer = item->history()->peer, |
| 322 | .command = QString(button->text), |
| 323 | .context = item->fullId(), |
| 324 | .replyTo = { replyTo }, |
| 325 | }); |
| 326 | } break; |
| 327 | |
| 328 | case ButtonType::Callback: |
| 329 | case ButtonType::Game: { |
| 330 | SendBotCallbackData(controller, item, row, column); |
| 331 | } break; |
| 332 | |
| 333 | case ButtonType::CallbackWithPassword: { |
| 334 | SendBotCallbackDataWithPassword(controller, item, row, column); |
| 335 | } break; |
| 336 | |
| 337 | case ButtonType::Buy: { |
| 338 | Payments::CheckoutProcess::Start( |
| 339 | item, |
| 340 | Payments::Mode::Payment, |
| 341 | crl::guard(controller, [=](auto) { |
| 342 | controller->widget()->activate(); |
| 343 | }), |
| 344 | Payments::ProcessNonPanelPaymentFormFactory(controller, item)); |
| 345 | } break; |
| 346 | |
| 347 | case ButtonType::Url: { |
| 348 | auto url = QString::fromUtf8(button->data); |
| 349 | auto skipConfirmation = false; |
| 350 | if (const auto bot = item->getMessageBot()) { |
no test coverage detected