update
This commit is contained in:
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
import {MessageContext} from "../../base/base";
|
||||
|
||||
export declare class Command {
|
||||
regexp: RegExp
|
||||
title?: string
|
||||
description?: string
|
||||
requireAdmin?: boolean
|
||||
requireReply?: boolean
|
||||
requireCreator?: boolean
|
||||
requireChat?: boolean
|
||||
|
||||
execute: (context: MessageContext, params: string[], reply?: MessageContext) => {}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const base_1 = require("../../base/base");
|
||||
const db_1 = require("../../base/db");
|
||||
const net_1 = require("../../base/net");
|
||||
const test_1 = require("../test");
|
||||
const help_1 = require("../help");
|
||||
const ae_1 = require("../ae");
|
||||
const dad_1 = require("../dad");
|
||||
const fuckYou_1 = require("../fuckYou");
|
||||
const mom_1 = require("../mom");
|
||||
const mute_1 = require("../mute");
|
||||
const unmute_1 = require("../unmute");
|
||||
const ping_1 = require("../ping");
|
||||
const q_1 = require("../q");
|
||||
const randomString_1 = require("../randomString");
|
||||
const systemSpecs_1 = require("../systemSpecs");
|
||||
async function parseCommands(context) {
|
||||
try {
|
||||
const cmd = searchCommand(context);
|
||||
if (!cmd ||
|
||||
(cmd.requireChat && !context.isChat()) ||
|
||||
(cmd.requireReply && !context.hasRepliedMessage()))
|
||||
return;
|
||||
if ((cmd.requireCreator && context.senderId != base_1.CREATOR_ID) ||
|
||||
(cmd.requireAdmin && !base_1.includes(db_1.adminsList, context.senderId))) {
|
||||
await net_1.sendMessage(context, 'У вас нет доступа');
|
||||
return;
|
||||
}
|
||||
cmd.execute(context, context.text.match(cmd.regexp), context.repliedMessage);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(base_1.getExceptionText(e));
|
||||
}
|
||||
function searchCommand(message, text) {
|
||||
return commands.find(c => c.regexp.test(message ? message.text : text));
|
||||
}
|
||||
}
|
||||
exports.parseCommands = parseCommands;
|
||||
let commands = [
|
||||
new ae_1.Ae(),
|
||||
new dad_1.Dad(),
|
||||
new fuckYou_1.FuckYou(),
|
||||
new help_1.Help(),
|
||||
new mom_1.Mom(),
|
||||
new mute_1.Mute(),
|
||||
new unmute_1.Unmute(),
|
||||
new ping_1.Ping(),
|
||||
new q_1.Q(),
|
||||
new randomString_1.RandomString(),
|
||||
new systemSpecs_1.SystemSpecs(),
|
||||
new test_1.Test()
|
||||
];
|
||||
//# sourceMappingURL=commands.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commands.js","sourceRoot":"","sources":["commands.ts"],"names":[],"mappings":";;AAAA,0CAAuF;AAEvF,sCAAyC;AACzC,wCAA2C;AAC3C,kCAA6B;AAC7B,kCAA6B;AAC7B,8BAAyB;AACzB,gCAA2B;AAC3B,wCAAmC;AACnC,gCAA2B;AAC3B,kCAA6B;AAC7B,sCAAiC;AACjC,kCAA6B;AAC7B,4BAAuB;AACvB,kDAA6C;AAC7C,gDAA2C;AAEpC,KAAK,UAAU,aAAa,CAAC,OAAuB;IACvD,IAAI;QACA,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;QAElC,IAAI,CAAC,GAAG;YACJ,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACtC,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAAE,OAAM;QAE9D,IAAI,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,CAAC,QAAQ,IAAI,iBAAU,CAAC;YACtD,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,eAAQ,CAAC,eAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;YAE/D,MAAM,iBAAW,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAA;YAC/C,OAAM;SACT;QAED,GAAG,CAAC,OAAO,CACP,OAAO,EACP,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAC9B,OAAO,CAAC,cAAc,CACzB,CAAA;KACJ;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,GAAG,CAAC,uBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;KACnC;IAED,SAAS,aAAa,CAAC,OAAO,EAAE,IAAa;QACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3E,CAAC;AACL,CAAC;AA3BD,sCA2BC;AAED,IAAI,QAAQ,GAAc;IACtB,IAAI,OAAE,EAAE;IACR,IAAI,SAAG,EAAE;IACT,IAAI,iBAAO,EAAE;IACb,IAAI,WAAI,EAAE;IACV,IAAI,SAAG,EAAE;IACT,IAAI,WAAI,EAAE;IACV,IAAI,eAAM,EAAE;IACZ,IAAI,WAAI,EAAE;IACV,IAAI,KAAC,EAAE;IACP,IAAI,2BAAY,EAAE;IAClB,IAAI,yBAAW,EAAE;IACjB,IAAI,WAAI,EAAE;CACb,CAAA"}
|
||||
@@ -0,0 +1,60 @@
|
||||
import {CREATOR_ID, getExceptionText, includes, MessageContext} from "../../base/base";
|
||||
import {Command} from "./command";
|
||||
import {adminsList} from "../../base/db";
|
||||
import {sendMessage} from "../../base/net";
|
||||
import {Test} from "../test";
|
||||
import {Help} from "../help";
|
||||
import {Ae} from "../ae";
|
||||
import {Dad} from "../dad";
|
||||
import {FuckYou} from "../fuckYou";
|
||||
import {Mom} from "../mom";
|
||||
import {Mute} from "../mute";
|
||||
import {Unmute} from "../unmute";
|
||||
import {Ping} from "../ping";
|
||||
import {Q} from "../q";
|
||||
import {RandomString} from "../randomString";
|
||||
import {SystemSpecs} from "../systemSpecs";
|
||||
|
||||
export async function parseCommands(context: MessageContext) {
|
||||
try {
|
||||
const cmd = searchCommand(context)
|
||||
|
||||
if (!cmd ||
|
||||
(cmd.requireChat && !context.isChat()) ||
|
||||
(cmd.requireReply && !context.hasRepliedMessage())) return
|
||||
|
||||
if ((cmd.requireCreator && context.senderId != CREATOR_ID) ||
|
||||
(cmd.requireAdmin && !includes(adminsList, context.senderId))) {
|
||||
|
||||
await sendMessage(context, 'У вас нет доступа')
|
||||
return
|
||||
}
|
||||
|
||||
cmd.execute(
|
||||
context,
|
||||
context.text.match(cmd.regexp),
|
||||
context.repliedMessage
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(getExceptionText(e))
|
||||
}
|
||||
|
||||
function searchCommand(message, text?: string): Command {
|
||||
return commands.find(c => c.regexp.test(message ? message.text : text))
|
||||
}
|
||||
}
|
||||
|
||||
let commands: Command[] = [
|
||||
new Ae(),
|
||||
new Dad(),
|
||||
new FuckYou(),
|
||||
new Help(),
|
||||
new Mom(),
|
||||
new Mute(),
|
||||
new Unmute(),
|
||||
new Ping(),
|
||||
new Q(),
|
||||
new RandomString(),
|
||||
new SystemSpecs(),
|
||||
new Test()
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const base_1 = require("../../base/base");
|
||||
const net_1 = require("../../base/net");
|
||||
class Stats {
|
||||
constructor() {
|
||||
this.regexp = /^\/stats/i;
|
||||
}
|
||||
async execute(context) {
|
||||
const text = `Статистика бота.\n\n⏳ Время работы: ${base_1.getUptime()}\n📥 Сообщений получено: ${base_1.messagesReceived}\n📤 Сообщений отправлено: ${base_1.messagesSent}`;
|
||||
await net_1.sendMessage(context, text);
|
||||
}
|
||||
}
|
||||
exports.Stats = Stats;
|
||||
//# sourceMappingURL=stats.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stats.js","sourceRoot":"","sources":["stats.ts"],"names":[],"mappings":";;AACA,0CAA0F;AAC1F,wCAA2C;AAE3C,MAAa,KAAK;IAAlB;QACI,WAAM,GAAG,WAAW,CAAA;IASxB,CAAC;IALG,KAAK,CAAC,OAAO,CAAC,OAAuB;QACjC,MAAM,IAAI,GAAG,uCAAuC,gBAAS,EAAE,4BAA4B,uBAAgB,8BAA8B,mBAAY,EAAE,CAAA;QACvJ,MAAM,iBAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC;CAEJ;AAVD,sBAUC"}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {Command} from "./command";
|
||||
import {getUptime, MessageContext, messagesReceived, messagesSent} from "../../base/base";
|
||||
import {sendMessage} from "../../base/net";
|
||||
|
||||
export class Stats implements Command {
|
||||
regexp = /^\/stats/i
|
||||
title: '/stats'
|
||||
description: 'статистика бота'
|
||||
|
||||
async execute(context: MessageContext) {
|
||||
const text = `Статистика бота.\n\n⏳ Время работы: ${getUptime()}\n📥 Сообщений получено: ${messagesReceived}\n📤 Сообщений отправлено: ${messagesSent}`
|
||||
await sendMessage(context, text)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user