|
地板
楼主 |
发表于 2020-3-2 11:52:50
|
只看该作者
本帖最后由 Qter 于 2020-3-2 11:58 编辑
scheme.tl中的定义- messages.sendMessage#fa88427a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> = Updates;
复制代码 自动生成的代码
scheme.h- class MTPmessages_sendMessage { // RPC method 'messages.sendMessage'
- public:
- enum class Flag : uint32 {
- f_no_webpage = (1U << 1),
- f_silent = (1U << 5),
- f_background = (1U << 6),
- f_clear_draft = (1U << 7),
- f_reply_to_msg_id = (1U << 0),
- f_reply_markup = (1U << 2),
- f_entities = (1U << 3),
- MAX_FIELD = (1U << 7),
- };
- using Flags = base::flags<Flag>;
- friend inline constexpr auto is_flag_type(Flag) { return true; };
- bool is_no_webpage() const { return vflags.v & Flag::f_no_webpage; }
- bool is_silent() const { return vflags.v & Flag::f_silent; }
- bool is_background() const { return vflags.v & Flag::f_background; }
- bool is_clear_draft() const { return vflags.v & Flag::f_clear_draft; }
- bool has_reply_to_msg_id() const { return vflags.v & Flag::f_reply_to_msg_id; }
- bool has_reply_markup() const { return vflags.v & Flag::f_reply_markup; }
- bool has_entities() const { return vflags.v & Flag::f_entities; }
- MTPflags<MTPmessages_sendMessage::Flags> vflags;
- MTPInputPeer vpeer;
- MTPint vreply_to_msg_id;
- MTPstring vmessage;
- MTPlong vrandom_id;
- MTPReplyMarkup vreply_markup;
- MTPVector<MTPMessageEntity> ventities;
- MTPmessages_sendMessage() = default;
- MTPmessages_sendMessage(const MTPflags<MTPmessages_sendMessage::Flags> &_flags, const MTPInputPeer &_peer, MTPint _reply_to_msg_id, const MTPstring &_message, const MTPlong &_random_id, const MTPReplyMarkup &_reply_markup, const MTPVector<MTPMessageEntity> &_entities) : vflags(_flags), vpeer(_peer), vreply_to_msg_id(_reply_to_msg_id), vmessage(_message), vrandom_id(_random_id), vreply_markup(_reply_markup), ventities(_entities) {
- }
- uint32 innerLength() const;
- mtpTypeId type() const {
- return mtpc_messages_sendMessage;
- }
- void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_sendMessage);
- void write(mtpBuffer &to) const;
- using ResponseType = MTPUpdates;
- };
- using MTPmessages_SendMessage = MTPBoxed<MTPmessages_sendMessage>;
复制代码 scheme.cpp
- uint32 MTPmessages_sendMessage::innerLength() const {
- return vflags.innerLength() + vpeer.innerLength() + (has_reply_to_msg_id() ? vreply_to_msg_id.innerLength() : 0) + vmessage.innerLength() + vrandom_id.innerLength() + (has_reply_markup() ? vreply_markup.innerLength() : 0) + (has_entities() ? ventities.innerLength() : 0);
- }
- void MTPmessages_sendMessage::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) {
- vflags.read(from, end);
- vpeer.read(from, end);
- if (has_reply_to_msg_id()) { vreply_to_msg_id.read(from, end); } else { vreply_to_msg_id = MTPint(); }
- vmessage.read(from, end);
- vrandom_id.read(from, end);
- if (has_reply_markup()) { vreply_markup.read(from, end); } else { vreply_markup = MTPReplyMarkup(); }
- if (has_entities()) { ventities.read(from, end); } else { ventities = MTPVector<MTPMessageEntity>(); }
- }
- void MTPmessages_sendMessage::write(mtpBuffer &to) const {
- vflags.write(to);
- vpeer.write(to);
- if (has_reply_to_msg_id()) vreply_to_msg_id.write(to);
- vmessage.write(to);
- vrandom_id.write(to);
- if (has_reply_markup()) vreply_markup.write(to);
- if (has_entities()) ventities.write(to);
- }
复制代码 代码中的调用- auto sendFlags = MTPmessages_SendMessage::Flags(0);
- sendFlags |= MTPmessages_SendMessage::Flag::f_reply_to_msg_id;
- sendFlags |= MTPmessages_SendMessage::Flag::f_no_webpage;
- sendFlags |= MTPmessages_SendMessage::Flag::f_silent;
- lastMessage = history->addNewMessage(
- MTP_message(
- MTP_flags(flags),
- MTP_int(newId.msg),
- MTP_int(messageFromId),
- peerToMTP(peer->id),
- MTPMessageFwdHeader(),
- MTPint(),
- MTP_int(message.replyTo),
- MTP_int(unixtime()),
- msgText,
- media,
- MTPReplyMarkup(),
- localEntities,
- MTP_int(1),
- MTPint(),
- MTP_string(messagePostAuthor),
- MTPlong()),
- NewMessageUnread);
- history->sendRequestId = request(MTPmessages_SendMessage(
- MTP_flags(sendFlags),
- peer->input,
- MTP_int(message.replyTo),
- msgText,
- MTP_long(randomId),
- MTPReplyMarkup(),
- sentEntities
- )).done([=](const MTPUpdates &result) {
- applyUpdates(result, randomId);
- history->clearSentDraftText(QString());
- }).fail([=](const RPCError &error) {
- if (error.type() == qstr("MESSAGE_EMPTY")) {
- lastMessage->destroy();
- } else {
- sendMessageFail(error);
- }
- history->clearSentDraftText(QString());
- }).afterRequest(history->sendRequestId
- ).send();
复制代码 日志:
发送- [11:56:21.034 01-0006421] (dc:2) Send: { core_message
- msg_id: 6799454597686760760 [LONG],
- seq_no: 352 [INT],
- bytes: 148 [INT],
- body: { msg_container
- messages: [ vector<0xffffffffffffffff>
- { core_message
- msg_id: 6799454597686728540 [LONG],
- seq_no: 351 [INT],
- bytes: 88 [INT],
- body: { messages_sendMessage
- flags: 128 [INT],
- no_webpage: [ SKIPPED BY BIT 1 IN FIELD flags ],
- silent: [ SKIPPED BY BIT 5 IN FIELD flags ],
- background: [ SKIPPED BY BIT 6 IN FIELD flags ],
- clear_draft: YES [ BY BIT 7 IN FIELD flags ],
- peer: { inputPeerChat
- chat_id: 1 [INT],
- },
- reply_to_msg_id: [ SKIPPED BY BIT 0 IN FIELD flags ],
- message: "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" [STRING],
- random_id: 14114719467741365869 [LONG],
- reply_markup: [ SKIPPED BY BIT 2 IN FIELD flags ],
- entities: [ SKIPPED BY BIT 3 IN FIELD flags ],
- },
- },
- { core_message
- msg_id: 6799454597686745724 [LONG],
- seq_no: 352 [INT],
- bytes: 20 [INT],
- body: { msgs_ack
- msg_ids: [ vector<0x22076cba>
- 6799454563309987337 [LONG],
- ],
- },
- },
- ],
- },
- }
复制代码 返回
- [11:56:21.247 01-0006436] (dc:2) Recv: { core_message
- msg_id: 6799454593288775185 [LONG],
- seq_no: 51 [INT],
- bytes: 292 [INT],
- body: { rpc_result
- req_msg_id: 6799454597686728540 [LONG],
- result: { updates
- updates: [ vector<0x0>
- { updateMessageID
- id: 172 [INT],
- random_id: 14114719467741365869 [LONG],
- },
- { updateNewMessage
- message: { message
- flags: 770 [INT],
- out: YES [ BY BIT 1 IN FIELD flags ],
- mentioned: [ SKIPPED BY BIT 4 IN FIELD flags ],
- media_unread: [ SKIPPED BY BIT 5 IN FIELD flags ],
- silent: [ SKIPPED BY BIT 13 IN FIELD flags ],
- post: [ SKIPPED BY BIT 14 IN FIELD flags ],
- from_scheduled: [ SKIPPED BY BIT 18 IN FIELD flags ],
- id: 172 [INT],
- from_id: 10000001 [INT],
- to_id: { peerChat
- chat_id: 1 [INT],
- },
- fwd_from: [ SKIPPED BY BIT 2 IN FIELD flags ],
- via_bot_id: [ SKIPPED BY BIT 11 IN FIELD flags ],
- reply_to_msg_id: [ SKIPPED BY BIT 3 IN FIELD flags ],
- date: 1583121389 [INT],
- message: "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" [STRING],
- media: { messageMediaEmpty },
- reply_markup: [ SKIPPED BY BIT 6 IN FIELD flags ],
- entities: [ SKIPPED BY BIT 7 IN FIELD flags ],
- views: [ SKIPPED BY BIT 10 IN FIELD flags ],
- edit_date: [ SKIPPED BY BIT 15 IN FIELD flags ],
- post_author: [ SKIPPED BY BIT 16 IN FIELD flags ],
- grouped_id: [ SKIPPED BY BIT 17 IN FIELD flags ],
- },
- pts: 316 [INT],
- pts_count: 1 [INT],
- },
- ],
- users: [ vector<0x0>
- { user
- flags: 4201591 [INT],
- self: YES [ BY BIT 10 IN FIELD flags ],
- contact: YES [ BY BIT 11 IN FIELD flags ],
- mutual_contact: YES [ BY BIT 12 IN FIELD flags ],
- deleted: [ SKIPPED BY BIT 13 IN FIELD flags ],
- bot: [ SKIPPED BY BIT 14 IN FIELD flags ],
- bot_chat_history: [ SKIPPED BY BIT 15 IN FIELD flags ],
- bot_nochats: [ SKIPPED BY BIT 16 IN FIELD flags ],
- verified: [ SKIPPED BY BIT 17 IN FIELD flags ],
- restricted: [ SKIPPED BY BIT 18 IN FIELD flags ],
- min: [ SKIPPED BY BIT 20 IN FIELD flags ],
- bot_inline_geo: [ SKIPPED BY BIT 21 IN FIELD flags ],
- support: [ SKIPPED BY BIT 23 IN FIELD flags ],
- id: 10000001 [INT],
- access_hash: 1827705845932265805 [LONG],
- first_name: "13812345678" [STRING],
- last_name: "t" [STRING],
- username: [ SKIPPED BY BIT 3 IN FIELD flags ],
- phone: "8613812345678" [STRING],
- photo: { userProfilePhotoEmpty },
- status: { userStatusOnline
- expires: 1583121449 [INT],
- },
- bot_info_version: [ SKIPPED BY BIT 14 IN FIELD flags ],
- restriction_reason: [ SKIPPED BY BIT 18 IN FIELD flags ],
- bot_inline_placeholder: [ SKIPPED BY BIT 19 IN FIELD flags ],
- lang_code: "" [STRING],
- },
- ],
- chats: [ vector<0x0>
- { chat
- flags: 262144 [INT],
- creator: [ SKIPPED BY BIT 0 IN FIELD flags ],
- kicked: [ SKIPPED BY BIT 1 IN FIELD flags ],
- left: [ SKIPPED BY BIT 2 IN FIELD flags ],
- deactivated: [ SKIPPED BY BIT 5 IN FIELD flags ],
- id: 1 [INT],
- title: "tangtest" [STRING],
- photo: { chatPhotoEmpty },
- participants_count: 1 [INT],
- date: 1578387290 [INT],
- version: 1 [INT],
- migrated_to: [ SKIPPED BY BIT 6 IN FIELD flags ],
- admin_rights: [ SKIPPED BY BIT 14 IN FIELD flags ],
- default_banned_rights: { chatBannedRights
- flags: 0 [INT],
- view_messages: [ SKIPPED BY BIT 0 IN FIELD flags ],
- send_messages: [ SKIPPED BY BIT 1 IN FIELD flags ],
- send_media: [ SKIPPED BY BIT 2 IN FIELD flags ],
- send_stickers: [ SKIPPED BY BIT 3 IN FIELD flags ],
- send_gifs: [ SKIPPED BY BIT 4 IN FIELD flags ],
- send_games: [ SKIPPED BY BIT 5 IN FIELD flags ],
- send_inline: [ SKIPPED BY BIT 6 IN FIELD flags ],
- embed_links: [ SKIPPED BY BIT 7 IN FIELD flags ],
- send_polls: [ SKIPPED BY BIT 8 IN FIELD flags ],
- change_info: [ SKIPPED BY BIT 10 IN FIELD flags ],
- invite_users: [ SKIPPED BY BIT 15 IN FIELD flags ],
- pin_messages: [ SKIPPED BY BIT 17 IN FIELD flags ],
- until_date: 2147483647 [INT],
- },
- },
- ],
- date: 1583121389 [INT],
- seq: 0 [INT],
- },
- },
- }
复制代码 |
|