A decision maker for Telegram
Clone or download
Latest commit 3e45436 Mar 26, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bot
commands
components Removed hover from website Nov 5, 2016
pages Added favicon Nov 5, 2016
static Add Rock, Paper, Scissors Mar 8, 2017
.gitignore Added `hyperlayout` to package.json Nov 15, 2016
README.md
gulpfile.babel.js Added `hyperlayout` to package.json Nov 15, 2016
package.json
yarn.lock

README.md

XO code style

CoinBot is a tiny bot for Telegram, that helps you with random decisions. It works inline and inside the chat.

Usage

Name Command Parameter
Flip a coin /coin -
Roll a dice /dice [Sides of the dice]
Choose from list /list Item1, Item2, ...

Examples

/coinTails

/dice5

/dice 2624

/list Pizza, Sushi, BurgerSushi

Inline:

@coinbot npm, yarnyarn

Development

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.

Run it locally

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.

Run it in production

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.

Writing a new command

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.

Example

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'
})

Options

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/