Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// you have to need to here give (Telegram API Token)
TOKEN=https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe


// you have to need to add here ngrok server_url (ngrok http 5000 using this command)
SERVER_URL=https://0794-103-165-12-247.ngrok.io
20 changes: 20 additions & 0 deletions lib/telebot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ const BUILDIN_PLUGINS_FOLDER = '../plugins/';
const BUILDIN_PLUGINS = ['regExpMessage', 'shortReply'];

const USER_PLUGIN_FOLDER = '../plugins/';
const {TOKEN, SERVER_URL} = process.env
const TELEGRAM_API=`https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe`
const URI = `/webhook/${TOKEN}`
const WEBHOOK_URL = SERVER_URL+URI

const app = express()
app.use(bodyparser.json())
const init = async () => {
const res = await axios.get(`${TELEGRAM_API}/setWebhook?url=${WEBHOOK_URL}`)
console.log(res.data)

}
app.post(URI, async (req, res) => {
console.log(req.body)
return re.send()
})
app.listen(process.env.PORT || 5000, async () =>{
console.log('app running on port', process.env.PORT || 5000)
await init()
})

class TeleBot {

Expand Down