-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
140 lines (125 loc) · 5.14 KB
/
index.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import qrcode from 'qrcode-terminal'
import * as pkg from 'whatsapp-web.js'
import { getTabela } from './futebol/campeonato/tabela.js';
import { getDavinciResponse } from './openai/davinci.js';
import { showUnique } from './util/show_unique.js';
import { getTop10 } from './games/valorant/leaderboard.js';
import { getCurrentRank } from './games/valorant/rank.js';
import { getQueueHirstoryByGameTag } from './games/valorant/queue.js';
import { commands, getHelp } from './util/commands.js';
import { getResponseContext } from './games/lol/others.js';
import { pollo } from './games/valorant/others.js';
import { createSticker } from './util/sticker.js';
import { options } from './client.js';
const { Client, MessageMedia } = pkg;
const client = new Client({
webVersionCache: {
type: 'remote',
remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html',
}
})
client.on('qr', (qr) => {
qrcode.generate(qr, { small: true })
console.log("Escaneie o QR Code acima para iniciar a sessão")
console.log('QR RECEIVED: ', qr)
})
client.on('ready', () => {
console.log('Client is ready!')
})
client.on('message', (msg) => {
const chat = msg.getChat().then((response) => {
console.log(`Chat: ${response.name}`)
return response
})
msg.getContact().then((response) => {
console.log(`${response.pushname} - ${msg.body}\n`)
})
const bot_commands = commands
let firstWord = ((msg.body.includes(' ')) ? msg.body.substring(0, msg.body.indexOf(" ")) : msg.body);
switch (firstWord) {
case bot_commands.ping:
msg.reply('🏓 Pong')
break
case bot_commands.aniversario:
const getPushname = async () => {
await msg.getContact().then((response) => {
msg.reply(`Feliz aniversário! ${response.pushname} 🎈🍰\n\n`)
})
}
getPushname()
break
case bot_commands.help:
msg.reply(getHelp())
break
case bot_commands.gpt:
const question_gpt = msg.body.substring(msg.body.indexOf(" ") + 1);
getDavinciResponse(question_gpt).then((response) => {
msg.reply(`🤖 Chat GPT - Generated by OpenAI Turbo 4.0 \n\n ${response}`)
})
break
case bot_commands.traduzir:
const traduzir = "Traduza" + msg.body.substring(msg.body.indexOf(" ") + 1);
getDavinciResponse(traduzir).then((response) => {
msg.reply(`📬 Tradução: \n\n ${response}`)
})
break
case bot_commands.dalle:
const question_dalle = msg.body.substring(msg.body.indexOf(" ") + 1);
//getDalleResponse(question_dalle).then((response) => {
// console.log("-=-=-=-=-=-=-=-\n\n")
// console.log(response)
// msg.reply(new pkg.MessageMedia('image/png', response))
//})
msg.reply('Ops! Comando desativado ❌')
break
case bot_commands.brasileirao:
msg.reply(getTabela().then((response) => {
const tabela_promise = Promise.resolve(getTabela())
tabela_promise.then((response) => {
msg.reply(response)
})
}))
break
case bot_commands.show:
showUnique(msg)
break
case bot_commands.transcribe:
//transcribe(msg)
msg.reply("Ops! Comando desativado ❌")
break
case bot_commands.vlrLeaderboard:
let regiao = (!(msg.body.includes(" ")))? "br":msg.body.substring(msg.body.indexOf(" ") + 1);
console.log(regiao)
getTop10(regiao).then((response) => {
msg.reply(response)
})
break
case bot_commands.rank:
const gametag = msg.body.substring(msg.body.indexOf(" ") + 1);
const gameName = gametag.substring(0, gametag.indexOf("#"))
const tagName = gametag.substring(gametag.indexOf("#") + 1)
getCurrentRank(gameName, tagName, "br").then((response) => {
msg.reply(`🤖 Generated by Bot \n${response}`)
})
break
case bot_commands.queue:
const gametagQueue = msg.body.substring(msg.body.indexOf(" ") + 1);
const gameNameQueue = gametagQueue.substring(0, gametagQueue.indexOf("#"))
const tagNameQueue = gametagQueue.substring(gametagQueue.indexOf("#") + 1)
getQueueHirstoryByGameTag(gameNameQueue, tagNameQueue).then((response) => {
msg.reply(`🤖 Generated by Bot \n${response}`)
})
break
case bot_commands.kahzix:
msg.reply(getResponseContext("kahzix"))
break
case bot_commands.pollo:
msg.getChat().then(async (response) => {
await response.sendMessage(`Paulo Cartões 🤪🪄\n ${pollo}`,{linkPreview:true})
})
case bot_commands.sticker:
createSticker(msg)
break
}
})
client.initialize();