|
@@ -1,8 +1,12 @@
|
|
"use strict";
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.status = exports.unsub = exports.sub = exports.parseCmd = void 0;
|
|
exports.status = exports.unsub = exports.sub = exports.parseCmd = void 0;
|
|
|
|
+const fs = require("fs");
|
|
|
|
+const path = require("path");
|
|
const datetime_1 = require("./datetime");
|
|
const datetime_1 = require("./datetime");
|
|
|
|
+const loggers_1 = require("./loggers");
|
|
const twitter_1 = require("./twitter");
|
|
const twitter_1 = require("./twitter");
|
|
|
|
+const logger = (0, loggers_1.getLogger)('command');
|
|
function parseCmd(message) {
|
|
function parseCmd(message) {
|
|
message = message.trim();
|
|
message = message.trim();
|
|
message = message.replace('\\\\', '\\0x5c');
|
|
message = message.replace('\\\\', '\\0x5c');
|
|
@@ -31,6 +35,8 @@ function sub(chat, args, reply, lock, lockfile) {
|
|
if (index > -1)
|
|
if (index > -1)
|
|
return reply('此聊天已订阅 IDOLY PRIDE BWIKI 更新提醒。');
|
|
return reply('此聊天已订阅 IDOLY PRIDE BWIKI 更新提醒。');
|
|
lock.subscribers.push(chat);
|
|
lock.subscribers.push(chat);
|
|
|
|
+ logger.warn(`chat ${JSON.stringify(chat)} has subscribed to updates`);
|
|
|
|
+ fs.writeFileSync(path.resolve(lockfile), JSON.stringify(lock));
|
|
reply('已为此聊天订阅 IDOLY PRIDE BWIKI 更新提醒。');
|
|
reply('已为此聊天订阅 IDOLY PRIDE BWIKI 更新提醒。');
|
|
}
|
|
}
|
|
exports.sub = sub;
|
|
exports.sub = sub;
|
|
@@ -42,6 +48,8 @@ function unsub(chat, args, reply, lock, lockfile) {
|
|
if (index === -1)
|
|
if (index === -1)
|
|
return reply('此聊天未订阅 IDOLY PRIDE BWIKI 更新提醒。');
|
|
return reply('此聊天未订阅 IDOLY PRIDE BWIKI 更新提醒。');
|
|
lock.subscribers.splice(index, 1);
|
|
lock.subscribers.splice(index, 1);
|
|
|
|
+ logger.warn(`chat ${JSON.stringify(chat)} has unsubscribed from updates`);
|
|
|
|
+ fs.writeFileSync(path.resolve(lockfile), JSON.stringify(lock));
|
|
reply('已为此聊天退订 IDOLY PRIDE BWIKI 更新提醒。');
|
|
reply('已为此聊天退订 IDOLY PRIDE BWIKI 更新提醒。');
|
|
}
|
|
}
|
|
exports.unsub = unsub;
|
|
exports.unsub = unsub;
|