Skip to content

Instantly share code, notes, and snippets.

Created July 6, 2015 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/71857a3ac67bb0daef7b to your computer and use it in GitHub Desktop.
Save anonymous/71857a3ac67bb0daef7b to your computer and use it in GitHub Desktop.
mods = engine.get_mod(id)
mods.each do |key, value|
lp_size = value[0]["lecture_periods"].size
for i in 0...lp_size do
days_match = value[0]["lecture_periods"][i].to_s.match day_of_week_regex
puts "#{value[0]["module_code"]} : #{value[0]["class_no"]} #{value[0]["tutorial_periods"]} #{days_match}"
if days_match.to_s.eql?(day_today) || days_match == day_today
if value[0]["day_text"].eql?(day_today) || value[0]["lesson_type"][0, 3].upcase.eql?("LEC") || value[0]["lesson_type"][0, 3].upcase.eql?("SEM")
formatted = "#{value[0]["module_code"]} - #{value[0]["module_title"]}\n[#{value[0]["lesson_type"][0, 3].upcase}][#{value[0]["class_no"]}]: #{value[0]["lecture_periods"]}\n#{value[0]["start_time"]} - #{value[0]["end_time"]} @ #{value[0]["venue"]}"
bot.send_message(chat_id: message.chat.id, text: "#{formatted}")
end
elsif value[0]["day_text"].eql?(day_today) || value[0]["lesson_type"][0, 3].upcase.eql?("TUT")
tp_size = value[0]["tutorial_periods"].size
for j in 0...tp_size do
tuts_match = value[0]["tutorial_periods"][i].to_s.match day_of_week_regex
if tuts_match.to_s.eql?(day_today) || tuts_match == day_today
formatted = "#{value[0]["module_code"]} - #{value[0]["module_title"]}\n[#{value[0]["lesson_type"][0, 3].upcase}][#{value[0]["class_no"]}]: #{value[0]["tutorial_periods"][i]}\n#{value[0]["start_time"]} - #{value[0]["end_time"]} @ #{value[0]["venue"]}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment