| 426 | } |
| 427 | |
| 428 | void UserData::setBotInfo(const MTPBotInfo &info) { |
| 429 | switch (info.type()) { |
| 430 | case mtpc_botInfo: { |
| 431 | const auto &d = info.c_botInfo(); |
| 432 | if (!isBot()) { |
| 433 | return; |
| 434 | } else if (d.vuser_id() && peerFromUser(*d.vuser_id()) != id) { |
| 435 | return; |
| 436 | } |
| 437 | |
| 438 | const auto description = qs(d.vdescription().value_or_empty()); |
| 439 | if (botInfo->description != description) { |
| 440 | botInfo->description = description; |
| 441 | ++botInfo->descriptionVersion; |
| 442 | } |
| 443 | if (const auto photo = d.vdescription_photo()) { |
| 444 | const auto parsed = owner().processPhoto(*photo); |
| 445 | if (botInfo->photo != parsed) { |
| 446 | botInfo->photo = parsed; |
| 447 | ++botInfo->descriptionVersion; |
| 448 | } |
| 449 | } else if (botInfo->photo) { |
| 450 | botInfo->photo = nullptr; |
| 451 | ++botInfo->descriptionVersion; |
| 452 | } |
| 453 | if (const auto document = d.vdescription_document()) { |
| 454 | const auto parsed = owner().processDocument(*document); |
| 455 | if (botInfo->document != parsed) { |
| 456 | botInfo->document = parsed; |
| 457 | ++botInfo->descriptionVersion; |
| 458 | } |
| 459 | } else if (botInfo->document) { |
| 460 | botInfo->document = nullptr; |
| 461 | ++botInfo->descriptionVersion; |
| 462 | } |
| 463 | |
| 464 | auto commands = d.vcommands() |
| 465 | ? ranges::views::all( |
| 466 | d.vcommands()->v |
| 467 | ) | ranges::views::transform( |
| 468 | Data::BotCommandFromTL |
| 469 | ) | ranges::to_vector |
| 470 | : std::vector<Data::BotCommand>(); |
| 471 | const auto changedCommands = !ranges::equal( |
| 472 | botInfo->commands, |
| 473 | commands); |
| 474 | botInfo->commands = std::move(commands); |
| 475 | |
| 476 | const auto changedButton = Data::ApplyBotMenuButton( |
| 477 | botInfo.get(), |
| 478 | d.vmenu_button()); |
| 479 | botInfo->inited = true; |
| 480 | |
| 481 | const auto privacy = qs(d.vprivacy_policy_url().value_or_empty()); |
| 482 | const auto privacyChanged = (botInfo->privacyPolicyUrl != privacy); |
| 483 | botInfo->privacyPolicyUrl = privacy; |
| 484 | |
| 485 | if (const auto settings = d.vapp_settings()) { |
no test coverage detected