cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
QuoteMessage.hpp
浏览该文件的文档.
1// Copyright (C) 2022 Numendacil and contributors
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Affero General Public License as
5// published by the Free Software Foundation, either version 3 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef MIRAI_QUOTE_MESSAGE_HPP_
17#define MIRAI_QUOTE_MESSAGE_HPP_
18
19#include <memory>
20#include <string>
21
23
24#include "IMessage.hpp"
25
26namespace Mirai
27{
28
29class MessageChain;
30
31/**
32 * @brief 引用回复消息
33 *
34 * 仅用于接收,发送时将会被无视。发送引用回复消息请在消息发送函数中设置 `QuoteId`
35 *
36 * Member Variable | Default Value
37 * --------------- | -------------
38 * `QuoteMessage::QuoteId_` | `-1`
39 * `QuoteMessage::GroupId_` | `0_gid`
40 * `QuoteMessage::SenderId_` | `0_qq`
41 * `QuoteMessage::TargetId_` | `0`
42 * `QuoteMessage::origin_` | `MessageChain{}`
43 */
44class QuoteMessage final : public IMessageImpl<QuoteMessage>
45{
47
48protected:
52 int64_t TargetId_ = 0;
53 std::unique_ptr<MessageChain> origin_{};
54
56 static constexpr bool SUPPORT_SEND_ = false;
57
58 bool isValid_() const final { return true; }
59
60public:
66
67 /// 获取被引用消息id
68 MessageId_t GetQuoteId() const { return this->QuoteId_; }
69 /// 获取被引用消息所在群聊id,若为好友消息则为 `0`
70 GID_t GetGroupId() const { return this->GroupId_; }
71 /// 获取引用消息的发送者QQ
72 QQ_t GetSenderId() const { return this->SenderId_; }
73 /// 获取引用消息的接收者QQ,仅当好友消息时有效
75 {
76 if (this->GroupId_ == (GID_t)0) return QQ_t(this->TargetId_);
77 else
78 return QQ_t(0);
79 }
80 /// 获取被引用消息
82
83 struct Serializable;
84};
85
86template<> struct GetType<QuoteMessage::GetType()>
87{
89};
90
91} // namespace Mirai
92
93
94#endif
群聊号码类型
Definition: BasicTypes.hpp:88
CRTP helper layer
Definition: IMessage.hpp:78
消息链对象,由一系列消息元素组成
QQ号码类型
Definition: BasicTypes.hpp:71
引用回复消息
bool isValid_() const final
MessageId_t QuoteId_
GID_t GetGroupId() const
获取被引用消息所在群聊id,若为好友消息则为 0
static constexpr bool SUPPORT_SEND_
QQ_t GetTargetId() const
获取引用消息的接收者QQ,仅当好友消息时有效
QuoteMessage(QuoteMessage &&)
MessageChain GetOriginMessage() const
获取被引用消息
QQ_t GetSenderId() const
获取引用消息的发送者QQ
QuoteMessage & operator=(QuoteMessage &&)
MessageId_t GetQuoteId() const
获取被引用消息id
std::unique_ptr< MessageChain > origin_
static constexpr MessageTypes TYPE_
QuoteMessage & operator=(const QuoteMessage &)
所有mirai相关的对象的命名空间
int64_t MessageId_t
消息id类型,用于撤回消息和引用消息
Definition: BasicTypes.hpp:35
用于类型之间转换的辅助模板