Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const token = '816620384:AAG9hiCDppW5chOGnq4nxcdMZwgZr3rxvPQ';
- const PROXY_SOCKS5_HOST = '162.243.108.161';
- const PROXY_SOCKS5_PORT = '1080';
- const TelegramBot = require('node-telegram-bot-api')
- const Agent = require('socks5-https-client/lib/Agent')
- const bot = new TelegramBot(process.env.token, {
- polling: true,
- request: {
- agentClass: Agent,
- agentOptions: {
- socksHost: process.env.PROXY_SOCKS5_HOST,
- socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
- // If authorization is needed:
- // socksUsername: process.env.PROXY_SOCKS5_USERNAME,
- // socksPassword: process.env.PROXY_SOCKS5_PASSWORD
- }
- }
- })
- // Matches "/echo [whatever]"
- bot.onText(/\/echo (.+)/, (msg, match) => {
- // 'msg' is the received Message from Telegram
- // 'match' is the result of executing the regexp above on the text content
- // of the message
- const chatId = msg.chat.id;
- const resp = match[1]; // the captured "whatever"
- // send back the matched "whatever" to the chat
- bot.sendMessage(chatId, resp);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement