mruby-tbot

Build Status License MRuby Version

MRuby wrapper for Telegram’s Bot API.

Install by mrbgems

  • add conf.gem line to build_config.rb

“by MRuby::Build.new do |conf| conf.gem :mgem => ‘mruby-tbot’ end

Example

“by bot = TBot::Bot.new(telegram_token)

bot.get_bot_data # return bot info

bot.response # last request response

bot.messages do |msg| msg.class # => Hash

# custom keyboard for Reply Markup keyboard = [Hello!, Bye!, Exit, Docs] #=> Array

# ReplyKeyboardMarkup reply_markup = { keyboard: keyboard, resize_keyboard: true, one_time_keyboard: true, selective: true }

# Send Message bot.message(msg, { text: ‘text message’, reply_markup: reply_markup }) # => Hash response end

Send Document

“by bot.document(message, { document: File.open(‘document.doc’,‘rb’) })

Send Photo

“by bot.photo(message, { photo: File.open(‘photo.jpeg’,‘rb’) })

Send Sticker

“by bot.sticker(message, { sticker: File.open(‘sticker.png’,‘rb’) })

Send Audio

“by bot.audio(message, { sticker: File.open(‘audio.mp3’,‘rb’) })

Send Voice

“by bot.voice(message, { sticker: File.open(‘voice.mp3’,‘rb’) })

Send location

“by bot.location(message, { latitude: 54.44, longitude: 80.0 })

Send Venue

“by bot.venue(message, { latitude: 50.00, longitude: 80.0, title: “Name”, address: “Address” })

Send Contact

“by bot.contact(message, { phone_number: “+123456789010”, first_name: “Name”, last_name: “Test” })

Send Chat Action

“by bot.chat_action(message, { action: “typing” })

License

Under the MIT License: - see LICENSE file