-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheespdic.js
72 lines (68 loc) · 2.06 KB
/
eespdic.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
// Modules
const fs = require('fs'),
Tgfancy = require('tgfancy'),
_ = require('lodash'),
Promise = require('bluebird'),
url = require('url'),
// Variables
secrets = fs.readFileSync("secrets.json"),
vars = JSON.parse(secrets),
token = vars.test_token,
bot = new Tgfancy(token, { polling: true }),
me = "ElMejorRobot";
bot.onText(/^\/eoen (.+)/, (msg, match)=>{
if (match[1].length < 40) {
msg.data = {
from: "0",
to: "5",
lang: "eo",
word: match[1],
langs: "eoen",
amount: "5",
type: "message"
}
bot.emit('eoen', msg)
} else {
if (data.lang === "en") {
text = "I can only process words of up to 39 characters in order to function properly."
} else if (data.lang === "eo") {
text = "Pro funkciaj limigoj, mi nur povas serĉi vortoj malpli longaj ol 40 literoj."
}
bot.sendMessage(msg.chat.id, text)
}
})
bot.onText(/^\/eneo (.+)/, (msg, match)=>{
if (match[1].length < 40) {
const data = {
from: "0",
to: "5",
lang: "en",
word: match[1],
langs: "eneo",
amount: "5",
type: "message"
}
processCbData(data, msg)
} else {
if (data.lang === "en") {
text = "I can only process words of up to 39 characters in order to function properly."
} else if (data.lang === "eo") {
text = "Pro funkciaj limigoj, mi nur povas serĉi vortoj malpli longaj ol 40 literoj."
}
bot.sendMessage(msg.chat.id, text)
}
})
bot.on('callback_query', msg=>{
const match = msg.data.split(" ")
const data = {
from: match[0],
to: match[1],
lang: match[2],
word: match[3],
langs: match[4],
command: match[5],
amount: String(match[1] - match[0]),
type: "callback_query"
}
processCbData(data, msg)
})