Skip to content

Commit ed104a0

Browse files
authored
Merge pull request #39 from TMBotDev/beta
Release v1.1.1
2 parents a91cc14 + f4cdb3f commit ed104a0

23 files changed

+145
-140
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.gitee
2-
.vscode
2+
# .vscode
33
build
44
node_modules
55
plugins/*

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cSpell.words": [
3+
"apng",
4+
"changesource",
5+
"KHTML",
6+
"Uncompress"
7+
]
8+
}

.vscode/tasks.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "typescript",
6+
"tsconfig": "tsconfigDebug.json",
7+
"option": "watch",
8+
"problemMatcher": [
9+
"$tsc-watch"
10+
],
11+
"group": "build",
12+
"label": "tsc: 监视 - tsconfigDebug.json"
13+
},
14+
{
15+
"type": "typescript",
16+
"tsconfig": "tsconfig.json",
17+
"option": "watch",
18+
"problemMatcher": [
19+
"$tsc-watch"
20+
],
21+
"group": "build",
22+
"label": "tsc: 监视 - tsconfig.json"
23+
}
24+
]
25+
}

Release-Description.md

+13-50
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,26 @@
11
# TMBot Release Note
22

3-
#### Version v1.0.9
3+
#### Version v1.1.1
44

55
## 更新描述:
66

7-
[添加,添加,添加,完善](https://github.com/TMBotDev/TMBot/commit/3ca2bf3fb158a66c81492602fe8e3ebec8b87bc5)
8-
1.添加ForwardMessageInfo类
9-
2.为OneBotDocking添加sendGroupForwardMsg, sendPrivateForwardMsg, getForwardMsgEx, sendGroupForwardMsgEx, sendPrivateForwardMsgEx 属性
10-
3.为SenderInfo类添加属性 _isGroupMember, _isGuildMember
11-
4.完善ForwardNode类
12-
5.完善MsgInfoBuilder类
7+
[修复无法分辨服务器连接成功出自哪个配置的问题](https://github.com/TMBotDev/TMBot/commit/86244f4059e836e7db2477eec1fc2284920e2287)
138

9+
[修改命令系统overload机制为抛出错误](https://github.com/TMBotDev/TMBot/commit/96a1a458db3f31f8f75b630759d6a6d1c0316661)
1410

15-
[修改,添加](https://github.com/TMBotDev/TMBot/commit/aab6c41dba9a00f63e8d49d6ab2631ebb12a7f9c)
16-
1.添加一些注释
17-
2.修改Event类为TEvent类(防止冲突)
18-
3.为GuildSystem增加一个新文件
19-
4.添加一些方便函数
20-
5.将GuildSender改为GuildSenderInfo(看着舒服)
21-
6.添加类ReactionInfo(s)
11+
[修复FileClass.getFilesList无法获取问题](https://github.com/TMBotDev/TMBot/commit/c4d70a67ba961ae443ea5650f4a6c430a828ffbe)
2212

23-
[添加&完善&修改&修复](https://github.com/TMBotDev/TMBot/commit/2fe1853aa77820d827aa55b4534ad3c49fdb3459)
24-
1.添加tools/leveldb.ts,数据库
25-
2.完善GuildSystem监听机制
26-
3.修改ChannelInfo为GuildChannelInfo
27-
4.修复在部分node环境中app会运行两次&添加Global.ts放入全局变量监听
28-
5.添加MessageDB
29-
(修复部分OneBot标准的服务器没有get_msg API导致的部分功能无法运行以及GuildSystem没有get_msg API导致的一些问题)
13+
[重新进行分类](https://github.com/TMBotDev/TMBot/commit/ba0b841fd0e34061141082d6219f899411e329c6)
3014

31-
[完善成员缓存系统](https://github.com/TMBotDev/TMBot/commit/53a7cb1225e863517b069dfe709086b139b037eb)
15+
[更新依赖包](https://github.com/TMBotDev/TMBot/commit/9c0158373d9672b8a762db160784ecc19f314793)
3216

33-
[添加发送请求错误打印机制](https://github.com/TMBotDev/TMBot/commit/cd2f5f612e8dbb1b7542cb13814867e7e096b6d7)
34-
更改:OneBotDocking._SendReqPro
35-
返回类型改为TMBotPromise(详情见源码)
17+
[1.1.0-修复未捕获错误分析失败导致TMBot崩溃&删除TEvent Debug信息](https://github.com/TMBotDev/TMBot/commit/d6c96ff843f1934a12d345a48aa17d238b8db62b)
3618

37-
[完善错报错机制&添加一些类toString方法](https://github.com/TMBotDev/TMBot/commit/557312fe5551589cac2b7da56cbf5d5efb8593f0)
38-
1.添加TEvent的打印错误插件名称的功能
39-
2.添加未捕获异常打印错误插件名称的功能
40-
3.添加QQChannelTypes文件夹里类的toString方法
19+
[优化JsonConfigFileClass性能](https://github.com/TMBotDev/TMBot/commit/ab59f05bbe0c1c3dde2e6374bccf778d9d06383d)
4120

42-
[完善&添加&优化](https://github.com/TMBotDev/TMBot/commit/1f16efac69fb285c78ec7d5bf0620cd2064eee6f)
43-
1.完善命令系统(namespace TMBotCmd)
44-
2.添加一些TMBot命令系统的基本命令
45-
3.添加TMBotCmd.HelpCmdHelper(class)
46-
4.优化掉一些沉余导入项
47-
5.优化LevelDB在有打开数据库的情况下再关闭才输出全部关闭完成
48-
49-
[修复&修改](https://github.com/TMBotDev/TMBot/commit/f02026898cd8be8b19dd8fdf0e9147c407f222e0)
50-
修复LevelDB类在nodejs环境可能会报数据库未开启
51-
修改LevelDB.getKeyIterator为异步方法
52-
53-
[添加debug模式(断点调试)&更新错误处理](https://github.com/TMBotDev/TMBot/commit/223eef2f6ec88b586226d4e53ba562b34814dca3)
54-
55-
[修复level包不安装的bug&移除部分无用的包&修复一个未定义变量bug](https://github.com/TMBotDev/TMBot/commit/ed5457046aa11ae75a51162c3412dc770d1f4805)
56-
57-
骗过ts编译器不提示缺失类
58-
[1](https://github.com/TMBotDev/TMBot/commit/5de47cd9215c0c7aaf92d35b294aa7b2ab3c2706)[2](https://github.com/TMBotDev/TMBot/commit/a498f5a5900136ad5ff1abca3a6b32454737ee94)[3](https://github.com/TMBotDev/TMBot/commit/90c7cc726abe2e5d805cdbd74e86e7eeb6d6c01d)[4](https://github.com/TMBotDev/TMBot/commit/c65304a484fc84cda30d7c813c752d81790da327)
59-
60-
[修改初始化输出,添加无颜色模式](https://github.com/TMBotDev/TMBot/commit/8a9e5e2c1751e11a155f4e62681eba5f9f7fb4b4)
61-
1.修改一些初始化的输出格式
62-
2.添加无颜色模式(在TMBot根目录添加NO_COLOR文件)
21+
[更新vsc生成任务](https://github.com/TMBotDev/TMBot/commit/143e637c5e56ee755fe4c750bf999ea9b0f3e896)
6322

23+
[添加&修改&修复](https://github.com/TMBotDev/TMBot/commit/11553ead499912d48e9f38a8cef1bbec80b344de)
24+
1.添加启动无色模式的启动参数"NO_COLOR"
25+
2.修改加载插件的一些问题
26+
3.修复FileClass.getStandardPath()的反斜杠问题

app.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// import { sleep } from "deasync";
2-
import { GlobalVar } from "./modules/Global";
2+
import { GlobalEvent, GlobalVar } from "./modules/RunTime/Global";
33
import { BotDockingMgr } from "./modules/BotDockingMgr";
4-
import { ErrorPrint } from "./modules/ErrorPrint";
4+
import { ErrorPrint } from "./modules/RunTime/ErrorPrint";
55
import { PluginPackage } from "./modules/PluginLoader";
66
import { JsonConfigFileClass } from "./tools/data";
77
// import { LevelDB } from "./tools/leveldb";
88
import { Logger } from "./tools/logger";
99
import { onReadLineInit } from "./modules/ReadLine";
10-
import { OffsetException } from "./modules/OffsetException";
10+
import { OffsetException } from "./modules/RunTime/OffsetException";
1111
import { FileClass } from "./tools/file";
1212

1313
let Logo = String.raw`
@@ -21,8 +21,8 @@ let Logo = String.raw`
2121

2222
let MainLogger = new Logger("TMBot");
2323
let Version = {
24-
"version": [1, 0, 9] as [number, number, number],
25-
"isBeta": false,
24+
"version": [1, 1, 1] as [number, number, number],
25+
"isBeta": true,
2626
"isDebug": false
2727
};
2828
let TMBotConfig = new JsonConfigFileClass("./config/config.json", JSON.stringify({
@@ -42,14 +42,18 @@ GlobalVar.Version = Version;
4242
GlobalVar.MainLogger = MainLogger;
4343
GlobalVar.TMBotConfig = TMBotConfig;
4444

45-
4645
process.on("uncaughtException", (err, _ori) => {
4746
MainLogger.error(`程序出现未捕获的异常:`);
4847
if (!(err instanceof Error)) {
4948
MainLogger.error("未知异常消息: ", err);
5049
return;
5150
}
52-
MainLogger.error(`Stack: ${err.stack}`);
51+
MainLogger.error(`Stack: ${err.toString()}`);
52+
if (err.toString().split("\n").length < 2) {
53+
MainLogger.fatal(`没有找到错误地点!`);
54+
// GlobalVar.TMBotStop();
55+
return;
56+
}
5357
let off = (!(err instanceof OffsetException)) ? 0 : err.offsetLine;
5458
let res = GlobalVar.getPluginName(GlobalVar.getErrorFile(err, off));
5559
if (res.isPlugin) {
@@ -100,7 +104,7 @@ async function load() {
100104
MainLogger.warn(str);
101105
return;
102106
}
103-
if (FileClass.exists("./NO_COLOR")) {
107+
if (FileClass.exists("./NO_COLOR") || process.argv.indexOf("-NO_COLOR") != -1) {
104108
GlobalVar.LogColor.setLogColor(false);
105109
MainLogger.info("无颜色模式...");
106110
}
@@ -157,6 +161,7 @@ async function load() {
157161
});
158162
allPromise.length != 0 && MainLogger.info(`§d--------初始化信息--------`);
159163
await Promise.all(allPromise);
164+
GlobalEvent.onTMBotInitd.fire("TMBotProcess_Event_TMBotInitd", null);
160165
MainLogger.info(`TMBot加载完成! (${((Date.now() - startTime) / 1000).toFixed(2)}s),输入"help"可查看命令列表`);
161166
}
162167

modules/BotDockingMgr.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { OneBotDocking } from "./OneBotDocking";
2-
import { WebsocketClient } from "./WebSocket";
2+
import { WebsocketClient } from "./RunTime/WebSocket";
33

44
// import { sleep } from "deasync";
55

@@ -18,6 +18,7 @@ export class BotDockingMgr {
1818
let lock = true;
1919
let res = false;
2020
wsc.events.onStart.on(() => {
21+
logger.info(`服务器连接成功!`);
2122
reConnectC = 0;
2223
isFirst = false; lock = false; res = true;
2324
});

modules/CommandSystem.ts renamed to modules/CmdSystem/CommandSystem.ts

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Logger } from "../tools/logger";
2-
import { OffsetException } from "./OffsetException";
3-
import { TEvent } from "./TEvent";
1+
import { Logger } from "../../tools/logger";
2+
import { OffsetException } from "../RunTime/OffsetException";
3+
import { TEvent } from "../RunTime/TEvent";
44

55
let logger = new Logger("CommandSystem");
66

77
export namespace TMBotCmd {
8+
let ACCEPT_SYMBOL = Symbol(Math.floor(Math.random() * 1000));
89
export namespace CommandParams {
910
/**
1011
* 父
@@ -65,6 +66,7 @@ export namespace TMBotCmd {
6566
super();
6667
}
6768
_paramIsThis(str: string) {
69+
if (typeof (str) != "string") { return false; }
6870
this.content = str;
6971
return true;
7072
}
@@ -115,6 +117,7 @@ export namespace TMBotCmd {
115117
private rawText: string | undefined;
116118
constructor(public name: string) { super(); }
117119
_paramIsThis(_str: string, oriRes: string[], index: number) {
120+
if (typeof (_str) != "string") { return false; }
118121
this.rawText = oriRes.slice(index).join(" ");
119122
return true;
120123
}
@@ -302,7 +305,7 @@ export namespace TMBotCmd {
302305
* @param perm 运行所需权限
303306
*/
304307
newCommand(cmd: string, description: string, perm: RunCmdNeedPerm) {
305-
let obj = new this.cmdClass(cmd, description, perm, this);
308+
let obj = new this.cmdClass(cmd, description, perm, this, ACCEPT_SYMBOL);
306309
return obj;
307310
}
308311

