Skip to content

Instantly share code, notes, and snippets.

@aspick
Last active August 29, 2015 14:02
Show Gist options
  • Save aspick/233b1dfff99eb380d0c8 to your computer and use it in GitHub Desktop.
Save aspick/233b1dfff99eb380d0c8 to your computer and use it in GitHub Desktop.
Gem::Specification.new do |spec|
spec.name = "ruboty-doma"
spec.version = "0.0.1"
spec.authors = ["aspick"]
spec.email = ["info@aspick.net"]
spec.summary = "ruboty plugin"
spec.files = ["ruboty-doma.rb"]
spec.require_path = "."
end
module Ruboty
module Handlers
class Doma < Base
on(
/おっしー!*\z/,
name: "oshibori",
description: "Return ぼりぼり! to おっしー"
)
on(
/(にんにく|ニンニク)/,
name: "ninniku",
description: "にんにくは : 多い方がいい"
)
on(
/次の練習/,
name: "next_rehearsal",
description: "Return next rehearsal event info"
)
def oshibori(message)
message.reply("ぼりぼり!")
end
def ninniku(message)
message.reply("ニンニクは多い方がいい!!")
end
def next_rehearsal(message)
url = URI.parse(ENV['EVENTS_SOURCE_URL'])
res = Net::HTTP.get url.host, url.path
events = JSON.parse(res)
events.each do |event|
if event['subject'].index('練習')
if event['date']
date = DateTime.parse(event['date']).new_offset(Rational(9,24)).strftime("%m/%d")
else
date = DateTime.parse(event['start_at']).new_offset(Rational(9,24)).strftime("%m/%d %H:%M")
end
text = "#{date} #{event['subject']}@#{event['location']} です"
message.reply(text)
return
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment