π€ A Telegram bot for Sunway Tech Club operations
As Sunway Tech Club uses Telegram as it's main communication channel, it went harder and harder to manage all the groups and channels, hence, a bot that helps to manage and even generate quick video meeting link is becoming more important.
Why not using Slack? Well, because building a telegram bot sounds cooler π.
Bots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats. These accounts serve as an interface for code running somewhere on your server.
This bot uses Telegraf as a wrapper to the telegram core API to ease out and smoothen the development process.
The backend: π€© Google Sheets as Backend!
To use the bot, go to:
https://t.me/sunwaytechclub_bot
and type
/start
This program is written in javascript, hence Node.js is required.
Simply run
npm i
To create new command:
- Create a new JavaScript file in
/commands
folder, the script will detect the file and build the endpoint based on the file name - write a function with
ctx
as argument, and export the function. an example is as shown below:
function test(ctx) {
ctx.reply("Hello world!");
}
module.exports = test;
to get the bot object
let bot = global.Bot;
- And you are good to go! Simply create a new bot from the @BotFather, create a file called
.env
at the root level and write
BOT_TOKEN=<YOUR BOT TOKEN>
- Now, you may start the development server by runnign
npm run dev
...tbc tutorial on integrating spreadsheet (or you may checkout this https://developers.google.com/sheets/api/quickstart/nodejs)
- Telegraf - Telegram API wrapper
- pupubird - The lonely programmer
See also the list of contributors who participated in this project.
- Kudos on Mark Tan on his comprehensive Udemy course