사용자의 메시지에서 정수를 가져 와서 변수 일에 넣어야합니다. 어떻게하면됩니까?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를 사용하고 있습니다. 웹 훅과 폴링을 사용하지 않습니다. – rafulin
지금까지 무엇을 가지고 계셨습니까? 어떻게 메시지를 가져 옵니까? 메시지는 어떻게 생겼습니까? 설명서를 읽었습니까? 몇 가지 코드를 보여줄 수 있습니까? – Stefan