Advertisement
Guest User

Untitled

a guest
Apr 8th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const token = '816620384:AAG9hiCDppW5chOGnq4nxcdMZwgZr3rxvPQ';
  2. const PROXY_SOCKS5_HOST = '162.243.108.161';
  3. const PROXY_SOCKS5_PORT = '1080';
  4.  
  5. const TelegramBot = require('node-telegram-bot-api')
  6. const Agent = require('socks5-https-client/lib/Agent')
  7.  
  8. const bot = new TelegramBot(process.env.token, {
  9.   polling: true,
  10.   request: {
  11.     agentClass: Agent,
  12.     agentOptions: {
  13.       socksHost: process.env.PROXY_SOCKS5_HOST,
  14.       socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
  15.       // If authorization is needed:
  16.       // socksUsername: process.env.PROXY_SOCKS5_USERNAME,
  17.       // socksPassword: process.env.PROXY_SOCKS5_PASSWORD
  18.     }
  19.   }
  20. })
  21.  
  22. // Matches "/echo [whatever]"
  23. bot.onText(/\/echo (.+)/, (msg, match) => {
  24.   // 'msg' is the received Message from Telegram
  25.   // 'match' is the result of executing the regexp above on the text content
  26.   // of the message
  27.  
  28.   const chatId = msg.chat.id;
  29.   const resp = match[1]; // the captured "whatever"
  30.  
  31.   // send back the matched "whatever" to the chat
  32.   bot.sendMessage(chatId, resp);
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement