本文整理汇总了C++中not_null::getMessageBot方法的典型用法代码示例。如果您正苦于以下问题:C++ not_null::getMessageBot方法的具体用法?C++ not_null::getMessageBot怎么用?C++ not_null::getMessageBot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类not_null
的用法示例。
在下文中一共展示了not_null::getMessageBot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FastShareMessage
void FastShareMessage(not_null<HistoryItem*> item) {
struct ShareData {
ShareData(not_null<PeerData*> peer, MessageIdsList &&ids)
: peer(peer)
, msgIds(std::move(ids)) {
}
not_null<PeerData*> peer;
MessageIdsList msgIds;
base::flat_set<mtpRequestId> requests;
};
const auto data = std::make_shared<ShareData>(
item->history()->peer,
Auth().data().itemOrItsGroup(item));
const auto isGroup = (Auth().data().groups().find(item) != nullptr);
const auto isGame = item->getMessageBot()
&& item->media()
&& (item->media()->game() != nullptr);
const auto canCopyLink = item->hasDirectLink() || isGame;
auto copyCallback = [data]() {
if (auto main = App::main()) {
if (auto item = App::histItemById(data->msgIds[0])) {
if (item->hasDirectLink()) {
QApplication::clipboard()->setText(item->directLink());
Ui::Toast::Show(lang(lng_channel_public_link_copied));
} else if (const auto bot = item->getMessageBot()) {
if (const auto media = item->media()) {
if (const auto game = media->game()) {
const auto link = Messenger::Instance().createInternalLinkFull(
bot->username
+ qsl("?game=")
+ game->shortName);
QApplication::clipboard()->setText(link);
Ui::Toast::Show(lang(lng_share_game_link_copied));
}
}
}
}
}
};
auto submitCallback = [data, isGroup](const QVector<PeerData*> &result) {
if (!data->requests.empty()) {
return; // Share clicked already.
}
auto items = Auth().data().idsToItems(data->msgIds);
if (items.empty() || result.empty()) {
return;
}
auto restrictedSomewhere = false;
auto restrictedEverywhere = true;
auto firstError = QString();
for (const auto peer : result) {
const auto error = GetErrorTextForForward(peer, items);
if (!error.isEmpty()) {
if (firstError.isEmpty()) {
firstError = error;
}
restrictedSomewhere = true;
continue;
}
restrictedEverywhere = false;
}
if (restrictedEverywhere) {
Ui::show(
Box<InformBox>(firstError),
LayerOption::KeepOther);
return;
}
auto doneCallback = [data](const MTPUpdates &updates, mtpRequestId requestId) {
if (auto main = App::main()) {
main->sentUpdatesReceived(updates);
}
data->requests.remove(requestId);
if (data->requests.empty()) {
Ui::Toast::Show(lang(lng_share_done));
Ui::hideLayer();
}
};
const auto sendFlags = MTPmessages_ForwardMessages::Flag(0)
| MTPmessages_ForwardMessages::Flag::f_with_my_score
| (isGroup
? MTPmessages_ForwardMessages::Flag::f_grouped
: MTPmessages_ForwardMessages::Flag(0));
auto msgIds = QVector<MTPint>();
msgIds.reserve(data->msgIds.size());
for (const auto fullId : data->msgIds) {
msgIds.push_back(MTP_int(fullId.msg));
}
auto generateRandom = [&] {
auto result = QVector<MTPlong>(data->msgIds.size());
for (auto &value : result) {
value = rand_value<MTPlong>();
}
return result;
//.........这里部分代码省略.........