ircbot.rb

Path: lib/rbot/ircbot.rb
Last Update: Sun Jun 27 10:21:56 +0200 2010
BasicUserMessage JoinMessage NamesMessage WhoisMessage ModeChangeMessage KickMessage MotdMessage QuitMessage BanlistMessage UserMessage NoSuchTargetMessage TopicMessage NickMessage WelcomeMessage UnknownMessage InviteMessage PartMessage NetmaskList UserList ArrayOf ChannelList Netmask User\n[lib/rbot/botuser.rb\nlib/rbot/irc.rb] Channel Singleton RfcCasemap StrictRfcCasemap AsciiCasemap Casemap PrivMessage NoticeMessage TokyoCabinet::BDB CIBDB Btree CIBtree Socket MessageQueue QueueRing Client DBHash\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] DBTree\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] Server NetmaskDb Bot\n[lib/rbot/botuser.rb\nlib/rbot/config.rb\nlib/rbot/ircbot.rb\nlib/rbot/language.rb\nlib/rbot/message.rb\nlib/rbot/messagemapper.rb\nlib/rbot/plugins.rb\nlib/rbot/rbotconfig.rb\nlib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] ServerError Exception RuntimeError lib/rbot/ircsocket.rb lib/rbot/rfc2812.rb lib/rbot/registry/tc.rb lib/rbot/irc.rb lib/rbot/maskdb.rb lib/rbot/message.rb lib/rbot/messagemapper.rb lib/rbot/botuser.rb lib/rbot/registry/tc.rb (null) BotConfig PKGConfig ServerOrCasemap Irc dot/f_31.png

Required files

thread   etc   fileutils   logger   pp   rbot/rbotconfig   rubygems   rbot/load-gettext   rbot/config   rbot/config-compat   rbot/irc   rbot/rfc2812   rbot/ircsocket   rbot/botuser   rbot/timer   rbot/plugins   rbot/message   rbot/language   rbot/registry/bdb   rbot/registry/tc  

Methods

Public Instance methods

[Source]

     # File lib/rbot/ircbot.rb, line 107
107: def debug(message=nil, who_pos=1)
108:   rawlog(Logger::Severity::DEBUG, message, who_pos)
109: end

[Source]

     # File lib/rbot/ircbot.rb, line 119
119: def error(message=nil, who_pos=1)
120:   rawlog(Logger::Severity::ERROR, message, who_pos)
121: end

[Source]

     # File lib/rbot/ircbot.rb, line 123
123: def fatal(message=nil, who_pos=1)
124:   rawlog(Logger::Severity::FATAL, message, who_pos)
125: end

[Source]

    # File lib/rbot/ircbot.rb, line 72
72: def halt_logger
73:   if $log_thread && $log_thread.alive?
74:     $log_queue << nil
75:     $log_thread.join
76:     $log_thread = nil
77:   end
78: end

[Source]

     # File lib/rbot/ircbot.rb, line 111
111: def log(message=nil, who_pos=1)
112:   rawlog(Logger::Severity::INFO, message, who_pos)
113: end

[Source]

     # File lib/rbot/ircbot.rb, line 102
102: def log_session_end
103:   $logger << "\n\n=== #{botclass} session ended on #{Time.now.strftime($dateformat)} ===\n\n"
104:   $log_queue << nil
105: end

[Source]

     # File lib/rbot/ircbot.rb, line 97
 97: def log_session_start
 98:   $logger << "\n\n=== #{botclass} session started on #{Time.now.strftime($dateformat)} ===\n\n"
 99:   restart_logger
100: end

[Source]

    # File lib/rbot/ircbot.rb, line 27
27:   def pretty_inspect
28:     PP.pp(self, '')
29:   end

[Source]

    # File lib/rbot/ircbot.rb, line 47
47: def rawlog(level, message=nil, who_pos=1)
48:   call_stack = caller
49:   if call_stack.length > who_pos
50:     who = call_stack[who_pos].sub(%r{(?:.+)/([^/]+):(\d+)(:in .*)?}) { "#{$1}:#{$2}#{$3}" }
51:   else
52:     who = "(unknown)"
53:   end
54:   # Output each line. To distinguish between separate messages and multi-line
55:   # messages originating at the same time, we blank #{who} after the first message
56:   # is output.
57:   # Also, we output strings as-is but for other objects we use pretty_inspect
58:   case message
59:   when String
60:     str = message
61:   else
62:     str = message.pretty_inspect
63:   end
64:   qmsg = Array.new
65:   str.each_line { |l|
66:     qmsg.push [level, l.chomp, who]
67:     who = ' ' * who.size
68:   }
69:   $log_queue.push qmsg
70: end

[Source]

    # File lib/rbot/ircbot.rb, line 82
82: def restart_logger(newlogger = false)
83:   halt_logger
84: 
85:   $logger = newlogger if newlogger
86: 
87:   $log_thread = Thread.new do
88:     ls = nil
89:     while ls = $log_queue.pop
90:       ls.each { |l| $logger.add(*l) }
91:     end
92:   end
93: end

[Source]

     # File lib/rbot/ircbot.rb, line 115
115: def warning(message=nil, who_pos=1)
116:   rawlog(Logger::Severity::WARN, message, who_pos)
117: end

[Validate]