mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-11 11:47:09 +02:00
Fix sending bot commands in paid chats.
This commit is contained in:
parent
940455f786
commit
d43a6da62b
4 changed files with 51 additions and 3 deletions
|
@ -4917,13 +4917,32 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
}
|
||||
|
||||
void HistoryWidget::sendBotCommand(const Bot::SendCommandRequest &request) {
|
||||
// replyTo != 0 from ReplyKeyboardMarkup, == 0 from command links
|
||||
sendBotCommand(request, {});
|
||||
}
|
||||
|
||||
void HistoryWidget::sendBotCommand(
|
||||
const Bot::SendCommandRequest &request,
|
||||
Api::SendOptions options) {
|
||||
// replyTo != 0 from ReplyKeyboardMarkup, == 0 from command links
|
||||
if (_peer != request.peer.get()) {
|
||||
return;
|
||||
} else if (showSlowmodeError()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto withPaymentApproved = [=](int approved) {
|
||||
auto copy = options;
|
||||
copy.starsApproved = approved;
|
||||
sendBotCommand(request, copy);
|
||||
};
|
||||
const auto checked = checkSendPayment(
|
||||
1,
|
||||
options.starsApproved,
|
||||
withPaymentApproved);
|
||||
if (!checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto forMsgId = _keyboard->forMsgId();
|
||||
const auto lastKeyboardUsed = (forMsgId == request.replyTo.messageId)
|
||||
&& (forMsgId == FullMsgId(_peer->id, _history->lastKeyboardId));
|
||||
|
@ -4933,7 +4952,7 @@ void HistoryWidget::sendBotCommand(const Bot::SendCommandRequest &request) {
|
|||
? request.command
|
||||
: Bot::WrapCommandInChat(_peer, request.command, request.context);
|
||||
|
||||
auto message = Api::MessageToSend(prepareSendAction({}));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = { toSend, TextWithTags::Tags() };
|
||||
message.action.replyTo = request.replyTo
|
||||
? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/)
|
||||
|
|
|
@ -491,6 +491,10 @@ private:
|
|||
std::shared_ptr<Ui::PreparedBundle> bundle,
|
||||
Api::SendOptions options);
|
||||
|
||||
void sendBotCommand(
|
||||
const Bot::SendCommandRequest &request,
|
||||
Api::SendOptions options);
|
||||
|
||||
void uploadFile(const QByteArray &fileContent, SendMediaType type);
|
||||
void itemRemoved(not_null<const HistoryItem*> item);
|
||||
|
||||
|
|
|
@ -2724,11 +2724,31 @@ bool RepliesWidget::listIsGoodForAroundPosition(
|
|||
void RepliesWidget::listSendBotCommand(
|
||||
const QString &command,
|
||||
const FullMsgId &context) {
|
||||
sendBotCommandWithOptions(command, context, {});
|
||||
}
|
||||
|
||||
void RepliesWidget::sendBotCommandWithOptions(
|
||||
const QString &command,
|
||||
const FullMsgId &context,
|
||||
Api::SendOptions options) {
|
||||
const auto withPaymentApproved = [=](int approved) {
|
||||
auto copy = options;
|
||||
copy.starsApproved = approved;
|
||||
sendBotCommandWithOptions(command, context, copy);
|
||||
};
|
||||
const auto checked = checkSendPayment(
|
||||
1,
|
||||
options.starsApproved,
|
||||
withPaymentApproved);
|
||||
if (!checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto text = Bot::WrapCommandInChat(
|
||||
_history->peer,
|
||||
command,
|
||||
context);
|
||||
auto message = Api::MessageToSend(prepareSendAction({}));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = { text };
|
||||
session().api().sendMessage(std::move(message));
|
||||
finishSending();
|
||||
|
|
|
@ -319,6 +319,11 @@ private:
|
|||
std::shared_ptr<Ui::PreparedBundle> bundle,
|
||||
Api::SendOptions options);
|
||||
|
||||
void sendBotCommandWithOptions(
|
||||
const QString &command,
|
||||
const FullMsgId &context,
|
||||
Api::SendOptions options);
|
||||
|
||||
bool sendExistingDocument(
|
||||
not_null<DocumentData*> document,
|
||||
Api::MessageToSend messageToSend,
|
||||
|
|
Loading…
Add table
Reference in a new issue