-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfbcover.js
More file actions
86 lines (83 loc) · 2.78 KB
/
fbcover.js
File metadata and controls
86 lines (83 loc) · 2.78 KB
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
module.exports.config = {
name: "fbcover",
version: "1.0.0",
hasPermssion: 0,
credits: "SENPROJECT", //TDUNG
description: "blah blah blha",
group: "image",
usages: "",
cooldowns: 5
};
module.exports.handleReply = async ({ api, event, handleReply }) => {
const { threadID, messageID, senderID, body } = event;
if (handleReply.content.id != senderID) return;
const input = body.trim();
const sendC = (msg, step, content) => api.sendMessage(msg, threadID, (err, info) => {
global.client.handleReply.splice(global.client.handleReply.indexOf(handleReply), 1);
api.unsendMessage(handleReply.messageID);
global.client.handleReply.push({
step: step,
name: this.config.name,
messageID: info.messageID,
content: content
})
}, messageID);
const send = async (msg) => api.sendMessage(msg, threadID, messageID);
let content = handleReply.content;
switch (handleReply.step) {
case 1:
content.nhanvat = input;
sendC("Reply tin nhắn này chữ nền của bạn", 2, content);
break;
case 2:
content.nen = input;
sendC("Reply tin nhắn này chữ ký của bạn", 3, content);
break;
case 3:
content.ky = input;
sendC("Reply tin nhắn này chọn màu của bạn(tên tiếng anh)", 4, content);
break;
case 4:
content.color = input;
sendC("Reply tin nhắn này fb của bạn", 5, content);
break;
case 5:
content.fb = input;
const axios = require("axios");
const fs = require("fs");
send("Thông tin đã được ghi nhận, vui lòng đợi trong giây lát!");
global.client.handleReply.splice(global.client.handleReply.indexOf(handleReply), 1);
api.unsendMessage(handleReply.messageID);
let c = content;
let res = await axios.get(encodeURI(`https://dino-1.araxy.repl.co/taoanhdep?id=${c.nhanvat}&tenchinh=${c.ky}&fb=${c.fb}&tenphu=${c.nen}&color=${c.color}`), { responseType: "arraybuffer" })
.catch(e => { return send("Lỗi không xác định, liên hệ admin để fix") });
if (res.status != 200) return send("Đã có lỗi xảy ra, vui lòng thử lại sau!");
let path = __dirname + `/cache/fbcoverv11__${senderID}.png`;
fs.writeFileSync(path, Buffer.from(res.data, "utf-8"));
send({
body: 'Ảnh của bạn đây',
attachment: fs.createReadStream(path)
}).then(fs.unlinkSync(path));
break;
default:
break;
}
}
module.exports.run = ({ api, event, args }) => {
const { threadID, messageID, senderID } = event;
return api.sendMessage("Reply tin nhắn này chọn id nhân vật", event.threadID, (err,info) => {
global.client.handleReply.push({
step: 1,
name: this.config.name,
messageID: info.messageID,
content: {
id: senderID,
nhanvat: "",
nen: "",
ky: "",
color: "",
fb: ""
}
})
}, event.messageID);
}