Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
准备2.7-RC-dev3
Browse files Browse the repository at this point in the history
Former-commit-id: 5be71b7
  • Loading branch information
Nambers committed Aug 2, 2021
1 parent 9f47694 commit 10d0e67
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 106 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
# Change Log

## v2.7-RC-dev2
## v2.7-RC-dev3

+ 优化cmake组合方式(所以推荐一并更新全部的Cmake文件)
+ loader增加jline3命令输入框
- 支持运行时登录
- 支持调用onDisable退出
+ loader支持md5作为密码(32位md5 大小写都可以)
+ 更新mirai版本到v2.7-RC-dev1 修复管理员识别问题
+ 支持群公告操作
+ 支持上下文
+ 添加ServiceMessage支持(UrlSharer)
+ 修复一些MiraiCode的小问题
+ 修复Mirai端取消mute(0)导致的不能unMute

> 该版本为预览版的开发版(,包含一些可能出现问题的特性
## v2.7-RC-dev2 [deleted and merge into dev3]

+ 修复Mirai端取消mute(0)导致的不能unMute
+ 修复loader一开始启动没有颜色

> 该版本为v2.7-RC-dev的补丁
## v2.7-RC-dev
## v2.7-RC-dev [deleted and merge into dev3]

+ 优化cmake组合方式(所以推荐一并更新全部的Cmake文件)
+ loader增加jline3命令输入框
Expand Down
126 changes: 59 additions & 67 deletions cpp/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Main:public CPPPlugin {
});
// 消息事件
// 监听私聊
Event::NodeHandle handle = procession->registerEvent<PrivateMessageEvent>([](PrivateMessageEvent e) {
procession->registerEvent<PrivateMessageEvent>([](PrivateMessageEvent e) {
unsigned long long id = e.bot.id;
e.botlogger.info(std::to_string(id));
e.message.source.quoteAndSendMsg("HI");
Expand All @@ -87,72 +87,64 @@ class Main:public CPPPlugin {

// 监听群信息
procession->registerEvent<GroupMessageEvent>([=](GroupMessageEvent e) {
e.sender.mute(60*2);
e.sender.mute(0);
// if(!e.group.announcements.empty())
// logger->info(e.group.announcements[0].content);
// e.group.sendMsg(e.message.content.filter(MiraiCP::MiraiCode::at));
// Group::OfflineAnnouncement("Helloooooooo!", Group::AnnouncementParams()).publishTo(e.group).deleteThis();
// logger->info(e.group.setting.entranceAnnouncement);
// logger->info("Global");
// Main::pluginLogger->Info("Plugin");
// e.botlogger.Info("bot");
// e.botlogger.Info(e.message.content.toString());
// e.group.sendMiraiCode(MiraiCode("[mirai:service:1,<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n<msg templateID=\"12345\" action=\"web\" brief=\"简介 没点进来看见的样子\" serviceID=\"1\" url=\"https://github.com/\"><item layout=\"2\"><picture cover=\"https://avatars.githubusercontent.com/u/35139537?s=400&u=c7e3794d25a2e0f27f15caf5ba7a57c7346962f0&v=4\"/><title>标题</title><summary>描述文字</summary></item><source/></msg>\\n]"));
// e.group.sendMiraiCode(MiraiCode(new ServiceMessage(URLSharer())));
// if(e.message.content.toString() == "a"){
// if(!e.getContext().content.contains("count"))
// e.getContext().content["count"] = 1;
// else
// e.getContext().content["count"] = e.getContext().content["count"] + 1;
// }
// if(e.getContext().content.contains("count"))
// e.group.sendMsg(e.getContext().content["count"].get<int>());
// e.group.sendVoice(R"(D:\下载缓存\test.amr)");
// e.botlogger.Info(e.message);
// e.group.sendMiraiCode(e.message);
// e.group.sendMsg("☺");
// e.group.sendMsg(e.group.setting.name);
// e.group.setting.name = "x";
// e.group.updateSetting();
// e.messageSource.quoteAndSendMsg("HI");
// e.botlogger.Info(e.messageSource.serializeToString());
// // 发送文本信息
// e.group.sendMsg("HI");
// // 发送MiraiCode信息,At
// e.group.sendMiraiCode(At(e.sender));
// // 撤回测试
// e.group.sendMsg("撤回测试").recall();
// // 发送xml卡片测试,可以用new传miraicodeable指针进去,也可以用.toMiraiCode()
// e.group.sendMiraiCode(new LightApp(LightAppStyle1()));
// e.group.sendMiraiCode(LightApp(LightAppStyle2()).toMiraiCode());
// e.group.sendMiraiCode(new LightApp(LightAppStyle3()));
// ForwardMessage(&e.group,
// {
// ForwardNode(1930893235, "Eritque arcus", "hahaha", 1),
// ForwardNode(1930893235, "Eritque arcus", "hahaha", -100)
// }).sendTo(&e.group);
// // 关闭上面的私聊消息监听器
// handle.stop();
// // 当前bot属性
// e.sender.sendMsg(e.bot.nick());
// e.sender.sendMsg(e.bot.FriendListToString());
// e.sender.sendMsg(e.bot.GroupListToString());
// RemoteFile tmp = e.group.sendFile("/test.txt", "D:\\ValveUnhandledExceptionFilter.txt");
// e.group.sendMsg(e.group.getFile("/", tmp.id).name);
// e.group.sendMsg(e.group.getFile("/test.txt").name);
// e.group.sendMsg(e.group.getFileListString("/"));
// std::vector<Group::file_short_info> a = e.group.getFileList("/");
// std::stringstream ss;
// for (size_t i = 0; i < a.size(); ++i) {
// if (i != 0)
// ss << ",";
// ss << "{" << a[i].path << "," << a[i].id << "}";
// }
// std::string s = ss.str();
// e.group.sendMsg(s);
// e.group.sendMsg(e.group.MemberListToString());
// e.messageSource.recall();
e.group.sendMsg("--开始测试--");
e.group.sendMsg(e.sender.at() + "发送纯文本MiraiCode");
e.group.sendMiraiCode(e.sender.at() + "发送MiraiCode");
e.group.sendMsg("禁言测试");
try{
e.sender.mute(60*2);
e.sender.mute(0);
}catch(BotException& b){e.group.sendMsg("权限不足");}
if(!e.group.announcements.empty())
e.group.sendMsg("第一个群公告内容: " + e.group.announcements[0].content);
e.group.sendMsg("消息中全部at对象: ");
try{
e.group.sendMsg(e.message.content.filter(MiraiCP::MiraiCode::at));
}catch(IllegalArgumentException& i){}
e.group.sendMsg("发送一个群公告并删除");
Group::OfflineAnnouncement("Helloooooooo!", Group::AnnouncementParams()).publishTo(e.group).deleteThis();
logger->info("Global全局日志");
Main::pluginLogger->info("Plugin插件日志");
e.botlogger.info("bot机器人日志");
e.botlogger.info("上一条信息:"+e.message.content.toString());
e.botlogger.info("上一条信息:"+e.message.content.toMiraiCode());
e.group.sendMiraiCode(MiraiCode("[mirai:service:1,<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n<msg templateID=\"12345\" action=\"web\" brief=\"简介 没点进来看见的样子\" serviceID=\"1\" url=\"https://github.com/\"><item layout=\"2\"><picture cover=\"https://avatars.githubusercontent.com/u/35139537?s=400&u=c7e3794d25a2e0f27f15caf5ba7a57c7346962f0&v=4\"/><title>标题</title><summary>描述文字</summary></item><source/></msg>\\n]"));
e.group.sendMiraiCode(MiraiCode(new ServiceMessage(URLSharer())));
e.group.sendMsg("上下文测试,在每接收一个'a'就加1");
if(e.message.content.toString() == "a"){
if(!e.getContext().content.contains("count"))
e.getContext().content["count"] = 1;
else
e.getContext().content["count"] = e.getContext().content["count"].get<int>() + 1;
}
if(e.getContext().content.contains("count"))
e.group.sendMsg(e.getContext().content["count"].get<int>());
e.group.sendMsg("发送语音测试:");
e.group.sendVoice(R"(D:\下载缓存\test.amr)");
e.group.sendMsg("UTF8 emoji测试: ☺");
e.group.sendMsg("群名称,并改名为'x':"+e.group.setting.name);
e.group.setting.name = "x";
try{
e.group.updateSetting();
}catch(BotException& b){e.group.sendMsg("没有权限");}
e.message.source.quoteAndSendMsg("引用测试");
e.botlogger.info("messageSource: "+e.message.source.serializeToString());
e.group.sendMsg("撤回测试:");
e.group.sendMsg("撤回测试").recall();
e.group.sendMsg("发送卡片:");
e.group.sendMiraiCode(new LightApp(LightAppStyle1()));
e.group.sendMiraiCode(LightApp(LightAppStyle2()).toMiraiCode());
e.group.sendMiraiCode(new LightApp(LightAppStyle3()));
e.group.sendMsg("转发测试:");
ForwardMessage(&e.group,
{
ForwardNode(1930893235, "Eritque arcus", "hahaha", 1),
ForwardNode(1930893235, "Eritque arcus", "hahaha", -100)
}).sendTo(&e.group);
e.group.sendMsg("bot属性");
e.sender.sendMsg(e.bot.nick());
e.sender.sendMsg(e.bot.FriendListToString());
e.sender.sendMsg(e.bot.GroupListToString());
});
// 监听群临时会话
procession->registerEvent<GroupTempMessageEvent>([](GroupTempMessageEvent e) {
Expand Down
64 changes: 32 additions & 32 deletions cpp/include/miraiCP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace MiraiCP {
using json = nlohmann::json;
// 开始声明MiraiCP常量声明代码
/// MiraiCP当前版本
const std::string MiraiCPVersion = "v2.7-RC-dev2";
const std::string MiraiCPVersion = "v2.7-RC-dev3";

/// @brief 插件信息
class PluginConfig{
Expand Down Expand Up @@ -389,9 +389,6 @@ LightApp风格1
class MiraiCode:MiraiCodeable {
private:
std::string content;
MiraiCode(std::string a, std::string){
content = std::move(a);
}
public:
/// 输出当前内容, 会自动转码
std::string toString() {
Expand All @@ -407,16 +404,21 @@ LightApp风格1
MiraiCode(MiraiCodeable *a) {
content = a->toMiraiCode();
}
/// 从文本初始化一个miraicode字符串
MiraiCode(std::string a) {
content = Tools::escapeToMiraiCode(std::move(a));
}

template<Number T>
MiraiCode (T n){
content = std::to_string(n);
}

/// 从文本初始化一个miraicode字符串, 根据第二个参数决定是否转码, 默认不转码
/// @attention 如果是传入文本MiraiCode,请勿转码,转码只是为了[mirai:xxx:<应该转码的部分>], 如果<应该转码>的部分里面含有'[]:,'内容,请调用Tools::escapeToMiraiCode转码
MiraiCode(std::string a, bool convert = false){
if(!convert)
content = a;
else
content = Tools::escapeToMiraiCode(std::move(a));
}

MiraiCode operator+(MiraiCodeable *a) {
return MiraiCode(content + a->toMiraiCode());
}
Expand All @@ -426,31 +428,19 @@ LightApp风格1
}

MiraiCode operator+(MiraiCode a){
return MiraiCode::MiraiCodeWithoutEscape(content + a.content);
return MiraiCode(content + a.content);
}

MiraiCode operator+(MiraiCode* a){
return MiraiCode::MiraiCodeWithoutEscape(content + a->content);
}

MiraiCode operator+=(MiraiCodeable *a) {
return MiraiCode::MiraiCodeWithoutEscape(content + a->toMiraiCode());
}

MiraiCode operator+=(std::string a) {
return MiraiCode( a) + this;
}

MiraiCode operator=(MiraiCodeable *a) {
return MiraiCode::MiraiCodeWithoutEscape(a->toMiraiCode());
return MiraiCode(content + a->content);
}

MiraiCode operator=(std::string a) {
return MiraiCode(std::move(a));
}

MiraiCode plus(MiraiCodeable *a) {
return MiraiCode::MiraiCodeWithoutEscape(content + a->toMiraiCode());
return MiraiCode(content + a->toMiraiCode());
}

MiraiCode plus(std::string a) {
Expand All @@ -459,11 +449,11 @@ LightApp风格1

/// 不执行转义,适用于已经被MiraiCode转义过的字符串
static MiraiCode MiraiCodeWithoutEscape(std::string a){
return MiraiCode(std::move(a), "");
return MiraiCode(std::move(a), false);
}
/// 不执行转义,因为MiraiCodeable的toMiraiCode已经转义过了
static MiraiCode MiraiCodeWithoutEscape(MiraiCodeable* a){
return MiraiCode::MiraiCodeWithoutEscape(a->toMiraiCode());
return MiraiCode(a->toMiraiCode(), false);
}

/// 支持提取的内容
Expand Down Expand Up @@ -1084,8 +1074,10 @@ LightApp风格1
class Contact {
private:
/// 发送纯文本信息
/// @throw IllegalArgumentException
MessageSource sendMsg0(std::string msg, JNIEnv * = manager->getEnv());
/// 发送miraicode
/// @throw IllegalArgumentException
MessageSource sendMiraiCode0(std::string msg, JNIEnv * = manager->getEnv());
protected:
int _type = 0;
Expand Down Expand Up @@ -1188,20 +1180,26 @@ LightApp风格1
/**
* @brief 发送miraicode
* @param msg - MiraiCode类型 - 内容
* @throw IllegalArgumentException
*/
MessageSource sendMiraiCode(MiraiCode msg) {
return sendMiraiCode0(msg.toString());
return sendMiraiCode0(msg.toMiraiCode());
}

/// 发送纯文本信息
/// @throw IllegalArgumentException
MessageSource sendMsg(std::string msg) {
return sendMsg0(msg);
}

/// 发送纯文本信息
/// @throw IllegalArgumentException
MessageSource sendMsg(MiraiCode msg){
return sendMsg0(msg.toMiraiCode());
}

/// 发送纯文本信息
/// @throw IllegalArgumentException
MessageSource sendMsg(std::vector<std::string> msg){
return sendMsg0(Tools::VectorToString(msg));
}
Expand All @@ -1226,6 +1224,7 @@ LightApp风格1
/*!
* @brief 小程序卡片
* @see LightAppStyle1, LightAppStyle2, LightAppStyle3
* @attention 自带的模板不稳定,可能发出现没有效果
* @example 通过常量构建并发送小程序卡片
* @code
* procession->registerEvent([](GroupMessageEvent e) {
Expand Down Expand Up @@ -1349,6 +1348,8 @@ LightApp风格1
}
};

/// xml格式的超文本信息
/// @attention 自带的模板不稳定,可能发出现没有效果
class ServiceMessage : public MiraiCodeable{
private:
std::string content;
Expand Down Expand Up @@ -1770,7 +1771,7 @@ LightApp风格1
/// At一个群成员
MiraiCode at() {
/*返回at这个人的miraicode*/
return MiraiCode("[mirai:at:" + std::to_string(id()) + "]");
return MiraiCode::MiraiCodeWithoutEscape("[mirai:at:" + std::to_string(id()) + "]");
}
};

Expand Down Expand Up @@ -2858,8 +2859,7 @@ throw: InitxException 即找不到对应签名
return "[mirai:image:" + Tools::escapeToMiraiCode(this->id) + "]";
}

MessageSource
MessageSource::quoteAndSendMiraiCode(const std::string &content, unsigned long long groupid, JNIEnv *env) {
MessageSource MessageSource::quoteAndSendMiraiCode(const std::string &content, unsigned long long groupid, JNIEnv *env) {
json obj;
json sign;
obj["messageSource"] = this->serializeToString();
Expand Down Expand Up @@ -2891,11 +2891,11 @@ throw: InitxException 即找不到对应签名
std::string re = LowLevelAPI::send0(std::move(msg), this, true, env);
ErrorHandle(re, "reach a error area, Contact::SendMiraiCode");
return MessageSource::deserializeFromString(re);
}
}

MessageSource Contact::sendMsg0(std::string msg, JNIEnv *env) {
if (msg.empty()) {
logger->error("警告:发送空信息, 位置: Contact::SendMsg");
logger->warning("警告:发送空信息, 位置: Contact::SendMsg");
throw IllegalArgumentException("参数不能为空, 位置: Contact::SendMsg");
}
std::string re = LowLevelAPI::send0(std::move(msg), this, false, env);
Expand Down Expand Up @@ -3334,7 +3334,7 @@ JNIEXPORT jstring JNICALL Java_tech_eritquearcus_miraicp_shared_CPP_1lib_Event
GroupMessageEvent(j["group"]["botid"],
Group::deserializationFromJson(j["group"]),
Member::deserializationFromJson(j["member"]),
MiraiCode(to_string(j["message"])),
MiraiCode(j["message"].get<std::string>()),
MessageSource::deserializeFromString(j["source"])
)
);
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/miraicp/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = MiraiCP
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = v2.7-Beta
PROJECT_NUMBER = v2.7-RC-dev2

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down Expand Up @@ -2583,7 +2583,7 @@ MAX_DOT_GRAPH_DEPTH = 0
# background. This is disabled by default, because dot on Windows does not seem
# to support this out of the box.
#
# warning: Depending on the platform used, enabling this option may lead to
# Warning: Depending on the platform used, enabling this option may lead to
# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
# read).
# The default value is: NO.
Expand Down
2 changes: 1 addition & 1 deletion kotlin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlinVersion = "1.5.10"
miraiVersion = "2.7-RC-dev-1"
miraiCPVersion = "2.7-RC-dev2"
miraiCPVersion = "2.7-RC-dev3"

[libraries]
mirai-core-api = { module = "net.mamoe:mirai-core-api", version.ref = "miraiVersion" }
Expand Down
2 changes: 1 addition & 1 deletion kotlin/plugin/src/main/kotlin/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object PluginMain : KotlinPlugin(
JvmPluginDescription(
id = "tech.eritquearcus.miraiCP",
name = "miraiCP",
version = "2.7-RC-dev2"
version = "2.7-RC-dev3"
){
author("Eritque arcus")
}
Expand Down
Loading

0 comments on commit 10d0e67

Please sign in to comment.