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