mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-20 08:03:45 +08:00
Initial support for managed bot creation.
This commit is contained in:
@@ -1027,6 +1027,8 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
||||
processBottomBarColor(arguments);
|
||||
} else if (command == "web_app_send_prepared_message") {
|
||||
processSendMessageRequest(arguments);
|
||||
} else if (command == "web_app_request_chat") {
|
||||
processRequestChat(arguments);
|
||||
} else if (command == "web_app_set_emoji_status") {
|
||||
processEmojiStatusRequest(arguments);
|
||||
} else if (command == "web_app_request_emoji_status_access") {
|
||||
@@ -1214,6 +1216,34 @@ void Panel::processSendMessageRequest(const QJsonObject &args) {
|
||||
});
|
||||
}
|
||||
|
||||
void Panel::processRequestChat(const QJsonObject &args) {
|
||||
if (args.isEmpty()) {
|
||||
_delegate->botClose();
|
||||
return;
|
||||
}
|
||||
const auto requestId = args["req_id"].toString();
|
||||
if (requestId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
auto callback = crl::guard(this, [=](QString error) {
|
||||
if (error.isEmpty()) {
|
||||
postEvent(
|
||||
"requested_chat_sent",
|
||||
u"{ req_id: \"%1\" }"_q.arg(requestId));
|
||||
} else {
|
||||
postEvent(
|
||||
"requested_chat_failed",
|
||||
u"{ req_id: \"%1\", error: \"%2\" }"_q.arg(
|
||||
requestId,
|
||||
error));
|
||||
}
|
||||
});
|
||||
_delegate->botRequestChat({
|
||||
.requestId = requestId,
|
||||
.callback = std::move(callback),
|
||||
});
|
||||
}
|
||||
|
||||
void Panel::processEmojiStatusRequest(const QJsonObject &args) {
|
||||
if (args.isEmpty()) {
|
||||
_delegate->botClose();
|
||||
|
||||
Reference in New Issue
Block a user