@@ -386,9 +389,9 @@ export namespace TMBotCmd {
386389
}
387390

388391
/**
389-
* 单个命令
392+
* 单个命令,只作为父类存在
390393
*/
391-
class TMBotCommand<
394+
export class TMBotCommand<
392395
RunCmdNeedPerm extends TMBotCommandPerm<any>,
393396
CmdRunner extends TMBotCommandRunner<RunCmdNeedPerm>,
394397
CmdOutput extends TMBotCommandOutput> {
@@ -432,7 +435,10 @@ export namespace TMBotCmd {
432435
params: CommandParams.Param<unknown>[]
433436
) => void
434437
}[] = [];
435-
constructor(private cmd_: string, private _description: string, private needPerm: RunCmdNeedPerm, private cmdSystem: TMBotCommandSystem<RunCmdNeedPerm, CmdRunner, CmdOutput>) {
438+
constructor(private cmd_: string, private _description: string, private needPerm: RunCmdNeedPerm, private cmdSystem: TMBotCommandSystem<RunCmdNeedPerm, CmdRunner, CmdOutput>, accept_sym: Symbol) {
439+
if (accept_sym != ACCEPT_SYMBOL) {
440+
throw new OffsetException(1, `单个命令无法被直接构建出来`);
441+
}
436442
if (cmd_.indexOf(" ") != -1) {
437443
throw new OffsetException(3, `主命令不得含有空格字符`);
438444
} else if (cmd_ == "") {
@@ -541,13 +547,11 @@ export namespace TMBotCmd {
541547
if (canHasMandatory) {
542548
canHasMandatory = param.isMandatory;
543549
} else if (param.isMandatory) {
544-
logger.warn(`命令: "${this.cmd}" 注册指令重载失败!原因:在非必须参数出现后就不可出现必须参数了!`);
545-
return undefined;
550+
throw new OffsetException(1, `命令: "${this.cmd}" 注册指令重载失败!原因:在非必须参数出现后就不可出现必须参数了!`);
546551
}
547552
if (param instanceof CommandParams.RawText) {
548553
if (!!params[(i + 1)]) {
549-
logger.warn(`命令: "${this.cmd}" 注册指令重载失败!原因:在RawText之后不能有任何参数了!`);
550-
return undefined;
554+
throw new OffsetException(1, `命令: "${this.cmd}" 注册指令重载失败!原因:在RawText之后不能有任何参数了!`);
551555
}
552556
}
553557
i++;
@@ -652,7 +656,7 @@ export namespace TMBotCmd {
652656
this.helpCmd = cmdSystem.newCommand(`help`, `命令帮助`, { "isEligible": () => true } as TMBotCommandPerm<any>);
653657
this.helpCmd.setAlias("?");
654658

655-
this.helpCmd.overload([])!((cmd, _runner, out, _params) => {
659+
this.helpCmd.overload([])((cmd, _runner, out, _params) => {
656660
let arr = MapMap(this.cache)[1];
657661
let content = ([] as string[]).concat(...arr);
658662
let pages = splitArr(content, 7);
@@ -665,7 +669,7 @@ export namespace TMBotCmd {
665669
cmd.RunningCompleted();
666670
});
667671

668-
this.helpCmd.overload([new CommandParams.Number("Page", false)])!((cmd, _runner, out, params) => {
672+
this.helpCmd.overload([new CommandParams.Number("Page", false)])((cmd, _runner, out, params) => {
669673
let arr = MapMap(this.cache)[1];
670674
let content = ([] as string[]).concat(...arr);
671675
let pages = splitArr(content, 7);
@@ -682,7 +686,7 @@ export namespace TMBotCmd {
682686
cmd.RunningCompleted();
683687
});
684688

685-
this.helpCmd.overload([new CommandParams.String("cmd")])!((cmd, _runner, out, params) => {
689+
this.helpCmd.overload([new CommandParams.String("cmd")])((cmd, _runner, out, params) => {
686690
let nowSelCmd = params[0].value!;
687691
let res = this.list.get(nowSelCmd);
688692
if (!res) {

modules/GuildSystem.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorPrint } from "./ErrorPrint";
1+
import { ErrorPrint } from "./RunTime/ErrorPrint";
22
import { OneBotDocking, TMBotPromise, obj, ret_data_struct } from "./OneBotDocking";
33
import { GuildChannelInfo } from "./QQChannelTypes/GuildChannelInfo";
44
import { GuildInfo } from "./QQChannelTypes/GuildInfo";
@@ -8,7 +8,7 @@ import { GuildMsgInfo, GuildMsgInfoEx } from "./QQChannelTypes/GuildMsgInfo";
88
import { GuildSenderInfo } from "./QQChannelTypes/GuildSenderInfo";
99
import { ReactionInfos } from "./QQChannelTypes/ReactionInfo";
1010
import { MsgInfo, Msg_Info } from "./QQDataTypes/MsgInfo";
11-
import { TEvent } from "./TEvent";
11+
import { TEvent } from "./RunTime/TEvent";
1212

1313

1414
function SafeGetGuild(this: GuildSystem, guild_id: string) {

modules/OneBotDocking.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from "path";
22
import { Logger } from "../tools/logger";
3-
import { WebsocketClient } from "./WebSocket";
4-
import { TEvent } from "./TEvent";
3+
import { WebsocketClient } from "./RunTime/WebSocket";
4+
import { TEvent } from "./RunTime/TEvent";
55
import { AnonymousInfo } from "./QQDataTypes/AnonymousInfo";
66
import { DeviceInfo } from "./QQDataTypes/DeviceInfo";
77
import { FileInfo } from "./QQDataTypes/FileInfo";
@@ -14,11 +14,11 @@ import { ForwardNodeData, MsgInfo, MsgInfoEx, Msg_Info } from "./QQDataTypes/Msg
1414
import { OfflineFileInfo } from "./QQDataTypes/OfflineFileInfo";
1515
import { SenderInfo } from "./QQDataTypes/SenderInfo";
1616
import { StrangerInfo } from "./QQDataTypes/StrangerInfo";
17-
import { ErrorPrint } from "./ErrorPrint";
17+
import { ErrorPrint } from "./RunTime/ErrorPrint";
1818
import { ForwardMessageInfo, ForwardMsgs } from "./QQDataTypes/ForwardMessageInfo";
1919
import { GuildSystem } from "./GuildSystem";
20-
import { MessageDB } from "./MessageDB";
21-
import { GlobalVar } from "./Global";
20+
import { MessageDB } from "./RunTime/MessageDB";
21+
import { GlobalVar } from "./RunTime/Global";
2222

2323

2424
// let logger = new Logger("Bot", LoggerLevel.Info);

0 commit comments

Comments
 (0)