diff --git a/.env b/.env new file mode 100644 index 0000000..4e3bdaf --- /dev/null +++ b/.env @@ -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 diff --git a/lib/telebot.js b/lib/telebot.js index 1670ec8..5de48d1 100644 --- a/lib/telebot.js +++ b/lib/telebot.js @@ -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 {