Best practics to use express with telegram-node-bot
See original GitHub issueHello! Im try to use this framework with express framework for notice users via get query from php-app. Well heres my code: `‘use strict’ const express = require(‘express’); const app = express(); app.listen(8008);
const Telegram = require('telegram-node-bot');
const TelegramBaseController = Telegram.TelegramBaseController;
const TextCommand = Telegram.TextCommand;
const tg = new Telegram.Telegram('MYTOKEN');`
So i get binded port error cause express execute many times. Some Log
Telegram Worker started at 1804 PID
[log]
Telegram Worker started at 6180 PID
[log]
Telegram Worker started at 5904 PID
[log]
Telegram Worker started at 5300 PID
events.js:160
throw er; // Unhandled 'error' event
^
Error: bind EADDRINUSE null:8008
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at cb (net.js:1324:16)
at shared (cluster.js:619:5)
at Worker.<anonymous> (cluster.js:592:9)
at process.<anonymous> (cluster.js:765:8)
at emitTwo (events.js:111:20)
at process.emit (events.js:191:7)
at process.nextTick (internal/child_process.js:744:12)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
events.js:160
throw er; // Unhandled 'error' event
^
Error: bind EADDRINUSE null:8008
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at cb (net.js:1324:16)
at shared (cluster.js:619:5)
at Worker.<anonymous> (cluster.js:592:9)
at process.<anonymous> (cluster.js:765:8)
at emitTwo (events.js:111:20)
at process.emit (events.js:191:7)
at process.nextTick (internal/child_process.js:744:12)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
What should i do for fix this issue? Thx and sorry for bad english 😃
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
How to create a Telegram bot with Node.js and Sanity
Learn how to hook up a Telegram chatbot to Sanity using Node.js in this short, snappy tutorial.
Read more >Building A Telegram Bot With NodeJS | by Manny - Medium
In our file, configure a simple output to return the data and just console log the payload in Terminal. index.js // Dependencies const...
Read more >Building your First Telegram Bot using Node.js and Telegraf
In this tutorial, you will learn how to build telegram bots using Node.js runtime environment and Telegraf library from scratch.
Read more >Building a Telegram Bot with Node.js in 10 minutes - YouTube
We are building a very basic Telegram Bot using Node.js, JavaScript and Telegram's Bot API. This tutorial will teach you to- create a ......
Read more >How To Build a Telegram Bot With Node.js in Under 3 Minutes
Telegram is a WhatsApp alternative — in my opinion, a pretty good one. It is free to use is considered very secure. But...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
`//init modules const express = require(‘express’); const port = 8888; var listener = express();
const Telegram = require(‘telegram-node-bot’) const TelegramBaseController = Telegram.TelegramBaseController const TextCommand = Telegram.TextCommand
let tg = new Telegram.Telegram(‘key’);
tg.onMaster(() => { listener.listen(port, function (){ console.log('Your app runing on '+port); });
});`
Like this
Yes i have, u need to use express init in $.onMaster callback