Skip to content

Instantly share code, notes, and snippets.

@yurist38
Created March 3, 2018 16:35
Show Gist options
  • Save yurist38/0ee8e0852542d8a9c5ea298934eb887b to your computer and use it in GitHub Desktop.
Save yurist38/0ee8e0852542d8a9c5ea298934eb887b to your computer and use it in GitHub Desktop.
Telegram Bot - converter text into ASCII text
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);
@mdfkzz
Copy link

mdfkzz commented Mar 15, 2018

const Botgram = require('botgram');

@mdfkzz
Copy link

mdfkzz commented Mar 15, 2018

const { TELEGRAM_BOT_TOKEN } = process.env;

@mdfkzz
Copy link

mdfkzz commented Mar 15, 2018

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