forked from bitcoinvsalts/node-binance-trader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelegram.js
52 lines (43 loc) · 2.13 KB
/
telegram.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
const TeleBot = require('telebot')
const _ = require('lodash')
module.exports = function (use_telegram, telegramToken, telChanel, trading_pairs) {
if (!use_telegram) {
return true;
}
const telBot = new TeleBot({
token: telegramToken, // Required. Telegram Bot API token.
polling: { // Optional. Use polling.
interval: 700, // Optional. How often check updates (in ms).
timeout: 0, // Optional. Update polling timeout (0 - short polling).
limit: 100, // Optional. Limits the number of updates to be retrieved.
retryTimeout: 5000, // Optional. Reconnecting timeout (in ms).
// proxy: 'http://username:password@yourproxy.com:8080' // Optional. An HTTP proxy to be used.
},
// webhook: { // Optional. Use webhook instead of polling.
// key: 'key.pem', // Optional. Private key for server.
// cert: 'cert.pem', // Optional. Public key.
// url: 'https://....', // HTTPS url to send updates to.
// host: '0.0.0.0', // Webhook server host.
// port: 443, // Server port.
// maxConnections: 40 // Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
// },
allowedUpdates: [], // Optional. List the types of updates you want your bot to receive. Specify an empty list to receive all updates.
usePlugins: ['askUser'], // Optional. Use user plugins from pluginFolder.
pluginFolder: '../plugins/', // Optional. Plugin folder location.
pluginConfig: { // Optional. Plugin configuration.
// myPluginName: {
// data: 'my custom value'
// }
}
});
telBot.telChanel = telChanel;
// GET CHANEL ID
telBot.on('/info', async (msg) => {
let response = "Open Trades: "+ _.values(trading_pairs).length+"\n"
// response += "Chanel ID : "+msg.chat.id+"\n" //IF UNCOMENT SHOW CHANEL ID
// telBot.telChanel = msg.chat.id
return telBot.sendMessage(telChanel, response)
});
telBot.start();
return telBot;
}