私はユーザーのメッセージから整数を取得し、それを可変日に置く必要があります。 どうすればいいですか?Ruby Telegram bot - ユーザーメッセージからテキストを取得し、それを変数に入れる方法は?
ここでのコードのビットです:
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
case message.text
when '/start'
bot.api.sendMessage(chat_id: message.chat.id, text: "Привет, #{message.from.first_name}. Чтобы узнать сегодняшнее расписание, напишите /today")
when '/today'
bot.api.sendMessage(chat_id: message.chat.id, text: "#{date}")
if discipline1_name.size == 0 && discipline2_name.size == 0 && discipline3_name.size == 0 && discipline4_name.size == 0 && discipline5_name.size == 0 && discipline6_name.size == 0 then
(bot.api.sendMessage(chat_id: message.chat.id, text: "Сегодня воскресенье, можете отдыхать :)")
bot.api.sendMessage(chat_id: message.chat.id, text: "Чтобы узнать расписание на другой день, введите дату в формате /13 (13 - день)."))
else
unless discipline1_name.size == 0
bot.api.sendMessage(chat_id: message.chat.id, text: "1. #{discipline1_name} в кабинете #{discipline1_cab}")
else
bot.api.sendMessage(chat_id: message.chat.id, text: "1. ===========")
end
、それがdiscipline2のためにダウンしたことを好きで、3、...私は必要なもの6
はこのようなものです:
when '#{message}'
day = message.to_i
page = Nokogiri::HTML(open("http://rating.ivpek.ru/timetable/timetable/show?gid=222&date=2017-10-#{day}"))
は、しかしそれは動作しません
質問を補完できますか?どのライブラリを使用していますか?ウェブフックやポーリングを使用していますか? –
私はtelegram-bot-ruby-0.8.4 libを使用しています。私はwebhooksとポーリングを使用しません。 – rafulin
あなたはこれまで何を持っていますか?あなたはどのようにメッセージを取得しますか?メッセージはどのように見えるのですか?あなたはその文書を読んだことがありますか?いくつかのコードを表示できますか? – Stefan