forked from BlackAmda/QueenAmdi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
49 lines (40 loc) · 1.86 KB
/
events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Copyright (C) 2020 Black Amda.
Licensed under the GPL-3.0 License;
you may not use this file except in compliance with the License.
QueenAmdi - Black Amda
*/
var config = require('./config');
var Commands = [];
function applyCMD(info, func) {
// Basit bir fonksiyon, komut eklemek için.
var types = ['photo', 'image', 'text', 'message'];
var infos = {
fromMe: info['fromMe'] === undefined ? true : info['fromMe'], // Or Sudo
onlyGroup: info['onlyGroup'] === undefined ? false : info['onlyGroup'],
onlyPinned: info['onlyPinned'] === undefined ? false : info['onlyPinned'],
onlyPm: info['onlyPm'] === undefined ? false : info['onlyPm'],
deleteCommand: info['deleteCommand'] === undefined ? true : info['deleteCommand'],
desc: info['desc'] === undefined ? '' : info['desc'],
usage: info['usage'] === undefined ? '' : info['usage'],
dontAddCommandList: info['dontAddCommandList'] === undefined ? false : info['dontAddCommandList'],
warn: info['warn'] === undefined ? '' : info['warn'],
function: func
};
if (info['on'] === undefined && info['pattern'] === undefined) {
infos.on = 'message';
infos.fromMe = false;
} else if (info['on'] !== undefined && types.includes(info['on'])) {
infos.on = info['on'];
if (info['pattern'] !== undefined) {
infos.pattern = new RegExp((info['handler'] === undefined || info['handler'] === true ? config.HANDLERS : '') + info.pattern, (info['flags'] !== undefined ? info['flags'] : ''));
}
} else {
infos.pattern = new RegExp((info['handler'] === undefined || info['handler'] === true ? config.HANDLERS : '') + info.pattern, (info['flags'] !== undefined ? info['flags'] : ''));
}
Commands.push(infos);
return infos;
}
module.exports = {
applyCMD: applyCMD,
commands: Commands
}