Created
May 3, 2018 00:18
-
-
Save igordcsouza/26c4a566a797567b5382f572961cda2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'telegram/bot' | |
require 'swgem' | |
token = '' | |
Telegram::Bot::Client.run(token) do |bot| | |
bot.listen do |message| | |
if message.text.include? ("/start") | |
bot.api.send_message(chat_id: message.chat.id, text: "How can i help u?") | |
bot.api.send_message(chat_id: message.chat.id, text: "If u need, just do /help") | |
elsif message.text.include? ("/help") | |
bot.api.send_message(chat_id: message.chat.id, text: "/movies - return the name of movies and your id number") | |
bot.api.send_message(chat_id: message.chat.id, text: "/epi {number_of_episode} - return somethings about the episode.") | |
bot.api.send_message(chat_id: message.chat.id, text: "/character {name of character}") | |
elsif message.text.include? ("/movies") | |
films = SWGEM::Films.new | |
films.all.map { |x| bot.api.send_message(chat_id: message.chat.id, text: "Episode #{x['episode_id']} -> #{x['title']}") } | |
elsif message.text.include? ("/epi") | |
film = SWGEM::Films.new | |
epi = film.by_episode(message.text.split(' ')[1].to_i) | |
bot.api.send_message(chat_id: message.chat.id, text: "Title - #{epi["title"]}") | |
bot.api.send_message(chat_id: message.chat.id, text: "Director - #{epi["director"]}") | |
bot.api.send_message(chat_id: message.chat.id, text: "Producer - #{epi["producer"]}") | |
bot.api.send_message(chat_id: message.chat.id, text: "Release Date - #{epi["release_date"]}") | |
elsif message.text.include? "/test" | |
answers = Telegram::Bot::Types::ReplyKeyboardMarkup | |
.new(keyboard: [%w(/movies /epi), %w(/help D)], one_time_keyboard: true) | |
bot.api.send_message(chat_id: message.chat.id, text: "How can i help you?", reply_markup: answers) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment