79 # we (<source>) sent a notice with message <data> to <channel> |
79 # we (<source>) sent a notice with message <data> to <channel> |
80 ('SELF_NOTICE', 0x51), |
80 ('SELF_NOTICE', 0x51), |
81 |
81 |
82 # we (<source>) changed nickname to <target> |
82 # we (<source>) changed nickname to <target> |
83 ('SELF_NICK', 0x52), |
83 ('SELF_NICK', 0x52), |
|
84 |
|
85 ## slightly weirder bits |
|
86 # netsplit between <source_hostname> and <target_hostname>, <data> is a space-separated list of <chanflags><nickname>s affected |
|
87 # the last item in the list of nicknames may also be of the form "+<count>", where count is the number of additional, but hidden, nicknames affected |
|
88 ('NETSPLIT_START', 0x61), |
|
89 |
|
90 # netsplit over, <data> is a list of users affected, see NETSPLIT_START |
|
91 ('NETSPLIT_END', 0x062), |
84 ] |
92 ] |
85 |
93 |
86 @classmethod |
94 @classmethod |
87 def name_from_code (cls, code) : |
95 def name_from_code (cls, code) : |
88 """ |
96 """ |
92 return dict((type, name) for name, type in cls.LIST)[code] |
100 return dict((type, name) for name, type in cls.LIST)[code] |
93 |
101 |
94 # apply as attributes |
102 # apply as attributes |
95 for name, code in LogTypes.LIST : |
103 for name, code in LogTypes.LIST : |
96 setattr(LogTypes, name, code) |
104 setattr(LogTypes, name, code) |
|
105 |
|
106 # masks |
|
107 LogTypes._NETSPLIT_MASK = 0x60 |
97 |
108 |
98 class LogLine (object) : |
109 class LogLine (object) : |
99 """ |
110 """ |
100 An event on some specific channel |
111 An event on some specific channel |
101 """ |
112 """ |
155 nick if nick else '', |
166 nick if nick else '', |
156 '!' + user if user else '', |
167 '!' + user if user else '', |
157 '@' + host if host else '' |
168 '@' + host if host else '' |
158 ) |
169 ) |
159 |
170 |
160 def __str__ (self) : |
171 def __unicode__ (self) : |
161 return '\t'.join(( |
172 return '\t'.join(( |
162 self.channel.name, |
173 self.channel.name, |
163 str(self.offset), |
174 str(self.offset), |
164 self.format_type(), |
175 self.format_type(), |
165 str(self.timestamp), |
176 str(self.timestamp), |
166 self.format_source(), |
177 self.format_source(), |
167 str(self.target), |
178 str(self.target), |
168 str(self.data) |
179 unicode(self.data) |
169 )) |
180 )) |
170 |
181 |
171 def __repr__ (self) : |
182 def __repr__ (self) : |
172 return "LogLine(%r, %s, %-12s, %s, %-35s, %-10s, %r)" % ( |
183 return "LogLine(%r, %s, %-12s, %s, %-35s, %-10s, %r)" % ( |
173 self.channel, self.offset, self.format_type(), self.timestamp, self.format_source(), self.target, self.data |
184 self.channel, self.offset, self.format_type(), self.timestamp, self.format_source(), self.target, self.data |