cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
SourceMessage.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_SOURCE_MESSAGE_HPP_
17#define MIRAI_SOURCE_MESSAGE_HPP_
18
19#include <ctime>
20#include <string>
21
23
24#include "IMessage.hpp"
25
26namespace Mirai
27{
28
29/**
30 * @brief 来源消息
31 *
32 * 用于标识消息的发送时间与id,仅可用于接收。
33 *
34 * Member Variable | Default Value
35 * --------------- | -------------
36 * `SourceMessage::id_` | `-1`
37 * `SourceMessage::timestamp_` | `0`
38 */
39class SourceMessage final : public IMessageImpl<SourceMessage>
40{
42
43protected:
45 std::time_t timestamp_ = 0;
46
48 static constexpr bool SUPPORT_SEND_ = false;
49
50 bool isValid_() const final { return true; }
51
52public:
53 SourceMessage() = default;
54
55 /// 获取消息id
56 MessageId_t GetMessageId() const { return this->id_; }
57 /// 获取消息时间戳
58 std::time_t GetTimestamp() const { return this->timestamp_; }
59
60 struct Serializable;
61};
62
63template<> struct GetType<SourceMessage::GetType()>
64{
66};
67
68} // namespace Mirai
69
70
71#endif
CRTP helper layer
Definition: IMessage.hpp:78
std::time_t GetTimestamp() const
获取消息时间戳
static constexpr bool SUPPORT_SEND_
bool isValid_() const final
static constexpr MessageTypes TYPE_
MessageId_t GetMessageId() const
获取消息id
所有mirai相关的对象的命名空间
int64_t MessageId_t
消息id类型,用于撤回消息和引用消息
Definition: BasicTypes.hpp:35
用于类型之间转换的辅助模板