Do you know Telegram Messenger ?
If yes, You maybe want to create your own Telegram bots on it ;>
Don’t worry, Creating Telegram Bots is Legal.
You can also host it at glitch. Why no man?
First, Prepare these Modules:
-
Telegraf
Yes, Only this package that you need, son.
Second, Create your First bot.
-
Go to @botfather bot, Tap /start at Bottom, Then send
/newbot
, Then setup your bots like these screenshot below:
-
Copy your Bot Token, and SHHHHH! Keep your bot token secret, Friend
-
In Glitch, Create a NodeJS Project, then install
telegraf
package. -
Copy these code and Paste it at your main file:
//Load modules
const telegraf = require('telegraf')
//Create a Bot
const bot = new telegraf('<BOT TOKEN HERE>')
//Do something when start command was executed
bot.start(ctx => {
//Yes, you need callback son.
//Send a message when /start command has executed
ctx.reply('Hello, Human!');
})
//Launch the bot
bot.launch().then(() => {
console.log("Logged as "+bot.context.botInfo.first_name)
//If it's shows your bot name, Then try execute /start Command, Enjoy!
});
Hohoho! You think Only that? No dude, You can create another command:
//Create '/hello' command Trigger
bot.command('hello', ctx => {
//There's no need slash.
//Reply when /hello command was executed
ctx.reply('Huzzah!');
})
Read the full docs of telegraf here
Need help for your Discord or Telegram bot? Feel free mention me at here / some post
Find me at Telegram: https://t.me/yonle
My Telegraf.js Bot: https://t.me/raining_robot