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

Commit

Permalink
增加示例
Browse files Browse the repository at this point in the history
Former-commit-id: 03e1e16
  • Loading branch information
Nambers committed May 1, 2021
1 parent 2186d75 commit c7f041f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 30 additions & 0 deletions cpp/Procession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,48 @@ void onEnable() {
...
参数都在param变量里,在lambda块中使用param.xxx来调用
*/
// 邀请事件
procession->registerEvent([](NewFriendRequestEvent e) {
e.accept();
});
procession->registerEvent([](GroupInviteEvent e) {
e.accept();
});
// 消息事件
procession->registerEvent([](PrivateMessageEvent e) {
std::thread func1(func, e.sender.id);
e.sender.SendMsg(e.message);
std::vector <std::string> temp = Image::GetImgIdsFromMiraiCode(e.message);
func1.detach();
// 线程应该在lambda中决定要detach还是join, 否则会报错
for (std::string a : temp) {
e.sender.SendMsg(a);
}
});
procession->registerEvent([](GroupMessageEvent e) {
e.group.SendMsg("HI");
e.group.SendMiraiCode(At(e.sender));
e.group.SendMsg("撤回测试").recall();
// 可以用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);
});
procession->registerEvent([](GroupTempMessageEvent e) {
e.sender.SendMsg("hi");
});
// 群事件
procession->registerEvent([](MemberJoinEvent e) {
e.group.SendMiraiCode(At(e.group.getOwner()) + std::to_string(e.member.id) + "加入了群聊");
});
procession->registerEvent([](MemberLeaveEvent e) {
e.group.SendMiraiCode(At(e.group.getOwner()) + std::to_string(e.member.id) + "退出了群聊");
});
}
void onDisable() {
/*插件结束,正常退出才会调用*/
Expand Down
1 change: 0 additions & 1 deletion cpp/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ MessageSource Friend::SendMsg(std::string msg, JNIEnv* env){
if (re == "E1") {
throw FriendException();
}
logger->Info("C-Source:\""+re+"\"");
return MessageSource(re);
}

Expand Down

0 comments on commit c7f041f

Please sign in to comment.