void BotCommandClickHandler::onClick(ClickContext context) const { const auto button = context.button; if (button == Qt::LeftButton || button == Qt::MiddleButton) { if (auto peer = peerForCommand()) { if (auto bot = peer->isUser() ? peer->asUser() : botForCommand()) { Ui::showPeerHistory(peer, ShowAtTheEndMsgId); App::sendBotCommand(peer, bot, _cmd); return; } } if (auto peer = Ui::getPeerForMouseAction()) { // old way auto bot = peer->isUser() ? peer->asUser() : nullptr; if (!bot) { if (const auto view = App::hoveredLinkItem()) { // may return nullptr bot = view->data()->fromOriginal()->asUser(); } } Ui::showPeerHistory(peer, ShowAtTheEndMsgId); App::sendBotCommand(peer, bot, _cmd); } else { App::insertBotCommand(_cmd); } } }
void BotCommandClickHandler::onClick(Qt::MouseButton button) const { if (button == Qt::LeftButton || button == Qt::MiddleButton) { if (auto peer = peerForCommand()) { if (auto bot = peer->isUser() ? peer->asUser() : botForCommand()) { Ui::showPeerHistory(peer, ShowAtTheEndMsgId); App::sendBotCommand(peer, bot, _cmd); return; } } if (auto peer = Ui::getPeerForMouseAction()) { // old way UserData *bot = peer->isUser() ? peer->asUser() : nullptr; if (auto item = App::hoveredLinkItem()) { if (!bot) { bot = item->fromOriginal()->asUser(); // may return nullptr } } Ui::showPeerHistory(peer, ShowAtTheEndMsgId); App::sendBotCommand(peer, bot, _cmd); } else { App::insertBotCommand(_cmd); } } }