diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 48271683..50bfe1db 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -54,7 +54,8 @@ inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = In inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia; inputMediaGame#d33f43f3 id:InputGame = InputMedia; inputMediaInvoice#f4e096c3 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:string = InputMedia; -inputMediaGeoLive#7b1a118f geo_point:InputGeoPoint period:int = InputMedia; +inputMediaGeoLive#ce4e82fd flags:# stopped:flags.0?true geo_point:InputGeoPoint period:flags.1?int = InputMedia; +inputMediaPoll#6b3765b poll:Poll = InputMedia; inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; inputChatUploadedPhoto#927c55b4 file:InputFile = InputChatPhoto; @@ -110,7 +111,7 @@ channel#c88974ac flags:# creator:flags.0?true left:flags.2?true editor:flags.3?t channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; chatFull#edd2a791 flags:# id:int participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int = ChatFull; -channelFull#76af5481 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int = ChatFull; +channelFull#1c87a71a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant; @@ -137,6 +138,7 @@ messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:str messageMediaGame#fdb19008 game:Game = MessageMedia; messageMediaInvoice#84551347 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument receipt_msg_id:flags.2?int currency:string total_amount:long start_param:string = MessageMedia; messageMediaGeoLive#7c3c2609 geo:GeoPoint period:int = MessageMedia; +messageMediaPoll#4bd6e798 poll:Poll results:PollResults = MessageMedia; messageActionEmpty#b6aef7b0 = MessageAction; messageActionChatCreate#a6638b9a title:string users:Vector = MessageAction; @@ -160,7 +162,7 @@ messageActionCustomAction#fae69f56 message:string = MessageAction; messageActionBotAllowed#abe9affe domain:string = MessageAction; messageActionSecureValuesSentMe#1b287353 values:Vector credentials:SecureCredentialsEncrypted = MessageAction; messageActionSecureValuesSent#d95c6154 types:Vector = MessageAction; -messageActionContactSignUp#70ef8294 flags:# silent:flags.0?true = MessageAction; +messageActionContactSignUp#f3f25f76 = MessageAction; dialog#e4def5db flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage = Dialog; @@ -324,6 +326,7 @@ updateChannelAvailableMessages#70db6837 channel_id:int available_min_id:int = Up updateDialogUnreadMark#e16459c3 flags:# unread:flags.0?true peer:DialogPeer = Update; updateUserPinnedMessage#4c43da18 user_id:int id:int = Update; updateChatPinnedMessage#22893b26 chat_id:int id:int = Update; +updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -966,6 +969,18 @@ help.supportName#8c05f1c9 name:string = help.SupportName; help.userInfoEmpty#f3ae2eed = help.UserInfo; help.userInfo#1eb3758 message:string entities:Vector author:string date:int = help.UserInfo; +pollAnswer#6ca9c2e9 text:string option:bytes = PollAnswer; + +poll#d5529d06 id:long flags:# closed:flags.0?true question:string answers:Vector = Poll; + +pollAnswerVoters#3b6ddad2 flags:# chosen:flags.0?true option:bytes voters:int = PollAnswerVoters; + +pollResults#5755785a flags:# min:flags.0?true results:flags.1?Vector total_voters:flags.2?int = PollResults; + +chatOnlines#f041e250 onlines:int = ChatOnlines; + +statsURL#47a971e0 url:string = StatsURL; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1122,8 +1137,8 @@ messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_p messages.setInlineBotResults#eb5ea206 flags:# gallery:flags.0?true private:flags.1?true query_id:long results:Vector cache_time:int next_offset:flags.2?string switch_pm:flags.3?InlineBotSwitchPM = Bool; messages.sendInlineBotResult#b16e06fe flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true hide_via:flags.11?true peer:InputPeer reply_to_msg_id:flags.0?int random_id:long query_id:long id:string = Updates; messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; -messages.editMessage#c000e4c8 flags:# no_webpage:flags.1?true stop_geo_live:flags.12?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector geo_point:flags.13?InputGeoPoint = Updates; -messages.editInlineBotMessage#adc3e828 flags:# no_webpage:flags.1?true stop_geo_live:flags.12?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector geo_point:flags.13?InputGeoPoint = Bool; +messages.editMessage#d116f31e flags:# no_webpage:flags.1?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Updates; +messages.editInlineBotMessage#83557dba flags:# no_webpage:flags.1?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Bool; messages.getBotCallbackAnswer#810a9fec flags:# game:flags.1?true peer:InputPeer msg_id:int data:flags.0?bytes = messages.BotCallbackAnswer; messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long message:flags.0?string url:flags.2?string cache_time:int = Bool; messages.getPeerDialogs#e470bcfd peers:Vector = messages.PeerDialogs; @@ -1164,6 +1179,10 @@ messages.markDialogUnread#c286d98f flags:# unread:flags.0?true peer:InputDialogP messages.getDialogUnreadMarks#22e24e22 = Vector; messages.clearAllDrafts#7e58ee9c = Bool; messages.updatePinnedMessage#d2aaf7ec flags:# silent:flags.0?true peer:InputPeer id:int = Updates; +messages.sendVote#10ea6184 peer:InputPeer msg_id:int options:Vector = Updates; +messages.getPollResults#73bb643b peer:InputPeer msg_id:int = Updates; +messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines; +messages.getStatsURL#83f6c0cd peer:InputPeer = StatsURL; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1227,7 +1246,6 @@ channels.deleteChannel#c0111fe3 channel:InputChannel = Updates; channels.toggleInvites#49609307 channel:InputChannel enabled:Bool = Updates; channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink; channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; -channels.updatePinnedMessage#a72ded52 flags:# silent:flags.0?true channel:InputChannel id:int = Updates; channels.getAdminedPublicChannels#8d8d82d7 = messages.Chats; channels.editBanned#bfd915cd channel:InputChannel user_id:InputUser banned_rights:ChannelBannedRights = Updates; channels.getAdminLog#33ddf480 flags:# channel:InputChannel q:string events_filter:flags.0?ChannelAdminLogEventsFilter admins:flags.1?Vector max_id:long min_id:long limit:int = channels.AdminLogResults; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index 33dc5539..bc1dceb6 100644 Binary files a/td/generate/scheme/telegram_api.tlo and b/td/generate/scheme/telegram_api.tlo differ diff --git a/td/telegram/Location.cpp b/td/telegram/Location.cpp index 5d22ccb8..e4c09bcf 100644 --- a/td/telegram/Location.cpp +++ b/td/telegram/Location.cpp @@ -81,7 +81,6 @@ tl_object_ptr Location::get_location_object() const { tl_object_ptr Location::get_input_geo_point() const { if (empty()) { - LOG(ERROR) << "Location is empty"; return make_tl_object(); } diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 7dd14aa9..9a1dde14 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2037,7 +2037,9 @@ static tl_object_ptr get_input_media(const MessageCont } case MessageContentType::LiveLocation: { auto m = static_cast(content); - return make_tl_object(m->location.get_input_geo_point(), m->period); + int32 flags = telegram_api::inputMediaGeoLive::PERIOD_MASK; + return make_tl_object(flags, false /*ignored*/, + m->location.get_input_geo_point(), m->period); } case MessageContentType::Location: { auto m = static_cast(content); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 0988a2f7..8d292a1e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -2194,7 +2194,6 @@ class EditMessageActor : public NetActorOnce { void send(int32 flags, DialogId dialog_id, MessageId message_id, const string &message, vector> &&entities, tl_object_ptr &&input_media, - tl_object_ptr &&input_geo_point, tl_object_ptr &&reply_markup, uint64 sequence_dispatcher_id) { dialog_id_ = dialog_id; @@ -2223,14 +2222,11 @@ class EditMessageActor : public NetActorOnce { if (input_media != nullptr) { flags |= telegram_api::messages_editMessage::MEDIA_MASK; } - if (input_geo_point != nullptr) { - flags |= telegram_api::messages_editMessage::GEO_POINT_MASK; - } LOG(DEBUG) << "Edit message with flags " << flags; auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_editMessage( - flags, false /*ignored*/, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get(), - message, std::move(input_media), std::move(reply_markup), std::move(entities), std::move(input_geo_point)))); + flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get(), message, + std::move(input_media), std::move(reply_markup), std::move(entities)))); query->debug("send to MessagesManager::MultiSequenceDispatcher"); send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, @@ -2275,7 +2271,6 @@ class EditInlineMessageQuery : public Td::ResultHandler { void send(int32 flags, tl_object_ptr input_bot_inline_message_id, const string &message, vector> &&entities, tl_object_ptr &&input_media, - tl_object_ptr &&input_geo_point, tl_object_ptr &&reply_markup) { CHECK(input_bot_inline_message_id != nullptr); @@ -2292,20 +2287,17 @@ class EditInlineMessageQuery : public Td::ResultHandler { if (!message.empty()) { flags |= MessagesManager::SEND_MESSAGE_FLAG_HAS_MESSAGE; } - if (input_geo_point != nullptr) { - flags |= telegram_api::messages_editInlineBotMessage::GEO_POINT_MASK; - } if (input_media != nullptr) { flags |= telegram_api::messages_editInlineBotMessage::MEDIA_MASK; } LOG(DEBUG) << "Edit inline message with flags " << flags; auto dc_id = DcId::internal(input_bot_inline_message_id->dc_id_); - send_query(G()->net_query_creator().create( - create_storer(telegram_api::messages_editInlineBotMessage( - flags, false /*ignored*/, false /*ignored*/, std::move(input_bot_inline_message_id), message, - std::move(input_media), std::move(reply_markup), std::move(entities), std::move(input_geo_point))), - dc_id)); + send_query( + G()->net_query_creator().create(create_storer(telegram_api::messages_editInlineBotMessage( + flags, false /*ignored*/, std::move(input_bot_inline_message_id), message, + std::move(input_media), std::move(reply_markup), std::move(entities))), + dc_id)); } void on_result(uint64 id, BufferSlice packet) override { @@ -15482,7 +15474,7 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, Message *m, send_closure(td_->create_net_actor(std::move(promise)), &EditMessageActor::send, 1 << 11, dialog_id, message_id, caption == nullptr ? "" : caption->text, get_input_message_entities(td_->contacts_manager_.get(), caption, "edit_message_media"), - std::move(input_media), nullptr, std::move(input_reply_markup), + std::move(input_media), std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); return; } @@ -16340,7 +16332,7 @@ void MessagesManager::edit_message_text(FullMessageId full_message_id, td_->create_net_actor(std::move(promise)), &EditMessageActor::send, flags, dialog_id, message_id, input_message_text.text.text, get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities, "edit_message_text"), - nullptr, nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); + nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); } void MessagesManager::edit_message_live_location(FullMessageId full_message_id, @@ -16387,12 +16379,13 @@ void MessagesManager::edit_message_live_location(FullMessageId full_message_id, int32 flags = 0; if (location.empty()) { - flags |= telegram_api::messages_editMessage::STOP_GEO_LIVE_MASK; + flags |= telegram_api::inputMediaGeoLive::STOPPED_MASK; } - send_closure(td_->create_net_actor(std::move(promise)), &EditMessageActor::send, flags, dialog_id, - message_id, string(), vector>(), nullptr, - location.empty() ? nullptr : location.get_input_geo_point(), std::move(input_reply_markup), - get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); + auto input_media = telegram_api::make_object(flags, false /*ignored*/, + location.get_input_geo_point(), 0); + send_closure(td_->create_net_actor(std::move(promise)), &EditMessageActor::send, 0, dialog_id, + message_id, string(), vector>(), std::move(input_media), + std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); } void MessagesManager::cancel_edit_message_media(DialogId dialog_id, Message *m, Slice error_message) { @@ -16599,8 +16592,7 @@ void MessagesManager::edit_message_caption(FullMessageId full_message_id, send_closure(td_->create_net_actor(std::move(promise)), &EditMessageActor::send, 1 << 11, dialog_id, message_id, caption.text, get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_message_caption"), - nullptr, nullptr, std::move(input_reply_markup), - get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); + nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); } void MessagesManager::edit_message_reply_markup(FullMessageId full_message_id, @@ -16638,7 +16630,7 @@ void MessagesManager::edit_message_reply_markup(FullMessageId full_message_id, } auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok()); send_closure(td_->create_net_actor(std::move(promise)), &EditMessageActor::send, 0, dialog_id, - message_id, string(), vector>(), nullptr, nullptr, + message_id, string(), vector>(), nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, MessageContentType::None)); } @@ -16683,7 +16675,7 @@ void MessagesManager::edit_inline_message_text(const string &inline_message_id, ->send(flags, std::move(input_bot_inline_message_id), input_message_text.text.text, get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities, "edit_inline_message_text"), - nullptr, nullptr, get_input_reply_markup(r_new_reply_markup.ok())); + nullptr, get_input_reply_markup(r_new_reply_markup.ok())); } void MessagesManager::edit_inline_message_live_location(const string &inline_message_id, @@ -16711,12 +16703,13 @@ void MessagesManager::edit_inline_message_live_location(const string &inline_mes int32 flags = 0; if (location.empty()) { - flags |= telegram_api::messages_editMessage::STOP_GEO_LIVE_MASK; + flags |= telegram_api::inputMediaGeoLive::STOPPED_MASK; } + auto input_media = telegram_api::make_object(flags, false /*ignored*/, + location.get_input_geo_point(), 0); td_->create_handler(std::move(promise)) - ->send(flags, std::move(input_bot_inline_message_id), "", vector>(), - nullptr, location.empty() ? nullptr : location.get_input_geo_point(), - get_input_reply_markup(r_new_reply_markup.ok())); + ->send(0, std::move(input_bot_inline_message_id), "", vector>(), + std::move(input_media), get_input_reply_markup(r_new_reply_markup.ok())); } void MessagesManager::edit_inline_message_media(const string &inline_message_id, @@ -16768,7 +16761,7 @@ void MessagesManager::edit_inline_message_media(const string &inline_message_id, td_->create_handler(std::move(promise)) ->send(1 << 11, std::move(input_bot_inline_message_id), caption == nullptr ? "" : caption->text, get_input_message_entities(td_->contacts_manager_.get(), caption, "edit_inline_message_media"), - std::move(input_media), nullptr, get_input_reply_markup(r_new_reply_markup.ok())); + std::move(input_media), get_input_reply_markup(r_new_reply_markup.ok())); } void MessagesManager::edit_inline_message_caption(const string &inline_message_id, @@ -16799,7 +16792,7 @@ void MessagesManager::edit_inline_message_caption(const string &inline_message_i td_->create_handler(std::move(promise)) ->send(1 << 11, std::move(input_bot_inline_message_id), caption.text, get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_inline_message_caption"), - nullptr, nullptr, get_input_reply_markup(r_new_reply_markup.ok())); + nullptr, get_input_reply_markup(r_new_reply_markup.ok())); } void MessagesManager::edit_inline_message_reply_markup(const string &inline_message_id, @@ -16821,7 +16814,7 @@ void MessagesManager::edit_inline_message_reply_markup(const string &inline_mess td_->create_handler(std::move(promise)) ->send(0, std::move(input_bot_inline_message_id), string(), vector>(), - nullptr, nullptr, get_input_reply_markup(r_new_reply_markup.ok())); + nullptr, get_input_reply_markup(r_new_reply_markup.ok())); } int32 MessagesManager::get_message_flags(const Message *m) { diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index ef4bf511..f66e6a58 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1871,4 +1871,7 @@ void UpdatesManager::on_update(tl_object_ptr updat // unsupported updates +void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { +} + } // namespace td diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 1ae4016d..2c6395d2 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -281,6 +281,7 @@ class UpdatesManager : public Actor { void on_update(tl_object_ptr update, bool /*force_apply*/); // unsupported updates + void on_update(tl_object_ptr update, bool /*force_apply*/); }; } // namespace td diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 39fbe56c..029fbdb8 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -565,6 +565,9 @@ class CliClient final : public Actor { } static tl_object_ptr as_location(string latitude, string longitude) { + if (trim(latitude).empty() && trim(longitude).empty()) { + return nullptr; + } return make_tl_object(to_double(latitude), to_double(longitude)); } diff --git a/td/telegram/net/MtprotoHeader.cpp b/td/telegram/net/MtprotoHeader.cpp index 481cab87..cf769cee 100644 --- a/td/telegram/net/MtprotoHeader.cpp +++ b/td/telegram/net/MtprotoHeader.cpp @@ -21,7 +21,7 @@ class HeaderStorer { } template void store(StorerT &storer) const { - constexpr int32 LAYER = 90; + constexpr int32 LAYER = 91; using td::store; // invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;