Skip to content

Instantly share code, notes, and snippets.

@tluyben
Created September 15, 2021 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tluyben/3adb74282b0df4819ee9f46ba10a2a4d to your computer and use it in GitHub Desktop.
Save tluyben/3adb74282b0df4819ee9f46ba10a2a4d to your computer and use it in GitHub Desktop.
const express = require('express')
const app = express()
const port = 3000
const fs = require('fs')
const TelegramBot = require('node-telegram-bot-api')
const token = '<<<< PUT BOT TOKEN HERE >>>>>'
const bot = new TelegramBot(token, {polling: true})
// 1. go to the web version web.telegram.org
// 2. go to the channel
// 3. take the number from the url and put -100 in front of the number
const chatId = -100xxxxxxxx;
app.use(express.json())
app.post('/', (req, res) => {
bot.sendMessage(chatId, req.body.message+', '+req.body.url)
res.send('ok')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment