All Projects → greyblake → telebot

greyblake / telebot

Licence: MIT license
Ruby client for Telegram bot API

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Telebot

Build Status

Ruby client for Telegram's Bot API.

Demo bot that demonstrates API calls: http://telegram.me/demoTelebot

Installation

Add this line to your application's Gemfile:

gem 'telebot'

Run

$ gem install telebot

Usage

Minimal example, that repeats a message, would look like this:

bot = Telebot::Bot.new(TOKEN)

bot.run do |client, message|
  reply = "You've said: #{message.text}"
  client.send_message(chat_id: message.chat.id, text: reply)
end

Please check out full featured example as well: demo.rb.

Using pure client

client = Telebot::Client.new(TOKEN)

# Perform getMe call
client.get_me
# =>
# #<Telebot::User:0x0000000111f688
#  @first_name="Telebot Demo",
#  @id=97445105,
#  @last_name=nil,
#  @username="demoTelebot">

# Send message to chat with id=12345
client.send_message(chat_id: 12345, text: "Hello there!")

The client supports all Telegram's Bot API methods.

For more information check the documentation for Telebot::Client and demo.rb.

Running demo

Clone the repo and run demo example to see how you can use Telegram's Bot API.

git clone /github.com/greyblake/telebot
cd telebot
bundle install

TOKEN=<YOUR_TOKEN> ruby ./examples/demo.rb

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].