mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Moved utils for sending bot commands to separated file.
This commit is contained in:
@@ -3601,34 +3601,33 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::sendBotCommand(
|
||||
not_null<PeerData*> peer,
|
||||
UserData *bot,
|
||||
const QString &cmd,
|
||||
MsgId replyTo) { // replyTo != 0 from ReplyKeyboardMarkup, == 0 from cmd links
|
||||
if (_peer != peer.get()) {
|
||||
void HistoryWidget::sendBotCommand(Bot::SendCommandRequest request) {
|
||||
// replyTo != 0 from ReplyKeyboardMarkup, == 0 from command links
|
||||
if (_peer != request.peer.get()) {
|
||||
return;
|
||||
} else if (showSlowmodeError()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool lastKeyboardUsed = (_keyboard->forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)) && (_keyboard->forMsgId() == FullMsgId(_channel, replyTo));
|
||||
const auto lastKeyboardUsed = (_keyboard->forMsgId()
|
||||
== FullMsgId(_channel, _history->lastKeyboardId))
|
||||
&& (_keyboard->forMsgId() == FullMsgId(_channel, request.replyTo));
|
||||
|
||||
// 'bot' may be nullptr in case of sending from FieldAutocomplete.
|
||||
const auto toSend = (replyTo || !bot)
|
||||
? cmd
|
||||
: HistoryView::WrapBotCommandInChat(_peer, cmd, bot);
|
||||
const auto toSend = (request.replyTo/* || !bot*/)
|
||||
? request.command
|
||||
: Bot::WrapCommandInChat(_peer, request.command, request.context);
|
||||
|
||||
auto message = ApiWrap::MessageToSend(_history);
|
||||
message.textWithTags = { toSend, TextWithTags::Tags() };
|
||||
message.action.replyTo = replyTo
|
||||
message.action.replyTo = request.replyTo
|
||||
? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/)
|
||||
? replyTo
|
||||
? request.replyTo
|
||||
: replyToId())
|
||||
: 0;
|
||||
session().api().sendMessage(std::move(message));
|
||||
if (replyTo) {
|
||||
if (_replyToId == replyTo) {
|
||||
if (request.replyTo) {
|
||||
if (_replyToId == request.replyTo) {
|
||||
cancelReply();
|
||||
saveCloudDraft();
|
||||
}
|
||||
|
Reference in New Issue
Block a user