MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / sendBotStart

Method sendBotStart

Telegram/SourceFiles/apiwrap.cpp:4497–4540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4495}
4496
4497void ApiWrap::sendBotStart(
4498 std::shared_ptr<Ui::Show> show,
4499 not_null<UserData*> bot,
4500 PeerData *chat,
4501 const QString &startTokenForChat) {
4502 Expects(bot->isBot());
4503
4504 if (chat && chat->isChannel() && !chat->isMegagroup()) {
4505 ShowAddParticipantsError(show, "USER_BOT", chat, bot);
4506 return;
4507 }
4508
4509 auto &info = bot->botInfo;
4510 const auto token = chat ? startTokenForChat : info->startToken;
4511 if (token.isEmpty()) {
4512 auto message = MessageToSend(
4513 Api::SendAction(_session->data().history(chat
4514 ? chat
4515 : bot.get())));
4516 message.textWithTags = { u"/start"_q, TextWithTags::Tags() };
4517 if (chat) {
4518 message.textWithTags.text += '@' + bot->username();
4519 }
4520 sendMessage(std::move(message));
4521 return;
4522 }
4523 const auto randomId = base::RandomValue<uint64>();
4524 if (!chat) {
4525 info->startToken = QString();
4526 }
4527 request(MTPmessages_StartBot(
4528 bot->inputUser(),
4529 chat ? chat->input() : MTP_inputPeerEmpty(),
4530 MTP_long(randomId),
4531 MTP_string(token)
4532 )).done([=](const MTPUpdates &result) {
4533 applyUpdates(result);
4534 }).fail([=](const MTP::Error &error) {
4535 if (chat) {
4536 const auto type = error.type();
4537 ShowAddParticipantsError(show, type, chat, bot);
4538 }
4539 }).send();
4540}
4541
4542void ApiWrap::sendInlineResult(
4543 not_null<UserData*> bot,

Callers 5

addBotToGroupMethod · 0.80
AddBotToGroupFunction · 0.80
toggleBotManagerMethod · 0.80
sendBotStartCommandMethod · 0.80

Calls 15

ShowAddParticipantsErrorFunction · 0.85
MTP_longFunction · 0.85
MTP_stringFunction · 0.85
isChannelMethod · 0.80
inputUserMethod · 0.80
MessageToSendClass · 0.50
SendActionClass · 0.50
QStringClass · 0.50
isBotMethod · 0.45
isMegagroupMethod · 0.45
isEmptyMethod · 0.45
historyMethod · 0.45

Tested by

no test coverage detected