mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-01 12:00:48 +00:00
Removed App::sendBotCommand.
This commit is contained in:
parent
a030907598
commit
dcc8a64d37
@ -192,7 +192,7 @@ bool BotKeyboard::moderateKeyActivate(int key) {
|
|||||||
if (!markup->rows.empty()
|
if (!markup->rows.empty()
|
||||||
&& index >= 0
|
&& index >= 0
|
||||||
&& index < int(markup->rows.front().size())) {
|
&& index < int(markup->rows.front().size())) {
|
||||||
App::activateBotCommand(item, 0, index);
|
App::activateBotCommand(_controller, item, 0, index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (const auto user = item->history()->peer->asUser()) {
|
} else if (const auto user = item->history()->peer->asUser()) {
|
||||||
|
@ -58,15 +58,6 @@ namespace {
|
|||||||
|
|
||||||
namespace App {
|
namespace App {
|
||||||
|
|
||||||
void sendBotCommand(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
UserData *bot,
|
|
||||||
const QString &cmd, MsgId replyTo) {
|
|
||||||
if (const auto m = CheckMainWidget(&peer->session())) {
|
|
||||||
m->sendBotCommand({ peer, /*bot,*/ cmd, FullMsgId(), replyTo });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hideSingleUseKeyboard(not_null<const HistoryItem*> message) {
|
void hideSingleUseKeyboard(not_null<const HistoryItem*> message) {
|
||||||
if (const auto m = CheckMainWidget(&message->history()->session())) {
|
if (const auto m = CheckMainWidget(&message->history()->session())) {
|
||||||
m->hideSingleUseKeyboard(message->history()->peer, message->id);
|
m->hideSingleUseKeyboard(message->history()->peer, message->id);
|
||||||
@ -81,6 +72,7 @@ bool insertBotCommand(const QString &cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void activateBotCommand(
|
void activateBotCommand(
|
||||||
|
Window::SessionController *sessionController,
|
||||||
not_null<const HistoryItem*> msg,
|
not_null<const HistoryItem*> msg,
|
||||||
int row,
|
int row,
|
||||||
int column) {
|
int column) {
|
||||||
@ -98,12 +90,15 @@ void activateBotCommand(
|
|||||||
case ButtonType::Default: {
|
case ButtonType::Default: {
|
||||||
// Copy string before passing it to the sending method
|
// Copy string before passing it to the sending method
|
||||||
// because the original button can be destroyed inside.
|
// because the original button can be destroyed inside.
|
||||||
MsgId replyTo = (msg->id > 0) ? msg->id : 0;
|
if (sessionController) {
|
||||||
sendBotCommand(
|
MsgId replyTo = (msg->id > 0) ? msg->id : 0;
|
||||||
msg->history()->peer,
|
sessionController->content()->sendBotCommand({
|
||||||
msg->fromOriginal()->asUser(),
|
.peer = msg->history()->peer,
|
||||||
QString(button->text),
|
.command = QString(button->text),
|
||||||
replyTo);
|
.context = msg->fullId(),
|
||||||
|
.replyTo = replyTo,
|
||||||
|
});
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ButtonType::Callback:
|
case ButtonType::Callback:
|
||||||
|
@ -14,15 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
class History;
|
class History;
|
||||||
|
|
||||||
namespace Data {
|
namespace Window {
|
||||||
struct FileOrigin;
|
class SessionController;
|
||||||
} // namespace Data
|
} // namespace Window
|
||||||
|
|
||||||
namespace InlineBots {
|
|
||||||
namespace Layout {
|
|
||||||
class ItemBase;
|
|
||||||
} // namespace Layout
|
|
||||||
} // namespace InlineBots
|
|
||||||
|
|
||||||
namespace App {
|
namespace App {
|
||||||
|
|
||||||
@ -37,13 +31,9 @@ template <typename Guard, typename Lambda>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendBotCommand(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
UserData *bot,
|
|
||||||
const QString &cmd,
|
|
||||||
MsgId replyTo = 0);
|
|
||||||
bool insertBotCommand(const QString &cmd);
|
bool insertBotCommand(const QString &cmd);
|
||||||
void activateBotCommand(
|
void activateBotCommand(
|
||||||
|
Window::SessionController *sessionController,
|
||||||
not_null<const HistoryItem*> msg,
|
not_null<const HistoryItem*> msg,
|
||||||
int row,
|
int row,
|
||||||
int column);
|
int column);
|
||||||
|
@ -447,9 +447,13 @@ auto ReplyMarkupClickHandler::getUrlButton() const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplyMarkupClickHandler::onClickImpl() const {
|
void ReplyMarkupClickHandler::onClick(ClickContext context) const {
|
||||||
|
if (context.button != Qt::LeftButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (const auto item = _owner->message(_itemId)) {
|
if (const auto item = _owner->message(_itemId)) {
|
||||||
App::activateBotCommand(item, _row, _column);
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
App::activateBotCommand(my.sessionWindow.get(), item, _row, _column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReplyMarkupClickHandler : public LeftButtonClickHandler {
|
class ReplyMarkupClickHandler : public ClickHandler {
|
||||||
public:
|
public:
|
||||||
ReplyMarkupClickHandler(
|
ReplyMarkupClickHandler(
|
||||||
not_null<Data::Session*> owner,
|
not_null<Data::Session*> owner,
|
||||||
@ -278,8 +278,7 @@ public:
|
|||||||
_itemId = msgId;
|
_itemId = msgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
void onClick(ClickContext context) const override;
|
||||||
void onClickImpl() const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const not_null<Data::Session*> _owner;
|
const not_null<Data::Session*> _owner;
|
||||||
|
Loading…
Reference in New Issue
Block a user