Skip to content

Commit 48dcdd6

Browse files
author
Denis
committedOct 9, 2018
proxy to telegram bot
1 parent 8a49829 commit 48dcdd6

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed
 

‎bot.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
process.env.NTBA_FIX_319 = 1;
22

33
var TelegramBot = require('node-telegram-bot-api');
4+
const Agent = require('socks5-https-client/lib/Agent')
5+
46

57
var emoji = require('node-emoji');
68
var fs = require('fs');
@@ -32,7 +34,19 @@ config.loadConfigurationFile().then(() => {
3234
});
3335

3436
function start_bot(){
35-
var bot = new TelegramBot(init.TOKEN, {polling: true});
37+
var bot = new TelegramBot(init.TOKEN, {
38+
polling: true,
39+
// request: {
40+
// agentClass: Agent,
41+
// agentOptions: {
42+
// socksHost: init.proxy.host,
43+
// socksPort: parseInt(init.proxy.port),
44+
// // If authorization is needed:
45+
// // socksUsername: init.proxy.username,
46+
// // socksPassword: init.proxy.password
47+
// }
48+
// }
49+
});
3650

3751
bot.on('message', function(msg){
3852
// Actions to SAVE

‎init.js

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ var menu = {};
1515
var menu_root;
1616
var admins = [];
1717

18+
var proxy = {
19+
'host': '',
20+
'port': '',
21+
'username': '',
22+
'password': ''
23+
}
24+
1825
var MSG_START = "Use menu";
1926
var MSG_DEFAULT = "Click to button";
2027
var MSG_BACK = function(key){ return "Back to " + key }
@@ -106,6 +113,8 @@ module.exports.menu = menu;
106113
module.exports.menu_root = menu_root;
107114
module.exports.admins = admins;
108115

116+
module.exports.proxy = proxy;
117+
109118
module.exports.MSG_START = MSG_START;
110119
module.exports.MSG_DEFAULT = MSG_DEFAULT;
111120
module.exports.MSG_BACK = MSG_BACK;

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"homepage": "https://github.com/zZoMROT/telegram-bot-menu#readme",
1919
"dependencies": {
2020
"node-emoji": "^1.8.1",
21-
"node-telegram-bot-api": "^0.30.0"
21+
"node-telegram-bot-api": "^0.30.0",
22+
"socks5-https-client": "^1.2.1"
2223
}
2324
}

0 commit comments

Comments
 (0)
Please sign in to comment.