npm install gramscript
npm i gramscript
yarn add gramscript
Creating custom bot Object
const TeleBot = require('gramscript');
const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
// bot's script here
bot.start();
const TeleBot = require('gramscript');
const bot = new TeleBot('123yuio456pasd678fghWqaz');
// bot command
bot.on('/hello', (msg) => {
return bot.sendMessage(msg.from.id, `Hello, ${ msg.from.first_name }!`);
});
// if user send message text , bot will forward same content
bot.on('text', (msg) => msg.reply.text(msg.text));
// if user send sticker, bot will forwad same sticker
bot.on('sticker', (msg) => {
return msg.reply.sticker('http://i.imgur.com/VRYdhuD.png', { asReply: true });
});
// also work with multiple events
bot.on(['/start', 'audio', 'sticker'], msg => {
return bot.sendMessage(msg.from.id, 'Bam!');
});
bot.start();