# -*- mode: ruby; -*- #=begin header #Omikuji - Fortuneteller agent # # $Author: knu $ # $Date: 2001/01/31 15:31:07 $ # # Copyright (C) 1998-2000 Hiroshi IGARASHI #=end agent = IRC::PassiveAgent::new("Fortuneteller") class << agent def start(client) super end def stop super end def notifyMessage(message) #p(message) case message.command when CMD_PRIVMSG #putlog("debug", "recieved PRIVMSG.") #putlog("debug", message.str) if message.trailing =~ /^(?:\s|กก)*(?:Fortune|Omikuji)\s*(.+)?$/ from = $1 ? $1 : User::parse(message.prefix).nick to = message.params[0] to = from if !to.nil? and to == @client.nick do_omikuji(from, to) end end end private def do_omikuji(from, to) #=begin #from:String - Consultee #to:String - Recipient #=end privmsg("Consulting an oracle.", to) action("reads #{from}'s fortune...", to) sleep(3) srand result = case rand(5) when 0 "Best Luck!!!" when 1 "Good Luck!!" when 2 "Not Much Luck!" when 3 "Bad Luck!" when 4 "Worst Luck!!" end privmsg("#{from}: #{result}", to) end end agent