forked from xIKRATOSx/Shizu-Bot-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanonymous_chat.js
45 lines (45 loc) Β· 4.07 KB
/
anonymous_chat.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
async function handler(m, { command }) {
command = command.toLowerCase()
this.anonymous = this.anonymous ? this.anonymous : {}
switch (command) {
case 'next':
case 'leave': {
let room = Object.values(this.anonymous).find(room => room.check(m.sender))
if (!room) return this.sendButton(m.chat, '*[βπππ
πβ] π½πΎ π΄πππ°π π΄π½ ππ½ π²π·π°π π°π½πΎπ½πΈπΌπΎ*\n\n*ΒΏπππΈπ΄ππ΄π πΈπ½πΈπ²πΈπ°π ππ½πΎ?*\n_π³π° π²π»πΈπ²πΊ π΄π½ π΄π» ππΈπΆππΈπ΄π½ππ΄ π±πΎππΎπ½_', author, null, [['πΈπ½πΈπ²πΈπ°π π²π·π°π π°π½πΎπ½πΈπΌπΎ', `.start`]], m)
m.reply('*[ β ] ππ°π»πΈπΎ π²πΎπ½ π΄ππΈππΎ π³π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ*')
let other = room.other(m.sender)
if (other) await this.sendButton(other, '*[βπππ
πβ] π΄π» πΎπππΎ ππππ°ππΈπΎ π°π· π°π±π°π½π³πΎπ½π°π³πΎ π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ*\n\n*ΒΏπππΈπ΄ππ΄π πΈπ π° πΎπππΎ π²π·π°π π°π½πΎπ½πΈπΌπΎ?*\n_π³π° π²π»πΈπ²πΊ π΄π½ π΄π» ππΈπΆππΈπ΄π½ππ΄ π±πΎππΎπ½_', author, null, [['πΈπ½πΈπ²πΈπ°π π²π·π°π π°π½πΎπ½πΈπΌπΎ', `.start`]], m)
delete this.anonymous[room.id]
if (command === 'leave') break
}
case 'start': {
if (Object.values(this.anonymous).find(room => room.check(m.sender))) return this.sendButton(m.chat, '*[βπππ
πβ] ππΎπ³π°π
πΈπ° π΄πππ°π π΄π½ ππ½ π²π·π°π π°π½πΎπ½πΈπΌπΎ πΎ π΄ππΏπ΄ππ°π½π³πΎ π° πππ΄ πΎπππΎ ππππ°ππΈπΎ ππ΄ ππ½π° πΏπ°ππ° πΈπ½πΈπ²πΈπ°π*\n\n*ΒΏπππΈπ΄ππ΄π ππ°π»πΈπ π³π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ?*\n_π³π° π²π»πΈπ²πΊ π΄π½ π΄π» ππΈπΆππΈπ΄π½ππ΄ π±πΎππΎπ½_', author, null, [['ππ°π»πΈπ π³π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ', `.leave`]], m)
let room = Object.values(this.anonymous).find(room => room.state === 'WAITING' && !room.check(m.sender))
if (room) {
await this.sendButton(room.a, '*[ β ] ππ½π° πΏπ΄πππΎπ½π° ππ΄ π°π· ππ½πΈπ³πΎ π°π» π²π·π°π π°π½πΎπ½πΈπΌπΎ, πΏππ΄π³π΄π½ πΈπ½πΈπ²πΈπ°π π° π²π·π°ππ΄π°π*', author, null, [['πΈπ π° πΎπππΎ π²π·π°π', `.next`]], m)
room.b = m.sender
room.state = 'CHATTING'
await this.sendButton(m.chat, '*[ β ] ππ½π° πΏπ΄πππΎπ½π° ππ΄ π°π· ππ½πΈπ³πΎ π°π» π²π·π°π π°π½πΎπ½πΈπΌπΎ, πΏππ΄π³π΄π½ πΈπ½πΈπ²πΈπ°π π° π²π·π°ππ΄π°π*', author, null, [['πΈπ π° πΎπππΎ π²π·π°π', `.next`]], m)
} else {
let id = + new Date
this.anonymous[id] = {
id,
a: m.sender,
b: '',
state: 'WAITING',
check: function (who = '') {
return [this.a, this.b].includes(who)
},
other: function (who = '') {
return who === this.a ? this.b : who === this.b ? this.a : ''
},
}
await this.sendButton(m.chat, '*[βπππ
πβ] π΄ππΏπ΄ππ°π½π³πΎ π° πΎπππΎ ππππ°ππΈπΎ πΏπ°ππ° πΈπ½πΈπ²πΈπ°π π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ*\n\n*ΒΏπππΈπ΄ππ΄π ππ°π»πΈπ π³π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ?*\n_π³π° π²π»πΈπ²πΊ π΄π½ π΄π» ππΈπΆππΈπ΄π½ππ΄ π±πΎππΎπ½_', author, null, [['ππ°π»πΈπ π³π΄π» π²π·π°π π°π½πΎπ½πΈπΌπΎ', `.leave`]], m)
}
break
}}}
handler.help = ['start', 'leave', 'next']
handler.tags = ['anonymous']
handler.command = ['start', 'leave', 'next']
handler.private = true
export default handler