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

Commit

Permalink
1.完成了日志系统的改造
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen committed Jul 15, 2019
1 parent 49e352a commit 530baba
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 54 deletions.
26 changes: 14 additions & 12 deletions dist/app/ltd.cmyr.demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const cq_robot_1 = require("cq-robot");
class App extends cq_robot_1.CQApp {
constructor() {
super('ltd.cmyr.demo', __dirname);
this.CQ.setDebug(true);
this.CQ.setDebug(false);
}
debug() {
// console.log('debug()方法只会在debug模式下执行')
Expand Down Expand Up @@ -45,66 +45,68 @@ class App extends cq_robot_1.CQApp {
if (fromQQ === 996881204) {
this.CQ.sendPrivateMsg(fromQQ, `这是${this.APP_ID},你发送了:${msg}`);
}
return 1;
// 如果要回复消息,请调用 api 发送,则 return CQMsg.MSG_INTERCEPT - 拦截本条消息,不再由其他应用继续处理 //注意:应用优先级设置为"最高"(10000)时,无法使用本返回值
// 如果不回复消息,交由之后的应用处理,则 return CQMsg.MSG_IGNORE- 忽略本条消息
return cq_robot_1.CQMsg.MSG_INTERCEPT;
});
}
groupMsg(subType, msgId, fromGroup, fromQQ, fromAnonymous, msg, font) {
return __awaiter(this, void 0, void 0, function* () {
if (fromQQ === 996881204) {
this.CQ.sendGroupMsg(fromGroup, `这是${this.APP_ID},你发送了:${msg}`);
}
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
discussMsg(subType, msgId, fromDiscuss, fromQQ, msg, font) {
return __awaiter(this, void 0, void 0, function* () {
if (fromQQ === 996881204) {
this.CQ.sendDiscussMsg(fromDiscuss, `这是${this.APP_ID},你发送了:${msg}`);
}
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupUpload(subType, sendTime, fromGroup, fromQQ, file) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupAdmin(subType, sendTime, fromGroup, beingOperateQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupDecrease(subType, sendTime, fromGroup, fromQQ, beingOperateQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupIncrease(subType, sendTime, fromGroup, fromQQ, beingOperateQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
friendAdd(subType, sendTime, fromQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
requestAddFriend(subType, sendTime, fromQQ, msg, responseFlag) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
requestAddGroup(subType, sendTime, fromGroup, fromQQ, msg, responseFlag) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
}
const app = new App(); //类名可以随意
exports.app = app;
/**
*仅在debug模式下执行,若不需要也可注释掉
*
*请注意,因为debug的内容在此处就会执行,因此是最先执行的内容!
*/
if (app.CQ.getDebug()) {
app.debug();
Expand Down
20 changes: 10 additions & 10 deletions dist/app/ltd.cmyr.js.demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class App extends cq_robot_1.CQApp {
let res = `这是${this.APP_ID},你发送了:${msg}`;
this.CQ.sendPrivateMsg(fromQQ, res);
}
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupMsg(subType, msgId, fromGroup, fromQQ, fromAnonymous, msg, font) {
Expand All @@ -57,50 +57,50 @@ class App extends cq_robot_1.CQApp {
if (fromQQ === 996881204) {
this.CQ.send_discuss_msg(fromDiscuss, `这是${this.APP_ID},你发送了:${msg}`);
}
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupUpload(subType, sendTime, fromGroup, fromQQ, file) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupAdmin(subType, sendTime, fromGroup, beingOperateQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupDecrease(subType, sendTime, fromGroup, fromQQ, beingOperateQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
groupIncrease(subType, sendTime, fromGroup, fromQQ, beingOperateQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
friendAdd(subType, sendTime, fromQQ) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
requestAddFriend(subType, sendTime, fromQQ, msg, responseFlag) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
requestAddGroup(subType, sendTime, fromGroup, fromQQ, msg, responseFlag) {
return __awaiter(this, void 0, void 0, function* () {
return 0;
return cq_robot_1.CQMsg.MSG_IGNORE;
});
}
}
const app = new App(); //类名可以随意
exports.app = app;
/**
*仅在debug模式下执行,若不需要也可注释掉
*
*请注意,因为debug的内容在此处就会执行,因此是最先执行的内容!
*/
if (app.CQ.getDebug()) {
app.debug();
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const app = help_1.loadApp(path.join(__dirname, 'app')); //载入全体插件
//
// })
bot.on('ready', () => {
cq_robot_1.printTime('[WebSocket] 连接成功!');
cq_robot_1.printTime('[WebSocket] 连接成功!', cq_robot_1.CQLog.LOG_INFO);
app.forEach((key) => {
key.enable();
cq_robot_1.printTime(`[应用] ${key.APP_ID}已启动`, cq_robot_1.CQLog.LOG_INFO_SUCCESS);
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
"lint:fix": "eslint src --fix",
"lint:create": "eslint --init",
"test": "mocha -r ts-node/register test/**/*.test.ts -R nyan",
"uninstall": "rimraf node_modules"
"uninstall": "rimraf node_modules",
"start": "nodemon dist"
},
"author": "CaoMeiYouRen",
"license": "ISC",
"dependencies": {
"cq-robot": "^0.5.0",
"cq-robot": "^0.7.0",
"cq-websocket": "^2.0.1",
"got": "^9.6.0",
"json5": "^2.1.0",
Expand Down Expand Up @@ -43,4 +44,4 @@
"typescript": "^3.5.2",
"typescript-eslint-parser": "^22.0.0"
}
}
}
28 changes: 15 additions & 13 deletions src/app/ltd.cmyr.demo/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// import * as CQ from '../../bin/CQ.old'
import { CQApp, CQFile } from 'cq-robot'
import { CQApp, CQFile, CQMsg } from 'cq-robot'
import fs = require('fs')
import path = require('path')
class App extends CQApp {
constructor() {
super('ltd.cmyr.demo', __dirname)
this.CQ.setDebug(true)
this.CQ.setDebug(false)
}
debug(): void {
// console.log('debug()方法只会在debug模式下执行')
Expand Down Expand Up @@ -36,48 +36,50 @@ class App extends CQApp {
if (fromQQ === 996881204) {
this.CQ.sendPrivateMsg(fromQQ, `这是${this.APP_ID},你发送了:${msg}`)
}
return 1
// 如果要回复消息,请调用 api 发送,则 return CQMsg.MSG_INTERCEPT - 拦截本条消息,不再由其他应用继续处理 //注意:应用优先级设置为"最高"(10000)时,无法使用本返回值
// 如果不回复消息,交由之后的应用处理,则 return CQMsg.MSG_IGNORE- 忽略本条消息
return CQMsg.MSG_INTERCEPT
}
async groupMsg(subType: string, msgId: number, fromGroup: number, fromQQ: number, fromAnonymous: string, msg: string, font: number): Promise<0 | 1> {
if (fromQQ === 996881204) {
this.CQ.sendGroupMsg(fromGroup, `这是${this.APP_ID},你发送了:${msg}`)
}
return 0
return CQMsg.MSG_IGNORE
}
async discussMsg(subType: string, msgId: number, fromDiscuss: number, fromQQ: number, msg: string, font: number): Promise<0 | 1> {
if (fromQQ === 996881204) {
this.CQ.sendDiscussMsg(fromDiscuss, `这是${this.APP_ID},你发送了:${msg}`)
}
return 0
return CQMsg.MSG_IGNORE
}
async groupUpload(subType: string, sendTime: number, fromGroup: number, fromQQ: number, file: CQFile): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}
async groupAdmin(subType: string, sendTime: number, fromGroup: number, beingOperateQQ: number): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}
async groupDecrease(subType: string, sendTime: number, fromGroup: number, fromQQ: number, beingOperateQQ: number): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}
async groupIncrease(subType: string, sendTime: number, fromGroup: number, fromQQ: number, beingOperateQQ: number): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}
async friendAdd(subType: string, sendTime: number, fromQQ: number): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}
async requestAddFriend(subType: string, sendTime: number, fromQQ: number, msg: string, responseFlag: string): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}
async requestAddGroup(subType: string, sendTime: number, fromGroup: number, fromQQ: number, msg: string, responseFlag: string): Promise<0 | 1> {
return 0
return CQMsg.MSG_IGNORE
}

}
const app = new App()//类名可以随意
export { app }//导出模块的名称必须为app
/**
*仅在debug模式下执行,若不需要也可注释掉
*
*请注意,因为debug的内容在此处就会执行,因此是最先执行的内容!
*/
if (app.CQ.getDebug()) {
app.debug()
Expand Down
22 changes: 11 additions & 11 deletions src/app/ltd.cmyr.js.demo/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import * as CQ from '../../bin/CQ.old'
import { CQApp } from 'cq-robot'
import { CQApp, CQMsg } from 'cq-robot'
// LtdCmyrJsDemo
class App extends CQApp {
constructor() {
Expand Down Expand Up @@ -30,7 +30,7 @@ class App extends CQApp {
let res = `这是${this.APP_ID},你发送了:${msg}`
this.CQ.sendPrivateMsg(fromQQ, res)
}
return 0
return CQMsg.MSG_IGNORE
}
async groupMsg(subType, msgId, fromGroup, fromQQ, fromAnonymous, msg, font) {
if (fromQQ === 996881204) {
Expand All @@ -42,35 +42,35 @@ class App extends CQApp {
if (fromQQ === 996881204) {
this.CQ.send_discuss_msg(fromDiscuss, `这是${this.APP_ID},你发送了:${msg}`)
}
return 0
return CQMsg.MSG_IGNORE
}
async groupUpload(subType, sendTime, fromGroup, fromQQ, file) {
return 0
return CQMsg.MSG_IGNORE
}
async groupAdmin(subType, sendTime, fromGroup, beingOperateQQ) {
return 0
return CQMsg.MSG_IGNORE
}
async groupDecrease(subType, sendTime, fromGroup, fromQQ, beingOperateQQ) {
return 0
return CQMsg.MSG_IGNORE
}
async groupIncrease(subType, sendTime, fromGroup, fromQQ, beingOperateQQ) {
return 0
return CQMsg.MSG_IGNORE
}
async friendAdd(subType, sendTime, fromQQ) {
return 0
return CQMsg.MSG_IGNORE
}
async requestAddFriend(subType, sendTime, fromQQ, msg, responseFlag) {
return 0
return CQMsg.MSG_IGNORE
}
async requestAddGroup(subType, sendTime, fromGroup, fromQQ, msg, responseFlag) {
return 0
return CQMsg.MSG_IGNORE
}
}
const app = new App()//类名可以随意
export { app }//导出模块的名称必须为app
/**
*仅在debug模式下执行,若不需要也可注释掉
*
*请注意,因为debug的内容在此处就会执行,因此是最先执行的内容!
*/
if (app.CQ.getDebug()) {
app.debug()
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const app = loadApp(path.join(__dirname, 'app'))//载入全体插件
//
// })
bot.on('ready', () => {
printTime('[WebSocket] 连接成功!')
printTime('[WebSocket] 连接成功!', CQLog.LOG_INFO)
app.forEach((key) => {
key.enable()
printTime(`[应用] ${key.APP_ID}已启动`, CQLog.LOG_INFO_SUCCESS)
Expand Down

0 comments on commit 530baba

Please sign in to comment.