forked from phaticusthiccy/WhatsAsenaDuplicated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
50 lines (41 loc) · 1.9 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
50
/* Copyright (C) 2020 Yusuf Usta.
Licensed under the GPL-3.0 License;
you may not use this file except in compliance with the License.
WhatsAsena - Yusuf Usta
*/
// Komutları burada tutacağız.
var config = require('./config');
var Commands = [];
function addCommand(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 = {
addCommand: addCommand,
commands: Commands
}