-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (54 loc) · 1.01 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
const server = require('./server')
const update = require('./update')
const tg = require('./tg')
const on = require('./on')
class telegram_nodity
{
constructor(_options)
{
const defalut_options = {
method : 'hook',
server : {
port : 3313,
host : '127.0.0.2'
},
response : {},
update_listen_timeout : 2000,
update_listen_time : 1000,
queue_timeout : 3000
}
this.options = Object.assign(defalut_options, _options)
this.events = new on(this)
this._tg = new tg(this)
if(typeof this.options.api !== 'object')
{
console.error("Telegram api config not set")
return
}
if(!this.options.api.token)
{
console.error("Telegram api token not set")
return
}
if(this.options.method == 'update')
{
new update(this)
}else if(this.options.method)
{
new server(this)
}
}
on()
{
return this.events.on(...arguments)
}
trigger()
{
return this.events.trigger(...arguments)
}
tg()
{
return this._tg.send(...arguments)
}
}
module.exports = telegram_nodity