CoinBot is a tiny bot for Telegram, that helps you with random decisions. It works inline and inside the chat.
Name | Command | Parameter |
---|---|---|
Flip a coin | /coin |
- |
Roll a dice | /dice |
[Sides of the dice] |
Choose from list | /list |
Item1, Item2, ... |
/coin
⇒ Tails
/dice
⇒ 5
/dice 26
⇒ 24
/list Pizza, Sushi, Burger
⇒ Sushi
Inline:
@coinbot npm, yarn
⇒ yarn
CoinBot was built with extensibility in mind. That's why it's based on the following principles and technologies:
- Based on Telegraf – A modern framework for Telegram bots.
- Commands are modular – They are split into individual files and work inside the chat & inline on the fly.
- Website updates automatically – It's built with Next.js and reads the same files the bot is using. If you add command to the bot, it will also be on the website.
After you cloned the repository to your computer, you can run it with npm run dev
*.
This command will start the bot itself AND the website on port 3000. It's also possible to start only one of them with either npm run dev:bot
or npm run dev:web
.
* You have to set the environment variable TOKEN
to your Telgram Bot Token in order for it to work. You can obtain it from the BotFather.
Same rules apply as above, but for a production environment I suggest to use npm run build
and npm start
. :bot
and :web
can also be applied on those two commands.
To get started, I would suggest to take a look at the files in the commands/
directory. Every command is described with a function
that returns an Object
.
export default query => ({
title: 'Demo',
trigger: 'demo',
enabled: true,
message: `This is a demo. Given query: ${query}`,
description: `Random item`,
parameter: 'Example',
thumb: 'list.png'
})
Key | Type | Required | Description |
---|---|---|---|
title |
String |
YES | Title/Name of the command. |
trigger |
String |
YES | The actual command to trigger it. (Without the / ) |
enabled |
Boolean |
YES | If false the command will be hidden from inline mode and return an error in chat mode. This is useful if your command only works with a certain query . |
message |
String |
YES | The result of the command. This will be returned when it runs. |
description |
String |
YES | Description for the website, /start and inline mode. |
parameter |
String |
- | Example parameter. Should be in brackets if it's optional. Will be displayed if enabled is set to false |
thumb |
String |
- | Thumbnail for inline mode and website. Image should be placed inside static/thumbs/ |