Skip to content

Commit a765da8

Browse files
committed
fix: readUntilTab
清理readUntilTab对GBK编码的特化补丁 rename: strCharacterTooBig->strBuildTooMany
1 parent 024495c commit a765da8

File tree

6 files changed

+29
-35
lines changed

6 files changed

+29
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
# Directories for temporary file
3535
/.vs
36+
/.vscode
3637
/build
3738
/Dice/Release
3839
/Dice/Debug

Dice/DiceAttrVar.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,17 +692,18 @@ bool AttrVar::equal_or_less(const AttrVar& other)const {
692692
void AnysTable::from_json(const fifo_json& j){
693693
if (j.is_object()) {
694694
unordered_set<string> idxs;
695-
if (string strI{ "0" }; j.count(strI)) {
695+
fifo_json tab{j};
696+
if (string strI{ "0" }; tab.count(strI)) {
696697
new_list();
697698
int idx{ 0 };
698699
do {
699-
list->push_back(j[strI]);
700+
list->push_back(tab[strI]);
700701
idxs.insert(strI);
701-
} while (j.count(strI = to_string(++idx)));
702+
tab.erase(strI);
703+
} while (tab.count(strI = to_string(++idx)));
702704
}
703-
for (auto& it : j.items()) {
704-
if (idxs.count(it.key()))continue;
705-
if (!it.value().is_null())set(it.key(), it.value());
705+
for (auto& it : tab.items()) {
706+
if (!idxs.count(it.key()) && !it.value().is_null())set(it.key(), it.value());
706707
}
707708
}
708709
else if (j.is_array()) {

Dice/DiceEvent.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,29 +1204,23 @@ int DiceEvent::BasicOrder()
12041204
}
12051205
trigger->answer = AnysTable(deck);
12061206
}
1207+
else if (trigger->echo == DiceMsgReply::Echo::Text) {
1208+
trigger->answer->set("text", readRest());
1209+
}
12071210
else {
1211+
if (trusted < 5) {
1212+
replyMsg("strNotMaster");
1213+
return -1;
1214+
}
12081215
if (trigger->echo == DiceMsgReply::Echo::Lua) {
1209-
if (trusted < 5) {
1210-
replyMsg("strNotMaster");
1211-
return -1;
1212-
}
12131216
trigger->answer = AttrVars{ {"lua",readRest()} };
12141217
}
12151218
else if (trigger->echo == DiceMsgReply::Echo::JavaScript) {
1216-
if (trusted < 5) {
1217-
replyMsg("strNotMaster");
1218-
return -1;
1219-
}
12201219
trigger->answer = AttrVars{ {"js",readRest()} };
12211220
}
12221221
else if (trigger->echo == DiceMsgReply::Echo::Python) {
1223-
if (trusted < 5) {
1224-
replyMsg("strNotMaster");
1225-
return -1;
1226-
}
12271222
trigger->answer = AttrVars{ {"py",readRest()} };
12281223
}
1229-
else trigger->answer->set("text", readRest());
12301224
}
12311225
break;
12321226
}
@@ -2305,12 +2299,12 @@ int DiceEvent::InnerOrder() {
23052299
}
23062300
string_view strNum{ strMsg.c_str() + nBegin,intMsgCnt - nBegin };
23072301
if (strNum.length() > 2) {
2308-
replyMsg("strCharacterTooBig");
2302+
replyMsg("strBuildTooMany");
23092303
return 1;
23102304
}
23112305
const int intNum = strNum.empty() ? 1 : svtoi(strNum);
23122306
if (intNum > 10) {
2313-
replyMsg("strCharacterTooBig");
2307+
replyMsg("strBuildTooMany");
23142308
return 1;
23152309
}
23162310
if (intNum == 0) {
@@ -2814,7 +2808,7 @@ int DiceEvent::InnerOrder() {
28142808
intMsgCnt++;
28152809
}
28162810
if (strNum.length() > 1 && strNum != "10") {
2817-
replyMsg("strCharacterTooBig");
2811+
replyMsg("strBuildTooMany");
28182812
return 1;
28192813
}
28202814
const int intNum = stoi(strNum.empty() ? "1" : strNum);
@@ -2836,7 +2830,7 @@ int DiceEvent::InnerOrder() {
28362830
intMsgCnt++;
28372831
}
28382832
if (strNum.length() > 1 && strNum != "10") {
2839-
replyMsg("strCharacterTooBig");
2833+
replyMsg("strBuildTooMany");
28402834
return 1;
28412835
}
28422836
const int intNum = stoi(strNum.empty() ? "1" : strNum);

Dice/DiceEvent.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* 消息处理
55
* Copyright (C) 2018-2021 w4123
6-
* Copyright (C) 2019-2024 String.Empty
6+
* Copyright (C) 2019-2025 String.Empty
77
*/
88
#ifndef DICE_EVENT
99
#define DICE_EVENT
@@ -109,8 +109,7 @@ class DiceEvent : public AnysTable {
109109
while (intMsgCnt < len && (!isspace(static_cast<unsigned char>(strMsg[intMsgCnt])) || strMsg[intMsgCnt] == ' '))
110110
{
111111
if (strMsg[intMsgCnt] != ' ' || strMsg[intEnd] != ' ')intEnd = intMsgCnt;
112-
if (intMsgCnt < len && strMsg[intMsgCnt] < 0)intMsgCnt += 2;
113-
else intMsgCnt++;
112+
intMsgCnt++;
114113
}
115114
if (strMsg[intEnd] == ' ')intMsgCnt = intEnd;
116115
return strMsg.substr(intBegin, intMsgCnt - intBegin);

Dice/GlobalVar.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Dice! QQ Dice Robot for TRPG
1010
* Copyright (C) 2018-2021 w4123溯洄
11-
* Copyright (C) 2019-2024 String.Empty
11+
* Copyright (C) 2019-2025 String.Empty
1212
*
1313
* This program is free software: you can redistribute it and/or modify it under the terms
1414
* of the GNU Affero General Public License as published by the Free Software Foundation,
@@ -333,7 +333,7 @@ const dict_ci<string> PlainMsg
333333
{"strSetTooBig", "这面数……让我丢个球啊!请{nick}输入1-9999之间的数字!"},
334334
{"strSetCannotBeZero", "默认骰不能为零!请{nick}输入1-9999之间的数字!"},
335335
{"strCharacterCannotBeZero", "人物作成次数不能为零!请输入1-10之间的数字!"},
336-
{"strCharacterTooBig", "人物作成次数过多!请输入1-10之间的数字!"},
336+
{"strBuildTooMany", "人物作成次数过多!请输入1-10之间的数字!"},
337337
{"strCharacterInvalid", "人物作成次数无效!请输入1-10之间的数字!"},
338338
{"strSanityRoll", "{pc}的San Check:\n{res} {grade:rank?2={strSuccess}&1={strFailure}&0={strFumble}}\n{case:loss?0=无理智损失√&else=理智减少{change}->剩余{final}}" },
339339
{"strSanCostInvalid", "{pc}输入SC表达式不正确,格式为成功扣San/失败扣San,如1/1d6!"},
@@ -379,11 +379,11 @@ const dict_ci<string> PlainMsg
379379
{"strNameSet", "{self}已将{old_nick}改称为{new_nick}√"},
380380
{"strNameDel", "{self}已删除{old_nick}在当前窗口的称呼√" },
381381
{"strNameClr", "{self}已清空{old_nick}的所有称呼√" },
382-
{"strUnknownPropErr", "未设定{attr}成功率,请先.st {attr} 技能值 或查看.help rc×"},
382+
{"strUnknownPropErr", "未设定{attr}成功率,请{pc}先.st {attr} 技能值 或查看.help rc×"},
383383
{"strPropErr", "{pc}的属性录入存在异常,请遵守规范:\n{err}"},
384-
{"strSetPropSuccess", "已为{pc}录入{cnt}条属性√"},
385-
{"strPropCleared", "已清空{char}的所有属性√"},
386-
{"strRuleReset", "已重置默认规则√"},
384+
{"strSetPropSuccess", "{self}已为{pc}录入{cnt}条属性√"},
385+
{"strPropCleared", "{self}已清空{char}的所有属性√"},
386+
{"strRuleReset", "{self}已重置默认规则√"},
387387
{"strRuleSet", "{self}已设置默认规则{rule}√"},
388388
{"strRuleErr", "规则数据获取失败,具体信息:\n"},
389389
{"strRulesFailedErr", "请求失败,{self}无法连接数据库×"},
@@ -451,8 +451,7 @@ const dict_ci<string> PlainMsg
451451
.help群管 查看群管指令
452452
.help设定 确认骰娘设定
453453
.help链接 查看源码文档
454-
官方论坛: https://forum.kokona.tech/
455-
Dice!众筹计划: https://afdian.net/@suhuiw4123)"
454+
官方论坛: https://forum.kokona.tech/)"
456455
}
457456
};
458457
dict_ci<string> GlobalMsg{ PlainMsg };

vcpkg

Submodule vcpkg updated 406 files

0 commit comments

Comments
 (0)