2015-08-01 17:57:21 +02:00
|
|
|
// An example for OpenShift platform.
|
2015-06-30 01:09:28 +02:00
|
|
|
var TelegramBot = require('node-telegram-bot-api');
|
|
|
|
|
|
|
|
var token = 'YOUR_TELEGRAM_BOT_TOKEN';
|
2015-08-01 17:57:21 +02:00
|
|
|
// See https://developers.openshift.com/en/node-js-environment-variables.html
|
2015-06-30 01:09:28 +02:00
|
|
|
var port = process.env.OPENSHIFT_NODEJS_PORT;
|
|
|
|
var host = process.env.OPENSHIFT_NODEJS_IP;
|
2015-08-01 17:57:21 +02:00
|
|
|
var domain = process.env.OPENSHIFT_APP_DNS;
|
2015-06-30 01:09:28 +02:00
|
|
|
|
|
|
|
var bot = new TelegramBot(token, {webHook: {port: port, host: host}});
|
2015-08-01 17:57:21 +02:00
|
|
|
// OpenShift enroutes :443 request to OPENSHIFT_NODEJS_PORT
|
|
|
|
bot.setWebHook(domain+':443/bot'+token);
|
2015-06-30 01:09:28 +02:00
|
|
|
bot.on('message', function (msg) {
|
|
|
|
var chatId = msg.chat.id;
|
|
|
|
bot.sendMessage(chatId, "I'm alive!");
|
|
|
|
});
|