-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
70 lines (55 loc) · 1.88 KB
/
main.js
File metadata and controls
70 lines (55 loc) · 1.88 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
const {getJob} = require('./src/middlewares/linkedin/jobs');
const {mandaNude} = require('./src/middlewares/nude/sendNude');
const {bot} = require('./src/servers/server');
const {getWhois} = require('./src/middlewares/whois/whois');
const { sendMessage, getSessionId } = require('./src/servers/assistent');
const { getCache, setCache } = require('./src/servers/redis');
// ---------------- busca por vagas --------------------
bot.onText(/\/vagas (.+)/, async (msg, match) => {
const chatId = msg.chat.id;
const resp = match[1]; // the captured "whatever"
const jobs = await getJob(resp)
bot.sendMessage(chatId,jobs);
});
// --------------- busca por informações de sites--------
bot.onText(/\/whois (.+)/, async (msg, match) => {
const chatId = msg.chat.id;
const resp = match[1]; // the captured "whatever"
const data = await getWhois(resp)
bot.sendMessage(chatId,data);
});
//------------------
bot.on('message', async (msg) => {
const chatId = msg.chat.id;
console.log(chatId);
if(msg.text == "#mandanude"){
const url = await mandaNude()
bot.sendPhoto(chatId, url);
}else if(msg.text == 'Oi'){
bot.sendMessage(chatId, 'Oiiii sumido, tudo bem?');
}else if(msg.text == 'Tudo e vc?'){
bot.sendMessage(chatId, 'Melhor agora ;)');
}else if(msg.text.toLowerCase() == "ola watson"){
try{
let id = await getSessionId();
console.log(id);
setCache(chatId,id.result.session_id);
session_id = true
}catch(err){
console.log(err)
}
}else if(msg.text){
try{
let id = await getCache(chatId);
if(id){
let response = await sendMessage(msg.text,id);
bot.sendMessage(chatId,response);
}else{
let id = await getSessionId();
console.log(id);
setCache(chatId,id.result.session_id);
bot.sendMessage(chatId,'Oiii, não consegui te entender! Diga novamente!')
}
}catch(err){
}
}});