Class: Ruboty::Handlers::Fortune

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/handlers/fortune.rb

Overview

A Ruboty Handler description

Constant Summary collapse

SEIZA =
[
  { name: 'やぎ座',     eng: 'capricorn',   border: 119 },
  { name: 'みずがめ座', eng: 'aquarius',    border: 218 },
  { name: 'うお座',     eng: 'pisces',      border: 320 },
  { name: 'おひつじ座', eng: 'aries',       border: 419 },
  { name: 'おうし座',   eng: 'taurus',      border: 520 },
  { name: 'ふたご座',   eng: 'gemini',      border: 621 },
  { name: 'かに座',     eng: 'cancer',      border: 722 },
  { name: 'しし座',     eng: 'leo',         border: 822 },
  { name: 'おとめ座',   eng: 'virgo',       border: 922 },
  { name: 'てんびん座', eng: 'libra',       border: 1023 },
  { name: 'さそり座',   eng: 'scorpio',     border: 1122 },
  { name: 'いて座',     eng: 'sagittarius', border: 1221 }
]

Instance Method Summary collapse

Instance Method Details

#uranai(message) ⇒ Object

env :development, “hoge”



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ruboty/handlers/fortune.rb', line 27

def uranai(message)
  target_date_num = message.match_data[1].to_i
  str_for_date = "2000/%s/%s" % ("%04d" % target_date_num).scan(/.{2}/)
  begin
    date = Date.parse(str_for_date)
    user_seiza = get_seiza_from_date(date)
    fortune_text = get_fortune_text(user_seiza[:eng])
    message.reply("うらないます:%s(%s)\n---\n%s" % [date.strftime("%m/%d"), user_seiza[:name], fortune_text])
  rescue => e
    message.reply("ごめん、無理でした")
  end
end