Created
March 3, 2018 16:35
-
-
Save yurist38/0ee8e0852542d8a9c5ea298934eb887b to your computer and use it in GitHub Desktop.
Telegram Bot - converter text into ASCII text
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 Botgram = require('botgram'); | |
const figlet = require('figlet'); | |
const { TELEGRAM_BOT_TOKEN } = process.env; | |
if (!TELEGRAM_BOT_TOKEN) { | |
console.error('Seems like you forgot to pass Telegram Bot Token. I can not proceed...'); | |
process.exit(1); | |
} | |
const bot = new Botgram(TELEGRAM_BOT_TOKEN); | |
function onMessage(msg, reply) { | |
figlet(msg.text, (err, data) => { | |
if (err) { | |
reply.text('An error occured. Probably text format is not correct.').then(); | |
return; | |
} | |
const markdownResult = `${'```\n'}${data}${'\n```'}`; | |
reply.markdown(markdownResult).then(); | |
}); | |
} | |
bot.text(onMessage); |
const Botgram = require('botgram');
const { TELEGRAM_BOT_TOKEN } = process.env;
const bot = new Botgram(TELEGRAM_BOT_TOKEN);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$> TELEGRAM_BOT_TOKEN=”” node index.js