Project

rubydium

0.0
The project is in a healthy, maintained state
An OO framework for building Telegram bots. That's the plan, at least.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

What it is

Rubydium is a framework for building Telegram bots. Built on top of telegram-bot-ruby API wrapper, it aims to provide tools for building your bots with minimum boilerplate.

It's far from being done, but all the code in the examples directory is functional and mostly covered with specs.

Installation

CLI tool for creating and setting up new projects is planned. For now:

  1. Create your project: mkdir example_bot && cd example_bot
  2. Install the gem:
  • Add this gem to the Gemfile: bundle init && echo 'gem "rubydium"' >> Gemfile bundle install
  • Or install system-wide: gem install rubydium
  1. Create your main file: touch example_bot.rb
  2. See the examples directory for bot examples.

Configuring the bot

There's two main ways to write your config. With a block:

ExampleBot.configure do |config|
  config.token = "1234567890:long_alphanumeric_string_goes_here"
  config.bot_username = "ends_with_bot"
  config.owner_username = "thats_you"
  config.privileged_usernames = %w[
    your_friend your_chat_moderator
  ]
end

Or with a hash:

ExampleBot.config = {
  token: "1234567890:long_alphanumeric_string_goes_here",
  bot_username: "ends_with_bot",
  owner_username: "thats_you",
  privileged_usernames: %w[
    your_friend your_chat_moderator
  ]
}

The hash variant also means you can pass in any valid Ruby hash, regardless of where it comes from. For example, you can set the same values, if you parse

a JSON file:

example_bot/config.json:

{
  "token": "1234567890:long_alphanumeric_string_goes_here",
  "bot_username": "ends_with_bot",
  "owner_username": "thats_you",
  "privileged_usernames": [
    "your_friend",
    "your_chat_moderator"
  ]
}

example_bot/example_bot.rb:

require "json"
ExampleBot.config = JSON.load_file("./config.json")
or a YAML:

example_bot/config.yaml

token: 1234567890:long_alphanumeric_string_goes_here
bot_username: ends_with_bot
owner_username: thats_you
privileged_usernames:
- your_friend
- your_chat_moderator

example_bot/example_bot.rb:

require "yaml"
ExampleBot.config = YAML.load_file("./config.yaml")