Skip to content

Commit

Permalink
fix: printChat
Browse files Browse the repository at this point in the history
修复不能正常打印群信息的问题
修正case/grade失配的返回值
  • Loading branch information
mystringEmpty committed Feb 21, 2024
1 parent dc7c6cf commit e580f12
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
10 changes: 3 additions & 7 deletions Dice/CharacterCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,9 @@ void CardTemp::after_update(const ptr<AnysTable>& eve) {
}

ptr<CardTemp> CharaCard::getTemplet()const{
thread_local ptr<CardTemp> temp;
if (!temp) {
if (string type{ get_str("__Type") };
!type.empty() && CardModels.count(type))return temp = CardModels[type];
return temp = CardModels["BRP"];
}
return temp;
if (string type{ get_str("__Type") };
!type.empty() && CardModels.count(type))return CardModels[type];
return CardModels["BRP"];
}

void CharaCard::update() {
Expand Down
10 changes: 5 additions & 5 deletions Dice/Dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ EVE_DiscussMsg(eventDiscussMsg)
if (blacklist->get_user_danger(fromUID) && console["AutoClearBlack"])
{
const string strMsg = "发现黑名单用户" + printUser(fromUID) + ",自动执行退群";
console.log(printChat(grp) + strMsg, 0b10, printSTNow());
console.log(grp.print() + strMsg, 0b10, printSTNow());
grp.leave(strMsg);
return 1;
}
Expand Down Expand Up @@ -749,7 +749,7 @@ EVE_GroupMemberKicked(eventGroupMemberKicked){
grp.reset("已入群").rmLst();
if (!console || grp.is("忽略"))return 0;
string strNow = printSTime(stNow);
string strNote = printUser(fromUID) + "" + printUser(beingOperateQQ) + "移出了" + printChat(grp);
string strNote = printUser(fromUID) + "" + printUser(beingOperateQQ) + "移出了" + grp.print();
console.log(strNote, 0b1000, strNow);
if (!console["ListenGroupKick"] || trustedQQ(fromUID) > 1 || grp.is("免黑") || grp.is("协议无效") || ExceptGroups.count(fromGID)) return 0;
AttrObject eve{ AnysTable{{
Expand All @@ -772,7 +772,7 @@ EVE_GroupMemberKicked(eventGroupMemberKicked){
{
if (!console || grp.is("忽略"))return 0;
string strNow = printSTime(stNow);
string strNote = printUser(fromUID) + "" + printUser(beingOperateQQ) + "移出了" + printChat(grp);
string strNote = printUser(fromUID) + "" + printUser(beingOperateQQ) + "移出了" + grp.print();
console.log(strNote, 0b1000, strNow);
if (trustedQQ(fromUID) > 1 || grp.is("免黑") || grp.is("协议无效") || ExceptGroups.count(fromGID)) return 0;
DDBlackMarkFactory mark{fromUID, fromGID};
Expand All @@ -792,15 +792,15 @@ EVE_GroupBan(eventGroupBan)
{
if (beingOperateQQ == console.DiceMaid)
{
console.log(getMsg("self") + "" + printGroup(fromGID) + "中被解除禁言", 0b10, printSTNow());
console.log(getMsg("self") + "" + grp.print() + "中被解除禁言", 0b10, printSTNow());
return 1;
}
}
else
{
string strNow = printSTNow();
long long llOwner = 0;
string strNote = "" + printGroup(fromGID) + "中," + printUser(beingOperateQQ) + "" + printUser(operatorQQ) + "禁言" + duration;
string strNote = "" + grp.print() + "中," + printUser(beingOperateQQ) + "" + printUser(operatorQQ) + "禁言" + duration;
if (!console["ListenGroupBan"] || trustedQQ(operatorQQ) > 1 || grp.is("免黑") || grp.is("协议无效") || ExceptGroups.count(fromGID))
{
console.log(strNote, 0b10, strNow);
Expand Down
3 changes: 3 additions & 0 deletions Dice/DiceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4049,6 +4049,7 @@ int DiceEvent::InnerOrder() {
if (PList[fromChat.uid].count(attr)) {
while (strMsg[intMsgCnt] == ':')++intMsgCnt;
pc = pl[attr];
set("char", pc);
set("pc", pc->getName());
attr = readAttrName();
}
Expand All @@ -4061,6 +4062,7 @@ int DiceEvent::InnerOrder() {
string strGenitive = attr.substr(0, pos);
if (pl.count(strGenitive)) {
pc = pl[strGenitive];
set("char", pc);
set("pc", pc->getName());
attr = attr.substr(pos + 2);
}
Expand Down Expand Up @@ -4111,6 +4113,7 @@ int DiceEvent::InnerOrder() {
}
}
pc = pl[name];
set("char", pc);
set("pc", name);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Dice/DiceFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class MarkCaseNode : public MarkNode {
if (auto i{ cases.find(res.print()) }; i != cases.end()) {
return i->second->concat(context, isTrust, global);
}
return other ? other->concat(context, isTrust, global) : leaf;
return other ? other->concat(context, isTrust, global) : AttrVar();
}
};
class MarkGradeNode : public MarkNode {
Expand All @@ -189,7 +189,7 @@ class MarkGradeNode : public MarkNode {
}
else if (auto grade{ grades.get_else() })
return grade->concat(context, isTrust, global);
return leaf;
return AttrVar();
}
};
class MarkJSNode : public MarkNode {
Expand Down
6 changes: 3 additions & 3 deletions Dice/DiceJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ void clear_group(AttrObject& job) {
}
else if (authSelf.less(authBlack)) {
if (grp.updated() < grpline)GrpDelete.push_back(id);
res << printChat(grp) + "" + printUser(eachQQ) + "对方群权限较高";
res << grp.print() + "" + printUser(eachQQ) + "对方群权限较高";
grp.leave("发现黑名单管理员" + printUser(eachQQ) + "\n" + getMsg("strSelfName") + "将预防性退群");
intCnt++;
break;
}
else if (console["GroupClearLimit"] > 0 && intCnt >= console["GroupClearLimit"]) {
if(intCnt == console["GroupClearLimit"])res << "*单次清退已达上限*";
res << printChat(grp) + "" + printUser(eachQQ);
res << grp.print() + "" + printUser(eachQQ);
}
else if (console["LeaveBlackQQ"]) {
if (grp.updated() < grpline)GrpDelete.push_back(id);
res << printChat(grp) + "" + printUser(eachQQ);
res << grp.print() + "" + printUser(eachQQ);
grp.leave("发现黑名单成员" + printUser(eachQQ) + "\n" + getMsg("strSelfName") + "将预防性退群");
intCnt++;
break;
Expand Down
6 changes: 3 additions & 3 deletions Dice/GlobalVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ const dict_ci<> HelpDoc = {
.pc stat //�鿴��ǰ��ɫ������ͳ��
.pc redo ([���ɲ���]:)(����) //���ԭ�����Ժ���������
.pc clr //����ȫ����ɫ����¼
//����ͳ���Խ�ɫ��Ϊ��λ��ÿ���û�����ͬʱ����16�Ž�ɫ��
//����ͳ���Խ�ɫ��Ϊ��λ��ÿ���û�����ͬʱ����32�Ž�ɫ��
)"
},
{"rc", "&rc/ra"},
Expand Down Expand Up @@ -879,8 +879,8 @@ const dict_ci<> HelpDoc = {
R"(Ⱥ��ָ��.group(Ⱥ����Ա�޶�)
.group state //�鿴��Ⱥ�ڶ����������
.group pause/restart //Ⱥȫ�����/ȫ��������
.group card [at/�û�QQ] [��Ƭ] //����ȺԱ��Ƭ
.group title [at/�û�QQ] [ͷ��] //����ȺԱͷ��
.group card [at/�û�ID] [��Ƭ] //����ȺԱ��Ƭ
.group title [at/�û�ID] [ͷ��] //����ȺԱͷ��
.group diver //�鿴DZˮ��Ա
.group +/-[Ⱥ�ܴ���] //ΪȺ�Ӽ����ã���Ҫ��ӦȨ��
��:.group +���ûظ� //�رձ�Ⱥ�Զ���ظ�
Expand Down
5 changes: 2 additions & 3 deletions Dice/GlobalVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Dice! QQ Dice Robot for TRPG
* Copyright (C) 2018-2021 w4123���
* Copyright (C) 2019-2023 String.Empty
* Copyright (C) 2019-2024 String.Empty
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation,
Expand All @@ -30,7 +30,6 @@
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif
#include <map>
#include "STLExtern.hpp"
#include "DiceExtensionManager.h"
#include "DiceAttrVar.h"
Expand All @@ -40,7 +39,7 @@
* �����޸�Dice_Build, Dice_Ver_Without_Build��DiceRequestHeader�Լ�Dice_Ver����
* ���޸�Dice_Short_Ver��Dice_Full_Ver�����Դﵽ�汾�Զ���
*/
constexpr unsigned short Dice_Build = 656u;
constexpr unsigned short Dice_Build = 657u;
inline const std::string Dice_Ver_Without_Build = "2.7.0beta7";
constexpr auto DiceRequestHeader = "Dice/2.7.0";
inline const std::string Dice_Ver = Dice_Ver_Without_Build + "(" + std::to_string(Dice_Build) + ")";
Expand Down

0 comments on commit e580f12

Please sign in to comment.