-
Notifications
You must be signed in to change notification settings - Fork 45
/
hi.js
87 lines (80 loc) · 1.89 KB
/
hi.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
module.exports.config = {
name: "hi",
version: "1.0.1",
hasPermssion: 0,
credits: "ManhG",
description: "",
commandCategory: "noprefix",
usages: "",
cooldowns: 0,
denpendencies: {
"fs-extra": "",
"request": ""
}
};
module.exports.handleEvent = async ({
event,
api,
Users
}) => {
const fs = global.nodemodule["fs-extra"];
var {
threadID,
messageID,
body,
senderID
} = event;
const thread = global.data.threadData.get(threadID) || {};
if (typeof thread["hi"] !== "undefined" && thread["hi"] == false) return;
let name = await Users.getNameUser(event.senderID);
if (senderID == api.getCurrentUserID()) return;
function out(data) {
api.sendMessage(data, threadID, messageID)
}
//trả lời
var msg = {
body: `Chào ${name}, chúc bạn một ngày tốt lành ❤️`,
attachment: (await global.nodemodule["axios"]({
url: (await global.nodemodule["axios"]('https://apikanna.change-itit.repl.co')).data.data,
method: "GET",
responseType: "stream"
})).data
}
// Gọi bot
var arr = ["hi", "hello", "lô", "hí lô", "chào"];
arr.forEach(i => {
let str = i[0].toUpperCase() + i.slice(1);
if (body === i.toUpperCase() | body === i | str === body) return out(msg)
});
};
module.exports.languages = {
"vi": {
"on": "Bật",
"off": "Tắt",
"successText": "hi thành công",
},
"en": {
"on": "on",
"off": "off",
"successText": "hi success!",
}
}
module.exports.run = async function({
api,
event,
Threads,
getText
}) {
const {
threadID,
messageID
} = event;
let data = (await Threads.getData(threadID)).data;
if (typeof data["hi"] == "undefined" || data["hi"] == true) data["hi"] = false;
else data["hi"] = true;
await Threads.setData(threadID, {
data
});
global.data.threadData.set(threadID, data);
return api.sendMessage(`${(data["hi"] == false) ? getText("off") : getText("on")} ${getText("successText")}`, threadID, messageID);
}