Created
September 15, 2021 10:59
-
-
Save tluyben/3adb74282b0df4819ee9f46ba10a2a4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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