mruby-tbot
MRuby wrapper for Telegram's Bot API.
Install by mrbgems
- add conf.gem line to
build_config.rb
MRuby::Build.new do |conf|
conf.gem :mgem => 'mruby-tbot'
end
Example
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
bot.document(message, { document: File.open('document.doc','rb') })
Send Photo
bot.photo(message, { photo: File.open('photo.jpeg','rb') })
Send Sticker
bot.sticker(message, { sticker: File.open('sticker.png','rb') })
Send Audio
bot.audio(message, { sticker: File.open('audio.mp3','rb') })
Send Voice
bot.voice(message, { sticker: File.open('voice.mp3','rb') })
Send location
bot.location(message, { latitude: 54.44, longitude: 80.0 })
Send Venue
bot.venue(message, { latitude: 50.00, longitude: 80.0, title: "Name", address: "Address" })
Send Contact
bot.contact(message, { phone_number: "+123456789010", first_name: "Name", last_name: "Test" })
Send Chat Action
bot.chat_action(message, { action: "typing" })
License
Under the MIT License:
- see LICENSE file