Initial support for managed bot creation.

This commit is contained in:
John Preston
2026-03-17 19:01:19 +04:00
parent 8224e6ece1
commit 358a9f87a1
27 changed files with 983 additions and 54 deletions

View File

@@ -1027,6 +1027,8 @@ bool Panel::createWebview(const Webview::ThemeParams &params) {
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();