Merge lp:~stefanor/ibid/translation-334764 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Merged at revision: 565
Proposed branch: lp:~stefanor/ibid/translation-334764
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/translation-334764
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+4287@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

My take on https://code.edge.launchpad.net/~bradwhittington/ibid/translation/+merge/3962

While I was at it, I tweaked a few responses.

Note, if you want to call addresponse with an arbitrary string, you now have to use addresponse(u'%s', string). We could work around this, by checking if len(attrs) > 0, but I think the way it is will promote good response style.

Also note, addresponse will only format unicode strings. Again, we could work around this, but I don't know if that's necessary.

Revision history for this message
Michael Gorven (mgorven) :
review: Approve
lp:~stefanor/ibid/translation-334764 updated
566. By Stefano Rivera

Unicode errors

567. By Stefano Rivera

OT: No memos response

568. By Stefano Rivera

OT: Unicode

Revision history for this message
Stefano Rivera (stefanor) wrote :

"Note, if you want to call addresponse with an arbitrary string, you now have to use addresponse(u'%s', string). We could work around this, by checking if len(attrs) > 0, but I think the way it is will promote good response style."

I'm having second thoughts about this:

I often forget to type the u. It's really naughty, and I should be punished, but the result is that the bot says something like "tumbleweed: Sorry, I don't know about a currency called %s", rather than doing the right thing and logging a warning. What do we prefer to do?

Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/event.py'
2--- ibid/event.py 2009-02-23 20:29:44 +0000
3+++ ibid/event.py 2009-03-08 10:57:45 +0000
4@@ -14,8 +14,11 @@
5 def __setattr__(self, name, value):
6 self[name] = value
7
8- def addresponse(self, response, processed=True):
9- self.responses.append(response)
10+ def addresponse(self, response, params={}, processed=True):
11+ if isinstance(response, unicode):
12+ self.responses.append(response % params)
13+ else:
14+ self.responses.append(response)
15
16 if processed:
17 self.processed = True
18
19=== modified file 'ibid/plugins/admin.py'
20--- ibid/plugins/admin.py 2009-03-02 09:21:35 +0000
21+++ ibid/plugins/admin.py 2009-03-08 13:16:28 +0000
22@@ -17,7 +17,7 @@
23 if processor.name not in plugins:
24 plugins.append(processor.name)
25
26- event.addresponse(', '.join(plugins))
27+ event.addresponse(u'Plugins: %s', u', '.join(sorted(plugins)))
28
29 help['core'] = u'Reloads core modules.'
30 class ReloadCoreModules(Processor):
31@@ -36,7 +36,7 @@
32 else:
33 result = getattr(ibid.reloader, 'reload_%s' % module)()
34
35- event.addresponse(result and u'%s reloaded' % module or u"Couldn't reload %s" % module)
36+ event.addresponse(result and u'%s reloaded' or u"Couldn't reload %s", module)
37
38 class LoadModules(Processor):
39 u"""(load|unload|reload) <plugin|processor>"""
40@@ -49,13 +49,13 @@
41 def load(self, event, plugin):
42 result = ibid.reloader.unload_processor(plugin)
43 result = ibid.reloader.load_processor(plugin)
44- event.addresponse(result and u'%s reloaded' % plugin or u"Couldn't reload %s" % plugin)
45+ event.addresponse(result and u'%s reloaded' or u"Couldn't reload %s", plugin)
46
47 @match(r'^unload\s+(\S+)$')
48 @authorise
49 def unload(self, event, plugin):
50 result = ibid.reloader.unload_processor(plugin)
51- event.addresponse(result and u'%s unloaded' % plugin or u"Couldn't unload %s" % plugin)
52+ event.addresponse(result and u'%s unloaded' or u"Couldn't unload %s", plugin)
53
54 help['die'] = u'Terminates the bot'
55 class Die(Processor):
56
57=== modified file 'ibid/plugins/apt.py'
58--- ibid/plugins/apt.py 2009-03-02 09:38:47 +0000
59+++ ibid/plugins/apt.py 2009-03-08 13:16:28 +0000
60@@ -29,7 +29,7 @@
61
62 for word in self.bad_search_strings:
63 if word in term:
64- event.addresponse(u"I can't tell you about my host system. Sorry.")
65+ event.addresponse(u"I can't tell you about my host system. Sorry")
66 return False
67
68 if term.strip().startswith("-"):
69@@ -52,14 +52,17 @@
70 if output:
71 output = unicode_output(output.strip())
72 output = [line.strip() for line in output.splitlines()]
73- event.addresponse(u"Found %i packages: %s" % (len(output), u', '.join(output)))
74+ event.addresponse(u'Found %(num)i packages: %(names)s', {
75+ 'num': len(output),
76+ 'names': u', '.join(output),
77+ })
78 else:
79 event.addresponse(u'No packages found')
80 else:
81 error = unicode_output(error.strip())
82 if error.startswith(u"E: "):
83 error = error[3:]
84- event.addresponse(u"Couldn't search: %s" % error)
85+ event.addresponse(u"Couldn't search: %s", error)
86
87 @match(r'(?:apt|aptitude|apt-get)\s+show\s+(.+)$')
88 def show(self, event, term):
89@@ -73,27 +76,30 @@
90
91 if code == 0:
92 description = None
93+ provided = None
94 output = unicode_output(output)
95 for line in output.splitlines():
96 if not description:
97 if line.startswith(u'Description:'):
98 description = u'%s:' % line.split(None, 1)[1]
99 elif line.startswith(u'Provided by:'):
100- description = u'Virtual package provided by %s' % line.split(None, 2)[2]
101+ provided = line.split(None, 2)[2]
102 elif line != "":
103 description += u' ' + line.strip()
104 else:
105 # More than one package listed
106 break
107- if description:
108- event.addresponse(description)
109+ if provided:
110+ event.addresponse(u'Virtual package provided by %s', provided)
111+ elif description:
112+ event.addresponse(u'%s', description)
113 else:
114 raise Exception("We couldn't successfully parse aptitude's output")
115 else:
116 error = unicode_output(error.strip())
117 if error.startswith(u"E: "):
118 error = error[3:]
119- event.addresponse(u"Couldn't find package: %s" % error)
120+ event.addresponse(u"Couldn't find package: %s", error)
121
122 help['apt-file'] = u'Searches for packages containing the specified file'
123 class AptFile(Processor):
124@@ -116,13 +122,16 @@
125 if output:
126 output = unicode_output(output.strip())
127 output = [line.split(u':')[0] for line in output.splitlines()]
128- event.addresponse(u"Found %i packages: %s" % (len(output), u', '.join(output)))
129+ event.addresponse(u'Found %(num)i packages: %(names)s', {
130+ 'num': len(output),
131+ 'names': u', '.join(output),
132+ })
133 else:
134- event.addresponse(u'No packages found.')
135+ event.addresponse(u'No packages found')
136 else:
137 error = unicode_output(error.strip())
138 if u"The cache directory is empty." in error:
139- event.addresponse(u'Search error: apt-file cache empty.')
140+ event.addresponse(u'Search error: apt-file cache empty')
141 else:
142 event.addresponse(u'Search error')
143 raise Exception("apt-file: %s" % error)
144
145=== modified file 'ibid/plugins/auth.py'
146--- ibid/plugins/auth.py 2009-03-01 23:01:30 +0000
147+++ ibid/plugins/auth.py 2009-03-08 13:16:28 +0000
148@@ -36,7 +36,7 @@
149 return
150 account = session.query(Account).filter_by(username=user).first()
151 if not account:
152- event.addresponse(u"I don't know who %s is" % user)
153+ event.addresponse(u"I don't know who %s is", user)
154 session.close()
155 return
156
157@@ -55,7 +55,7 @@
158 log.info(u"Added %s credential %s for account %s (%s) on %s by account %s", method, credential.credential, account.id, account.username, source, event.account)
159 session.close()
160
161- event.addresponse(u'Okay')
162+ event.addresponse(True)
163
164 permission_values = {'no': '-', 'yes': '+', 'auth': ''}
165 class Permissions(Processor):
166@@ -73,7 +73,7 @@
167 session = ibid.databases.ibid()
168 account = session.query(Account).filter_by(username=username).first()
169 if not account:
170- event.addresponse(u"I don't know who %s is" % username)
171+ event.addresponse(u"I don't know who %s is", username)
172 session.close()
173 return
174
175@@ -82,7 +82,7 @@
176 if permission:
177 session.delete(permission)
178 else:
179- event.addresponse(u"%s doesn't have that permission anyway" % username)
180+ event.addresponse(u"%s doesn't have that permission anyway", username)
181 return
182
183 else:
184@@ -97,7 +97,11 @@
185 value = 'yes'
186
187 if permission.value == value:
188- event.addresponse(u"%s permission for %s is already %s" % (name, username, value))
189+ event.addresponse(u'%(permission)s permission for %(user)s is already %(value)s', {
190+ 'permission': name,
191+ 'user': username,
192+ 'value': value,
193+ })
194 return
195
196 permission.value = value
197@@ -122,10 +126,11 @@
198 return
199 account = session.query(Account).filter_by(username=username).first()
200 if not account:
201- event.addresponse(u"I don't know who %s is" % username)
202+ event.addresponse(u"I don't know who %s is", username)
203 return
204
205- event.addresponse(', '.join(['%s%s' % (permission_values[perm.value], perm.name) for perm in account.permissions]))
206+ permissions = sorted(u'%s%s' % (permission_values[perm.value], perm.name) for perm in account.permissions)
207+ event.addresponse(u'Permissions: %s', u', '.join(permissions))
208
209 @match(r'^list\s+permissions$')
210 def list_permissions(self, event):
211@@ -138,7 +143,7 @@
212 if permission not in permissions:
213 permissions.append(permission)
214
215- event.addresponse(', '.join(permissions))
216+ event.addresponse(u'Permissions: %s', u', '.join(sorted(permissions)))
217
218 class Auth(Processor):
219 u"""auth <credential>"""
220
221=== modified file 'ibid/plugins/basic.py'
222--- ibid/plugins/basic.py 2009-03-02 09:21:35 +0000
223+++ ibid/plugins/basic.py 2009-03-08 13:16:28 +0000
224@@ -64,6 +64,6 @@
225
226 @match(r'^(?:choose|choice|pick)\s+(.+)$')
227 def choose(self, event, choices):
228- event.addresponse(u'I choose %s' % choice(self.choose_re.split(choices)))
229+ event.addresponse(u'I choose %s', choice(self.choose_re.split(choices)))
230
231 # vi: set et sta sw=4 ts=4:
232
233=== modified file 'ibid/plugins/bzr.py'
234--- ibid/plugins/bzr.py 2009-03-02 09:21:35 +0000
235+++ ibid/plugins/bzr.py 2009-03-08 13:16:28 +0000
236@@ -66,7 +66,8 @@
237
238 @match(r'^(?:repos|repositories)$')
239 def handle_repositories(self, event):
240- event.addresponse(', '.join(self.branches.keys()))
241+ repositories = self.branches.keys()
242+ event.addresponse(u'I know about: %s', u', '.join(sorted(repositories)))
243
244 def remote_committed(self, repository, start, end=None):
245 commits = self.get_commits(repository, start, end)
246@@ -83,7 +84,7 @@
247
248 for commit in commits:
249 if commit:
250- event.addresponse(unicode(commit.strip()))
251+ event.addresponse(u'%s', commit.strip())
252
253 def get_commits(self, repository, start, end=None, full=None):
254 branch = None
255
256=== modified file 'ibid/plugins/config.py'
257--- ibid/plugins/config.py 2009-03-02 09:21:35 +0000
258+++ ibid/plugins/config.py 2009-03-08 13:16:28 +0000
259@@ -24,8 +24,8 @@
260 ibid.config.reload()
261 ibid.config.merge(FileConfig(join(ibid.options['base'], 'local.ini')))
262 ibid.reloader.reload_config()
263- event.addresponse(u"Configuration reread")
264- log.info(u"Reread configuration file")
265+ event.addresponse(u'Configuration reread')
266+ log.info(u'Reread configuration file')
267
268 @match(r'^set\s+config\s+(\S+?)(?:\s+to\s+|\s*=\s*)(\S.*?)$')
269 @authorise
270@@ -51,6 +51,6 @@
271 event.addresponse(u'No such option')
272 return
273 config = config[part]
274- event.addresponse(unicode(config))
275+ event.addresponse(u'%s', config)
276
277 # vi: set et sta sw=4 ts=4:
278
279=== modified file 'ibid/plugins/core.py'
280--- ibid/plugins/core.py 2009-03-02 09:21:35 +0000
281+++ ibid/plugins/core.py 2009-03-08 13:16:28 +0000
282@@ -116,7 +116,7 @@
283
284 priority = 950
285 complaints = Option('complaints', 'Complaint responses', (u'Huh?', u'Sorry...', u'?', u'Excuse me?', u'*blink*', u'What?'))
286- notauthed = Option('notauthed', 'Complaint responses for auth failures', (u"I'm not your bitch", u"Just do it yourself", u"I'm not going to listen to you", u"You're not the boss of me"))
287+ notauthed = Option('notauthed', 'Complaint responses for auth failures', (u"I'm not your bitch", u'Just do it yourself', u"I'm not going to listen to you", u"You're not the boss of me"))
288
289 @handler
290 def complain(self, event):
291@@ -141,7 +141,7 @@
292 self.messages[event.identity] = filter(lambda x: event.time-x < self.limit_time, self.messages[event.identity])
293 if len(self.messages[event.identity]) > self.limit_messages:
294 if event.public:
295- event.addresponse({'reply': u"Geez, give me some time to think!"})
296+ event.addresponse({'reply': u'Geez, give me some time to think!'})
297 else:
298 event.processed = True
299
300@@ -159,6 +159,6 @@
301 for value in object:
302 self.process(value)
303 elif isinstance(object, str):
304- self.log.warning(u"Found a non-unicode string: %s" % object)
305+ self.log.warning(u'Found a non-unicode string: %s' % object)
306
307 # vi: set et sta sw=4 ts=4:
308
309=== modified file 'ibid/plugins/crypto.py'
310--- ibid/plugins/crypto.py 2009-03-01 23:01:30 +0000
311+++ ibid/plugins/crypto.py 2009-03-08 13:16:28 +0000
312@@ -14,11 +14,11 @@
313
314 @match(r'^(md5|sha1|sha224|sha256|sha384|sha512)\s+(.+?)$')
315 def hash(self, event, hash, string):
316- event.addresponse(unicode(eval('hashlib.%s' % hash.lower())(string).hexdigest()))
317+ event.addresponse(u'%s', eval('hashlib.%s' % hash.lower())(string).hexdigest())
318
319 @match(r'^crypt\s+(.+)\s+(\S+)$')
320 def handle_crypt(self, event, string, salt):
321- event.addresponse(unicode(crypt(string, salt)))
322+ event.addresponse(u'%s', crypt(string, salt))
323
324 help['base64'] = u'Encodes and decodes base 16, 32 and 64.'
325 class Base64(Processor):
326@@ -27,7 +27,7 @@
327
328 @match(r'^b(16|32|64)(enc|dec)(?:ode)?\s+(.+?)$')
329 def base64(self, event, base, operation, string):
330- event.addresponse(unicode(eval('base64.b%s%sode' % (base, operation.lower()))(string)))
331+ event.addresponse(u'%s', eval('base64.b%s%sode' % (base, operation.lower()))(string))
332
333 help['rot13'] = u'Transforms a string with ROT13.'
334 class Rot13(Processor):
335@@ -36,6 +36,6 @@
336
337 @match(r'^rot13\s+(.+)$')
338 def rot13(self, event, string):
339- event.addresponse(unicode(string.encode('rot13')))
340+ event.addresponse(u'%s', string.encode('rot13'))
341
342 # vi: set et sta sw=4 ts=4:
343
344=== modified file 'ibid/plugins/dict.py'
345--- ibid/plugins/dict.py 2009-03-02 08:33:02 +0000
346+++ ibid/plugins/dict.py 2009-03-08 13:16:28 +0000
347@@ -22,32 +22,39 @@
348 @match(r'^define\s+(.+?)(?:\s+using\s+(.+))?$')
349 def define(self, event, word, dictionary):
350 definitions = self.connection.define(dictionary or '*', word)
351- event.addresponse(u', '.join([d.getdefstr() for d in definitions]))
352+ event.addresponse(u'%s', u', '.join([d.getdefstr() for d in definitions]))
353
354 @match(r'spell\s+(.+?)(?:\s+using\s+(.+))?$')
355 def handle_spell(self, event, word, strategy):
356- suggestions = self.connection.match('*', strategy or 'soundex', word)
357- event.addresponse(u', '.join([d.getword() for d in suggestions]))
358+ correct = self.connection.match('*', 'exact', word)
359+ if correct:
360+ event.addresponse(u'That seems correct. Carry on')
361+ return
362+ suggestions = self.connection.match('*', strategy or 'lev', word)
363+ if suggestions:
364+ event.addresponse(u'Suggestions: %s', u', '.join([d.getword() for d in suggestions]))
365+ else:
366+ event.addresponse(u"That doesn't seem correct, but I can't find anything to suggest")
367
368 @match(r'^dictionaries$')
369 def handle_dictionaries(self, event):
370- event.addresponse(u', '.join(self.dictionaries.keys()))
371+ event.addresponse(u'Dictionaries: %s', u', '.join(sorted(self.dictionaries.keys())))
372
373 @match(r'^strater?gies$')
374 def handle_strategies(self, event):
375- event.addresponse(u', '.join(self.strategies.keys()))
376+ event.addresponse(u'Strategies: %s', u', '.join(sorted(self.strategies.keys())))
377
378 @match(r'^dictionary\s+(.+?)$')
379 def handle_dictionary(self, event, dictionary):
380 if dictionary in self.dictionaries:
381- event.addresponse(unicode(self.dictionaries[dictionary]))
382+ event.addresponse(u'%s', self.dictionaries[dictionary])
383 else:
384 event.addresponse(u"I don't have that dictionary")
385
386 @match(r'^strater?gy\s+(.+?)$')
387 def handle_strategy(self, event, strategy):
388 if strategy in self.strategies:
389- event.addresponse(unicode(self.strategies[strategy]))
390+ event.addresponse(u'%s', self.strategies[strategy])
391 else:
392 event.addresponse(u"I don't have that strategy")
393
394
395=== modified file 'ibid/plugins/eval.py'
396--- ibid/plugins/eval.py 2009-03-05 16:33:12 +0000
397+++ ibid/plugins/eval.py 2009-03-08 13:16:28 +0000
398@@ -27,10 +27,10 @@
399 exec('import sys', globals)
400 exec('import re', globals)
401 exec('import time', globals)
402- result = unicode(eval(code, globals, {}))
403+ result = eval(code, globals, {})
404 except Exception, e:
405- result = unicode(e)
406- event.addresponse(result)
407+ result = e
408+ event.addresponse(u'%s', result)
409
410 class Perl(Processor):
411 u"""pl <code>"""
412@@ -46,7 +46,7 @@
413 except Exception, e:
414 result = e
415
416- event.addresponse(unicode(result))
417+ event.addresponse(u'%s', result)
418
419 class Lua(Processor):
420 u"""lua <code>"""
421@@ -62,6 +62,6 @@
422 except Exception, e:
423 result = e
424
425- event.addresponse(unicode(result))
426+ event.addresponse(u'%s', result)
427
428 # vi: set et sta sw=4 ts=4:
429
430=== modified file 'ibid/plugins/factoid.py'
431--- ibid/plugins/factoid.py 2009-03-01 23:01:30 +0000
432+++ ibid/plugins/factoid.py 2009-03-08 13:16:28 +0000
433@@ -96,7 +96,7 @@
434 session = ibid.databases.ibid()
435 factoid = session.query(Factoid).options(eagerload('values')).join('names').filter(func.lower(FactoidName.name)==escape_name(name).lower()).order_by(FactoidValue.id).first()
436 if factoid:
437- event.addresponse(', '.join(['%s: %s' % (factoid.values.index(value), value.value) for value in factoid.values[start:]]))
438+ event.addresponse(u'%s', u', '.join(['%s: %s' % (factoid.values.index(value), value.value) for value in factoid.values[start:]]))
439
440 session.close()
441
442@@ -120,7 +120,7 @@
443
444 if (number or pattern):
445 if len(factoids) > 1:
446- event.addresponse(u"Pattern matches multiple factoids, please be more specific")
447+ event.addresponse(u'Pattern matches multiple factoids, please be more specific')
448 return
449
450 if factoids[0][2].identity_id not in identities and not factoidadmin:
451@@ -152,7 +152,7 @@
452 session.close()
453 event.addresponse(True)
454 else:
455- event.addresponse(u"I didn't know about %s anyway" % name)
456+ event.addresponse(u"I didn't know about %s anyway", name)
457
458 @match(r'^(.+)\s+is\s+the\s+same\s+as\s+(.+)$')
459 @authorise
460@@ -172,7 +172,7 @@
461 event.addresponse(True)
462 log.info(u"Added name '%s' to factoid %s by %s/%s (%s)", name.name, factoid.id, event.account, event.identity, event.sender['connection'])
463 else:
464- event.addresponse(u"I don't know about %s" % name)
465+ event.addresponse(u"I don't know about %s", name)
466
467 class Search(Processor):
468 u"""(search|scan) for <pattern> [from <start>]"""
469@@ -196,7 +196,7 @@
470 matches = query[start:start+limit]
471
472 if matches:
473- event.addresponse(u'; '.join('%s [%s]' % (fname.name, values) for factoid, values, fname in matches))
474+ event.addresponse(u'%s', u'; '.join('%s [%s]' % (fname.name, values) for factoid, values, fname in matches))
475 else:
476 event.addresponse(u"I couldn't find anything with that name")
477
478@@ -264,7 +264,7 @@
479 if count:
480 return {'reply': reply}
481
482- reply = '%s %s' % (fname.name.replace('_%', '$arg').replace('\\%', '%').replace('\\_', '_'), reply)
483+ reply = u'%s %s' % (fname.name.replace('_%', '$arg').replace('\\%', '%').replace('\\_', '_'), reply)
484 return reply
485
486 class Set(Processor):
487@@ -294,7 +294,7 @@
488 session.delete(fvalue)
489 session.flush()
490 elif not addition:
491- event.addresponse(u"I already know stuff about %s" % name)
492+ event.addresponse(u'I already know stuff about %s', name)
493 return
494 else:
495 factoid = Factoid()
496
497=== modified file 'ibid/plugins/feeds.py'
498--- ibid/plugins/feeds.py 2009-03-01 23:01:30 +0000
499+++ ibid/plugins/feeds.py 2009-03-08 13:16:28 +0000
500@@ -58,7 +58,7 @@
501 feed = session.query(Feed).filter(func.lower(Feed.name)==name.lower()).first()
502
503 if feed:
504- event.addresponse(u"I already have the %s feed" % name)
505+ event.addresponse(u'I already have the %s feed', name)
506 else:
507 feed = Feed(unicode(name), unicode(url), event.identity)
508
509@@ -68,7 +68,10 @@
510 event.addresponse(True)
511 log.info(u"Added feed '%s' by %s/%s (%s): %s (Found %s entries)", name, event.account, event.identity, event.sender['connection'], url, len(feed.entries))
512 else:
513- event.addresponse(u"Sorry, I could not add the %s feed. %s is not a valid feed" % (name,url))
514+ event.addresponse(u'Sorry, I could not add the %(name)s feed. %(url)s is not a valid feed', {
515+ 'name': name,
516+ 'url': url,
517+ })
518
519 session.close()
520
521@@ -77,7 +80,7 @@
522 session = ibid.databases.ibid()
523 feeds = session.query(Feed).all()
524 if feeds:
525- event.addresponse(u', '.join([feed.name for feed in feeds]))
526+ event.addresponse(u'I know about: %s', u', '.join(sorted([feed.name for feed in feeds])))
527 else:
528 event.addresponse(u"I don't know about any feeds")
529
530@@ -88,7 +91,7 @@
531 feed = session.query(Feed).filter(func.lower(Feed.name)==name.lower()).first()
532
533 if not feed:
534- event.addresponse(u"I don't have the %s feed anyway" % name)
535+ event.addresponse(u"I don't have the %s feed anyway", name)
536 else:
537 session.delete(feed)
538 log.info(u"Deleted feed '%s' by %s/%s (%s): %s", name, event.account, event.identity, event.sender['connection'], feed.url)
539@@ -112,7 +115,7 @@
540 session.close()
541
542 if not feed:
543- event.addresponse(u"I don't know about the %s feed" % name)
544+ event.addresponse(u"I don't know about the %s feed", name)
545 return
546
547 feed.update()
548@@ -120,7 +123,9 @@
549 event.addresponse(u"I can't access that feed")
550 return
551
552- event.addresponse(u', '.join(['%s: "%s"' % (feed.entries.index(entry), html2text_file(entry.title, None).strip()) for entry in feed.entries[start:number+start]]))
553+ articles = feed.entries[start:number+start]
554+ articles = ['%s: "%s"' % (feed.entries.index(entry), html2text_file(entry.title, None).strip()) for entry in articles]
555+ event.addresponse(u'%s', u', '.join(articles))
556
557 @match(r'^article\s+(?:(\d+)|/(.+?)/)\s+from\s+(.+?)$')
558 def article(self, event, number, pattern, name):
559@@ -129,7 +134,7 @@
560 session.close()
561
562 if not feed:
563- event.addresponse(u"I don't know about the %s feed" % name)
564+ event.addresponse(u"I don't know about the %s feed", name)
565 return
566
567 feed.update()
568@@ -152,7 +157,7 @@
569 break
570
571 if not article:
572- event.addresponse(u"Are you making up news again?")
573+ event.addresponse(u'Are you making up news again?')
574 return
575
576 if 'summary' in article:
577@@ -163,6 +168,10 @@
578 else:
579 summary = article.content[0].value
580
581- event.addresponse(u'"%s" %s : %s' % (html2text_file(article.title, None).strip(), article.link, summary))
582+ event.addresponse(u'"%(title)s" %(link)s : %(summary)s', {
583+ 'title': html2text_file(article.title, None).strip(),
584+ 'link': article.link,
585+ 'summary': summary,
586+ })
587
588 # vi: set et sta sw=4 ts=4:
589
590=== modified file 'ibid/plugins/google.py'
591--- ibid/plugins/google.py 2009-03-05 15:03:20 +0000
592+++ ibid/plugins/google.py 2009-03-08 13:16:28 +0000
593@@ -61,17 +61,26 @@
594 results.append(u'"%s" %s' % (de_entity(title), item["unescapedUrl"]))
595
596 if results:
597- event.addresponse(u', '.join(results))
598+ event.addresponse(u'%s', u', '.join(results))
599 else:
600- event.addresponse(u"Wow! Google couldn't find anything.")
601+ event.addresponse(u"Wow! Google couldn't find anything")
602
603 @match(r'^(?:rank|(?:google(?:fight|compare|cmp)))\s+(?:for\s+)?(.+?)\s+and\s+(.+?)$')
604 def googlefight(self, event, term1, term2):
605 count1 = int(self._google_api_search(term1, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
606 count2 = int(self._google_api_search(term2, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
607- event.addresponse(u'%s wins with %i hits, %s had %i hits' %
608- (count1 > count2 and (term1, count1, term2, count2) or (term2, count2, term1, count1))
609- )
610+ event.addresponse(u'%(firstterm)s wins with %(firsthits)i hits, %(secondterm)s had %(secondhits)i hits',
611+ (count1 > count2 and {
612+ 'firstterm': term1,
613+ 'firsthits': count1,
614+ 'secondterm': term2,
615+ 'secondhits': count2,
616+ } or {
617+ 'firstterm': term2,
618+ 'firsthits': count2,
619+ 'secondterm': term1,
620+ 'secondhits': count1,
621+ }))
622
623 # Unfortunatly google API search doesn't support all of google search's
624 # features.
625@@ -103,7 +112,7 @@
626 if not font:
627 event.addresponse(u'No result')
628 else:
629- event.addresponse(font.b.string)
630+ event.addresponse(u'%s', font.b.string)
631
632 @match(r'^gdefine\s+(.+)$')
633 def define(self, event, term):
634@@ -114,9 +123,9 @@
635 definitions.append(de_entity(li.contents[0].strip()))
636
637 if definitions:
638- event.addresponse(u' :: '.join(definitions))
639+ event.addresponse(u'%s', u' :: '.join(definitions))
640 else:
641- event.addresponse(u"Are you making up words again?")
642+ event.addresponse(u'Are you making up words again?')
643
644 # Not supported by Google API: http://code.google.com/p/google-ajax-apis/issues/detail?id=24
645 @match(r'^google(?:\.com?)?\.([a-z]{2})(?:\s+for)?\s+(.*)$')
646@@ -138,8 +147,8 @@
647 break
648
649 if results:
650- event.addresponse(u", ".join(results))
651+ event.addresponse('%s', u', '.join(results))
652 else:
653- event.addresponse(u"Wow! Google couldn't find anything.")
654+ event.addresponse(u"Wow! Google couldn't find anything")
655
656 # vi: set et sta sw=4 ts=4:
657
658=== modified file 'ibid/plugins/help.py'
659--- ibid/plugins/help.py 2009-03-05 16:33:12 +0000
660+++ ibid/plugins/help.py 2009-03-08 13:16:28 +0000
661@@ -27,7 +27,7 @@
662 if feature not in features:
663 features.append(feature)
664
665- event.addresponse(u' '.join(features))
666+ event.addresponse(u'Features: %s', u' '.join(sorted(features)))
667
668 @match(r'^help\s+(.+)$')
669 def help(self, event, feature):
670@@ -39,7 +39,7 @@
671 event.addresponse(module.help[feature])
672 return
673
674- event.addresponse(u"I can't help you with %s" % feature)
675+ event.addresponse(u"I can't help you with %s", feature)
676
677 @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')
678 def usage(self, event, feature):
679@@ -49,9 +49,9 @@
680 for name, klass in inspect.getmembers(processor, inspect.isclass):
681 if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:
682 for line in klass.__doc__.splitlines():
683- event.addresponse('Usage: %s' % line.strip())
684+ event.addresponse(u'Usage: %s', line.strip())
685
686 if not event.responses:
687- event.addresponse(u"I don't know how to use %s either" % feature)
688+ event.addresponse(u"I don't know how to use %s either", feature)
689
690 # vi: set et sta sw=4 ts=4:
691
692=== modified file 'ibid/plugins/http.py'
693--- ibid/plugins/http.py 2009-03-07 16:10:50 +0000
694+++ ibid/plugins/http.py 2009-03-08 13:16:28 +0000
695@@ -52,7 +52,8 @@
696 if action == 'GET':
697 match = title.search(data)
698 if match:
699- reply = u'%s "%s"' % (reply, match.groups()[0].strip())
700-
701- event.addresponse(reply)
702+ reply += u' "%s"' % match.groups()[0].strip()
703+
704+ event.addresponse('%s', reply)
705+
706 # vi: set et sta sw=4 ts=4:
707
708=== modified file 'ibid/plugins/identity.py'
709--- ibid/plugins/identity.py 2009-03-01 23:01:30 +0000
710+++ ibid/plugins/identity.py 2009-03-08 13:16:28 +0000
711@@ -29,12 +29,12 @@
712 admin = True
713 else:
714 account = session.query(Account).filter_by(id=event.account).first()
715- event.addresponse(u'You already have an account called "%s".' % account.username)
716+ event.addresponse(u'You already have an account called "%s"', account.username)
717 return
718
719 account = session.query(Account).filter_by(username=username).first()
720 if account:
721- event.addresponse(u'There is already an account called "%s". Please choose a different name.' % account.username)
722+ event.addresponse(u'There is already an account called "%s". Please choose a different name', account.username)
723 return
724
725 account = Account(username)
726@@ -51,7 +51,7 @@
727
728 identify_cache.clear()
729 session.close()
730- event.addresponse(u'Done')
731+ event.addresponse(True)
732
733 chars = string.letters + string.digits
734
735@@ -78,7 +78,8 @@
736 username = event.sender['id']
737 account = session.query(Account).filter_by(username=username).first()
738 if account:
739- event.addresponse(u"I tried to create the account %s for you, but it already exists. Please use 'create account <name>'." % username)
740+ event.addresponse(u'I tried to create the account %s for you, but it already exists. '
741+ u"Please use 'create account <name>'", username)
742 return
743 account = Account(username)
744 session.save_or_update(account)
745@@ -88,7 +89,7 @@
746 session.save_or_update(currentidentity)
747 session.flush()
748 identify_cache.clear()
749- event.addresponse(u"I've created the account %s for you" % username)
750+ event.addresponse(u"I've created the account %s for you", username)
751 log.info(u"Created account %s (%s) by %s/%s (%s)", account.id, account.username, event.account, event.identity, event.sender['connection'])
752 log.info(u"Attached identity %s (%s on %s) to account %s (%s)", currentidentity.id, currentidentity.identity, currentidentity.source, account.id, account.username)
753
754@@ -98,16 +99,16 @@
755 admin = True
756 account = session.query(Account).filter_by(username=username).first()
757 if not account:
758- event.addresponse(u"I don't know who %s is" % username)
759+ event.addresponse(u"I don't know who %s is", username)
760 return
761
762 ident = session.query(Identity).filter(func.lower(Identity.identity)==identity.lower()).filter(func.lower(Identity.source)==source.lower()).first()
763 if ident and ident.account:
764- event.addresponse(u'This identity is already attached to account %s' % ident.account.username)
765+ event.addresponse(u'This identity is already attached to account %s', ident.account.username)
766 return
767
768 if source.lower() not in ibid.sources:
769- event.addresponse(u"I am not connected to %s" % source)
770+ event.addresponse(u'I am not connected to %s', source)
771 else:
772 source = ibid.sources[source.lower()].name
773
774@@ -136,7 +137,10 @@
775 session = ibid.databases.ibid()
776 (account_id, user, source) = self.tokens[token]
777 if event.source.lower() != source.lower() or event.sender['id'].lower() != user.lower():
778- event.addresponse(u'You need to send me this token from %s on %s' % (user, source))
779+ event.addresponse(u'You need to send me this token from %(name)s on %(source)s', {
780+ 'name': user,
781+ 'source': source,
782+ })
783 return
784
785 identity = session.query(Identity).filter(func.lower(Identity.identity)==user.lower()).filter(func.lower(Identity.source)==source.lower()).first()
786@@ -163,7 +167,7 @@
787 return
788 account = session.query(Account).filter_by(username=username).first()
789 if not account:
790- event.addresponse(u"I don't know who %s is" % username)
791+ event.addresponse(u"I don't know who %s is", username)
792 return
793
794 identity = session.query(Identity).filter_by(account_id=account.id).filter(func.lower(Identity.identity)==user.lower()).filter(func.lower(Identity.source)==source.lower()).first()
795@@ -193,7 +197,7 @@
796 return
797 account = session.query(Account).filter_by(id=event.account).first()
798 if not account:
799- event.addresponse(u"%s doesn't exist. Please use 'add account' first" % username)
800+ event.addresponse(u"%s doesn't exist. Please use 'add account' first", username)
801 return
802
803 else:
804@@ -201,14 +205,14 @@
805 return
806 account = session.query(Account).filter_by(username=username).first()
807 if not account:
808- event.addresponse(u"I don't know who %s is" % username)
809+ event.addresponse(u"I don't know who %s is", username)
810 return
811
812 account.attributes.append(Attribute(name, value))
813 session.save_or_update(account)
814 session.flush()
815 session.close()
816- event.addresponse(u'Done')
817+ event.addresponse(True)
818 log.info(u"Added attribute '%s' = '%s' to account %s (%s) by %s/%s (%s)", name, value, account.id, account.username, event.account, event.identity, event.sender['connection'])
819
820 class Describe(Processor):
821@@ -221,17 +225,23 @@
822 if username.upper() == 'I':
823 if not event.account:
824 identity = session.query(Identity).get(event.identity)
825- event.addresponse(u"%s on %s" % (identity.identity, identity.source))
826+ event.addresponse(u"%(name)s on %(source)s", {
827+ 'name': identity.identity,
828+ 'source': identity.source,
829+ })
830 return
831 account = session.query(Account).get(event.account)
832
833 else:
834 account = session.query(Account).filter_by(username=username).first()
835 if not account:
836- event.addresponse(u"I don't know who %s is" % username)
837+ event.addresponse(u"I don't know who %s is", username)
838 return
839
840- event.addresponse(u'%s is %s' % (account.username, ', '.join('%s on %s' % (identity.identity, identity.source) for identity in account.identities)))
841+ event.addresponse(u'%(accountname)s is %(identities)s', {
842+ 'accountname': account.username,
843+ 'identities': u', '.join(u'%s on %s' % (identity.identity, identity.source) for identity in account.identities),
844+ })
845 session.close()
846
847 class Identify(Processor):
848
849=== modified file 'ibid/plugins/imdb.py'
850--- ibid/plugins/imdb.py 2009-03-01 23:01:30 +0000
851+++ ibid/plugins/imdb.py 2009-03-08 13:16:28 +0000
852@@ -50,25 +50,28 @@
853 self.imdb.update(result)
854
855 except IMDbDataAccessError, e:
856- event.addresponse(u"IMDb doesn't like me today. It said '%s'" % e[0]["errmsg"])
857+ event.addresponse(u"IMDb doesn't like me today. It said '%s'", e[0]["errmsg"])
858 raise
859
860 except IMDbError, e:
861- event.addresponse(u"IMDb must be having a bad day (or you are asking it silly things)")
862+ event.addresponse(u'IMDb must be having a bad day (or you are asking it silly things)')
863 raise
864
865 if result is not None:
866- event.addresponse(u"Found " + getattr(self, "display_" + search_type)(result))
867+ event.addresponse(u'Found %s', getattr(self, 'display_' + search_type)(result))
868 return
869
870 if len(results) == 0:
871- event.addresponse(u"Sorry, couldn't find that.")
872+ event.addresponse(u"Sorry, couldn't find that")
873 else:
874 results = [x[self.name_keys[search_type]] for x in results]
875 results = enumerate(results)
876 results = [u"%i: %s" % (x[0] + 1, x[1]) for x in results]
877- more = (u"", u">")[len(results) == 20]
878- event.addresponse(u"Found %s%i matches: %s" % (more, len(results), u", ".join(results)))
879+ event.addresponse(u'Found %(greaterthan)s%(num)i matches: %(results)s', {
880+ 'greaterthan': (u'', u'>')[len(results) == 20],
881+ 'num': len(results),
882+ 'results': u', '.join(results),
883+ })
884
885 def display_character(self, character):
886 desc = u"%s: %s." % (character.characterID, character["long imdb name"])
887
888=== modified file 'ibid/plugins/info.py'
889--- ibid/plugins/info.py 2009-03-02 09:38:47 +0000
890+++ ibid/plugins/info.py 2009-03-08 13:16:28 +0000
891@@ -26,7 +26,11 @@
892
893 @match(r'^fortune$')
894 def handler(self, event):
895- event.addresponse(self.remote_fortune() or u"Couldn't execute fortune")
896+ fortune = self.remote_fortune()
897+ if fortune:
898+ event.addresponse(u'%s', fortune)
899+ else:
900+ event.addresponse(u"Couldn't execute fortune")
901
902 def remote_fortune(self):
903 fortune = Popen(self.fortune, stdout=PIPE, stderr=PIPE)
904@@ -49,9 +53,12 @@
905 def handle_nickometer(self, event, nick, wreasons):
906 nick = nick or event.sender['nick']
907 score, reasons = nickometer(str(nick))
908- event.addresponse(u"%s is %s%% lame" % (nick, score))
909+ event.addresponse(u"%(nick)s is %(score)s%% lame", {
910+ 'nick': nick,
911+ 'score': score,
912+ })
913 if wreasons:
914- event.addresponse(u', '.join(['%s (%s)' % reason for reason in reasons]))
915+ event.addresponse(u'Because: %s', u', '.join(['%s (%s)' % reason for reason in reasons]))
916
917 help['man'] = u'Retrieves information from manpages.'
918 class Man(Processor):
919@@ -88,9 +95,9 @@
920 output = output.splitlines()
921 index = output.index('NAME')
922 if index:
923- event.addresponse(output[index+1].strip())
924+ event.addresponse(u'%s', output[index+1].strip())
925 index = output.index('SYNOPSIS')
926 if index:
927- event.addresponse(output[index+1].strip())
928+ event.addresponse(u'%s', output[index+1].strip())
929
930 # vi: set et sta sw=4 ts=4:
931
932=== modified file 'ibid/plugins/irc.py'
933--- ibid/plugins/irc.py 2009-03-01 23:01:30 +0000
934+++ ibid/plugins/irc.py 2009-03-08 13:16:28 +0000
935@@ -25,21 +25,21 @@
936 channel = event.channel
937
938 if source.lower() not in ibid.sources:
939- event.addresponse(u"I don't have a source called %s" % source.lower())
940+ event.addresponse(u"I don't have a source called %s", source.lower())
941 return
942
943 source = ibid.sources[source.lower()]
944
945 if not hasattr(source, 'join'):
946- event.addresponse(u"%s cannot join/part channels" % (source.name,))
947+ event.addresponse(u'%s cannot join/part channels', source.name)
948 return
949
950 if action == 'join':
951 source.join(channel)
952- event.addresponse(u"Joining %s" % channel)
953+ event.addresponse(u'Joining %s', channel)
954 else:
955 source.part(channel)
956- event.addresponse(u"Parting %s" % channel)
957+ event.addresponse(u'Parting %s', channel)
958
959 @match(r'^change\s+nick\s+to\s+(\S+)(?:\s+on\s+(\S+))?$')
960 @authorise
961@@ -49,15 +49,15 @@
962 source = event.source
963
964 if source.lower() not in ibid.sources:
965- event.addresponse(u"I don't have a source called %s" % source.lower())
966+ event.addresponse(u"I don't have a source called %s", source.lower())
967 return
968
969 source = ibid.sources[source.lower()]
970
971 if not hasattr(source, 'change_nick'):
972- event.addresponse(u"%s cannot change nicks" % source)
973+ event.addresponse(u'%s cannot change nicks', source)
974 else:
975 source.change_nick(nick)
976- event.addresponse(u'Changing nick to %s' % nick)
977+ event.addresponse(u'Changing nick to %s', nick)
978
979 # vi: set et sta sw=4 ts=4:
980
981=== modified file 'ibid/plugins/karma.py'
982--- ibid/plugins/karma.py 2009-03-01 23:01:30 +0000
983+++ ibid/plugins/karma.py 2009-03-08 13:16:28 +0000
984@@ -50,7 +50,7 @@
985 @authorise
986 def set(self, event, subject, adjust, reason):
987 if self.public and not event.public:
988- event.addresponse(u"Karma must be done in public")
989+ event.addresponse(u'Karma must be done in public')
990 return
991
992 if subject.lower() in self.ignore:
993@@ -97,16 +97,19 @@
994 session = ibid.databases.ibid()
995 karma = session.query(Karma).filter(func.lower(Karma.subject)==subject.lower()).first()
996 if not karma:
997- event.addresponse(u"%s has neutral karma" % subject)
998+ event.addresponse(u'%s has neutral karma', subject)
999 else:
1000- event.addresponse(u"%s has karma of %s" % (subject, karma.value))
1001+ event.addresponse(u'%(subject)s has karma of %(value)s', {
1002+ 'subject': subject,
1003+ 'value': karma.value,
1004+ })
1005 session.close()
1006
1007 @match(r'^(reverse\s+)?karmaladder$')
1008 def ladder(self, event, reverse):
1009 session = ibid.databases.ibid()
1010 karmas = session.query(Karma).order_by(reverse and Karma.value.asc() or Karma.value.desc()).limit(30).all()
1011- event.addresponse(', '.join(['%s: %s (%s)' % (karmas.index(karma), karma.subject, karma.value) for karma in karmas]))
1012+ event.addresponse('%s', ', '.join(['%s: %s (%s)' % (karmas.index(karma), karma.subject, karma.value) for karma in karmas]))
1013 session.close()
1014
1015 # vi: set et sta sw=4 ts=4:
1016
1017=== modified file 'ibid/plugins/lookup.py'
1018--- ibid/plugins/lookup.py 2009-03-08 08:00:10 +0000
1019+++ ibid/plugins/lookup.py 2009-03-08 13:21:32 +0000
1020@@ -28,15 +28,15 @@
1021
1022 if quote.lower() == "random":
1023 number = u"".join(soup.find('p', attrs={'class': 'quote'}).find('b').contents)
1024- event.addresponse(u"%s:" % number)
1025+ event.addresponse(u'%s:', number)
1026
1027 quote = soup.find('p', attrs={'class': 'qt'})
1028 if not quote:
1029- event.addresponse(u"There's no such quote, but if you keep talking like that maybe there will be.")
1030+ event.addresponse(u"There's no such quote, but if you keep talking like that maybe there will be")
1031 else:
1032 for line in quote.contents:
1033 if str(line) != '<br />':
1034- event.addresponse(unicode(line).strip())
1035+ event.addresponse(u'%s', line.strip())
1036
1037 help['lastfm'] = u'Lists the tracks last listened to by the specified user.'
1038 class LastFm(Processor):
1039@@ -46,11 +46,11 @@
1040
1041 @match(r'^last\.?fm\s+for\s+(\S+?)\s*$')
1042 def listsongs(self, event, username):
1043- songs = feedparser.parse("http://ws.audioscrobbler.com/1.0/user/%s/recenttracks.rss?%s" % (username, time()))
1044+ songs = feedparser.parse('http://ws.audioscrobbler.com/1.0/user/%s/recenttracks.rss?%s' % (username, time()))
1045 if songs['bozo']:
1046- event.addresponse(u"No such user")
1047+ event.addresponse(u'No such user')
1048 else:
1049- event.addresponse(u', '.join(u'%s (%s ago)' % (e.title, ago(datetime.utcnow() - datetime.strptime(e.updated, '%a, %d %b %Y %H:%M:%S +0000'), 1)) for e in songs['entries']))
1050+ event.addresponse(u'%s', u', '.join(u'%s (%s ago)' % (e.title, ago(datetime.utcnow() - datetime.strptime(e.updated, '%a, %d %b %Y %H:%M:%S +0000'), 1)) for e in songs['entries']))
1051
1052 help['lotto'] = u"Gets the latest lotto results from the South African National Lottery."
1053 class Lotto(Processor):
1054@@ -58,40 +58,37 @@
1055
1056 feature = 'lotto'
1057
1058- errors = {
1059- 'open': 'Something went wrong getting to the Lotto site',
1060- 'balls': 'I expected to get %s balls, but found %s. They were: %s',
1061- }
1062-
1063 za_url = 'http://www.nationallottery.co.za/'
1064 za_re = re.compile(r'images/balls/ball_(\d+).gif')
1065- za_text = u'Latest lotto results for South Africa, Lotto: '
1066
1067 @match(r'lotto(\s+for\s+south\s+africa)?')
1068 def za(self, event, za):
1069 try:
1070 f = urlopen(self.za_url)
1071 except Exception, e:
1072- event.addresponse(self.errors['open'])
1073+ event.addresponse(u'Something went wrong getting to the Lotto site')
1074 return
1075
1076 s = "".join(f)
1077 f.close()
1078
1079- r = self.za_text
1080-
1081 balls = self.za_re.findall(s)
1082
1083 if len(balls) != 14:
1084- event.addresponse(self.errors['balls'] % \
1085- (14, len(balls), ", ".join(balls)))
1086+ event.addresponse(u'I expected to get %(expected)s balls, but found %(found)s. They were: %(balls)s', {
1087+ 'expected': 14,
1088+ 'found': len(balls),
1089+ 'balls': u', '.join(balls),
1090+ })
1091 return
1092
1093- r += u" ".join(balls[:6])
1094- r += u" (Bonus: %s), Lotto Plus: " % (balls[6], )
1095- r += u" ".join(balls[7:13])
1096- r += u" (Bonus: %s)" % (balls[13], )
1097- event.addresponse(r)
1098+ event.addresponse(u'Latest lotto results for South Africa, '
1099+ u'Lotto: %(lottoballs)s (Bonus: %(lottobonus)s), Lotto Plus: %(plusballs)s (Bonus: %(plusbonus)s)', {
1100+ 'lottoballs': u" ".join(balls[:6]),
1101+ 'lottobonus': balls[6],
1102+ 'plusballs': u" ".join(balls[7:13]),
1103+ 'plusbonus': balls[13],
1104+ })
1105
1106 help['fml'] = u'Retrieves quotes from fmylife.com.'
1107 class FMyLife(Processor):
1108@@ -109,7 +106,11 @@
1109
1110 @match(r'^(?:fml\s+|http://www\.fmylife\.com/\S+/)(\d+|random)$')
1111 def fml(self, event, id):
1112- event.addresponse(self.remote_get(id) or u"No such quote")
1113+ quote = self.remote_get(id)
1114+ if quote:
1115+ event.addresponse(u'%s', quote)
1116+ else:
1117+ event.addresponse(u'No such quote')
1118
1119 help["microblog"] = u"Looks up messages on microblogging services like twitter and identica."
1120 class Twitter(Processor):
1121@@ -134,7 +135,7 @@
1122 status = loads(f.read())
1123 f.close()
1124
1125- return u'%s: "%s"' % (status['user']['screen_name'], status['text'])
1126+ return {'screen_name': status['user']['screen_name'], 'text': status['text']}
1127
1128 def remote_latest(self, service, user):
1129 service_url = self.services[service]
1130@@ -148,25 +149,27 @@
1131 elif service_url.endswith("/api/"):
1132 url = "%s/notice/%i" % (service_url[:-5], latest["id"])
1133
1134- when = ago(datetime.utcnow() - datetime.strptime(latest["created_at"], '%a %b %d %H:%M:%S +0000 %Y'), 1)
1135-
1136- return u'"%s" %s ago, %s' % (latest['text'], when, url)
1137+ return {
1138+ 'text': latest['text'],
1139+ 'ago': ago(datetime.utcnow() - datetime.strptime(latest["created_at"], '%a %b %d %H:%M:%S +0000 %Y'), 1),
1140+ 'url': url,
1141+ }
1142
1143 @handler
1144 def update(self, event, service, id):
1145- event.addresponse(self.remote_update(service.lower(), int(id)))
1146+ event.addresponse(u'%(screen_name)s: "%(text)s"', self.remote_update(service.lower(), int(id)))
1147
1148 @handler
1149 def latest(self, event, service, user):
1150- event.addresponse(self.remote_latest(service.lower(), user))
1151+ event.addresponse(u'"%(text)s" %(ago)s ago, %(url)s', self.remote_latest(service.lower(), user))
1152
1153 @match(r'^https?://(?:www\.)?twitter\.com/[^/ ]+/statuse?s?/(\d+)$')
1154 def twitter(self, event, id):
1155- event.addresponse(self.remote_update('twitter', int(id)))
1156+ event.addresponse(u'%(screen_name)s: "%(text)s"', self.remote_update('twitter', int(id)))
1157
1158 @match(r'^https?://(?:www\.)?identi.ca/notice/(\d+)$')
1159 def identica(self, event, id):
1160- event.addresponse(self.remote_update('identi.ca', int(id)))
1161+ event.addresponse(u'%(screen_name)s: "%(text)s"', self.remote_update('identi.ca', int(id)))
1162
1163 help['currency'] = u'Converts amounts between currencies.'
1164 class Currency(Processor):
1165@@ -199,7 +202,7 @@
1166 soup = BeautifulSoup(f.read())
1167 f.close()
1168
1169- event.addresponse(soup.findAll('span', attrs={'class': 'XEsmall'})[1].contents[0])
1170+ event.addresponse(u'%s', soup.findAll('span', attrs={'class': 'XEsmall'})[1].contents[0])
1171
1172 @match(r'^(?:currency|currencies)\s+for\s+(?:the\s+)?(.+)$')
1173 def currency(self, event, place):
1174@@ -210,10 +213,10 @@
1175 results = []
1176 for code, place, name in self.currencies:
1177 if search.search(place):
1178- results.append('%s uses %s (%s)' % (place, name, code))
1179+ results.append(u'%s uses %s (%s)' % (place, name, code))
1180
1181 if results:
1182- event.addresponse(u', '.join(results))
1183+ event.addresponse(u'%s', u', '.join(results))
1184 else:
1185 event.addresponse(u'No currencies found')
1186
1187@@ -279,7 +282,7 @@
1188 for td in soup.findAll('table')[2].findAll('td', align='left'):
1189 day = td.b.string
1190 forecast = td.contents[2]
1191- forecasts.append('%s: %s' % (day, self._text(forecast)))
1192+ forecasts.append(u'%s: %s' % (day, self._text(forecast)))
1193
1194 return forecasts
1195
1196@@ -287,19 +290,25 @@
1197 def weather(self, event, place):
1198 try:
1199 values = self.remote_weather(place)
1200- event.addresponse(u'In %(place)s at %(time)s: %(temp)s; Humidity: %(humidity)s; Wind: %(wind)s; Conditions: %(conditions)s; Sunrise/set: %(sunrise)s/%(sunset)s; Moonrise/set: %(moonrise)s/%(moonset)s' % values)
1201+ event.addresponse(u'In %(place)s at %(time)s: %(temp)s; Humidity: %(humidity)s; Wind: %(wind)s; Conditions: %(conditions)s; Sunrise/set: %(sunrise)s/%(sunset)s; Moonrise/set: %(moonrise)s/%(moonset)s', values)
1202 except Weather.TooManyPlacesException, e:
1203- event.addresponse(u'Too many places match %s: %s' % (place, '; '.join(e.message)))
1204+ event.addresponse(u'Too many places match %(place)s: %(exception)s', {
1205+ 'place': place,
1206+ 'exception': u'; '.join(e.message),
1207+ })
1208 except Weather.WeatherException, e:
1209- event.addresponse(e.message)
1210+ event.addresponse(u'%s', e.message)
1211
1212 @match(r'^forecast\s+(?:for\s+)?(.+)$')
1213 def forecast(self, event, place):
1214 try:
1215- event.addresponse(u', '.join(self.remote_forecast(place)))
1216+ event.addresponse(u'%s', u', '.join(self.remote_forecast(place)))
1217 except Weather.TooManyPlacesException, e:
1218- event.addresponse(u'Too many places match %s: %s' % (place, '; '.join(e.message)))
1219+ event.addresponse(u'Too many places match %(place)s: %(exception)s', {
1220+ 'place': place,
1221+ 'exception': u'; '.join(e.message),
1222+ })
1223 except Weather.WeatherException, e:
1224- event.addresponse(e.message)
1225+ event.addresponse(u'%s', e.message)
1226
1227 # vi: set et sta sw=4 ts=4:
1228
1229=== modified file 'ibid/plugins/math.py'
1230--- ibid/plugins/math.py 2009-03-02 09:38:47 +0000
1231+++ ibid/plugins/math.py 2009-03-08 13:16:28 +0000
1232@@ -30,12 +30,12 @@
1233 if output:
1234 output = unicode_output(output.strip())
1235 output = output.replace('\\\n', '')
1236- event.addresponse(output)
1237+ event.addresponse(u'%s', output)
1238 else:
1239 error = unicode_output(error.strip())
1240 error = error.split(":", 1)[1].strip()
1241 error = error[0].lower() + error[1:]
1242- event.addresponse(u"You can't %s" % error)
1243+ event.addresponse(u"You can't %s", error)
1244 else:
1245 event.addresponse(u"Error running bc")
1246 error = unicode_output(error.strip())
1247@@ -70,17 +70,17 @@
1248 event.addresponse(u"I can't divide by zero.")
1249 return
1250 except ArithmeticError, e:
1251- event.addresponse(u"I can't do that: %s" % e.message)
1252+ event.addresponse(u"I can't do that: %s", e.message)
1253 return
1254 except ValueError, e:
1255 if e.message == "math domain error":
1256- event.addresponse(u"I can't do that: %s" % e.message)
1257+ event.addresponse(u"I can't do that: %s", e.message)
1258 return
1259 except Exception, e:
1260 return
1261
1262 if isinstance(result, (int, long, float, complex)):
1263- event.addresponse(unicode(result))
1264+ event.addresponse(u'%s', result)
1265
1266 help['base'] = 'Convert numbers between bases (radixes)'
1267 class BaseConvert(Processor):
1268@@ -197,17 +197,19 @@
1269 base_to = self._parse_base(base_to)
1270
1271 if min(base_from, base_to) < 2 or max(base_from, base_to) > 64:
1272- event.addresponse(u"Sorry, valid bases are between 2 and 64, inclusive.")
1273+ event.addresponse(u'Sorry, valid bases are between 2 and 64, inclusive')
1274 return
1275
1276 try:
1277 number = self._from_base(number, base_from)
1278 except ValueError, e:
1279- event.addresponse(e.message)
1280+ event.addresponse(u'%s', e.message)
1281 return
1282
1283- event.addresponse(u"That is %s in %s." %
1284- (self._in_base(number, base_to), self._base_name(base_to)))
1285+ event.addresponse(u'That is %(result)s in %(base)s', {
1286+ 'result': self._in_base(number, base_to),
1287+ 'base': self._base_name(base_to),
1288+ })
1289
1290 @handler
1291 def ascii_decode(self, event, text, base_to):
1292@@ -222,16 +224,19 @@
1293 for char in text:
1294 code_point = ord(char)
1295 if code_point > 255:
1296- output += u"U%s " % self._in_base(code_point, base_to)
1297+ output += u'U%s ' % self._in_base(code_point, base_to)
1298 else:
1299 output += self._in_base(code_point, base_to) + u" "
1300
1301 output = output.strip()
1302
1303- event.addresponse(u"That is %s in %s." % (output, self._base_name(base_to)))
1304+ event.addresponse(u'That is %(result)s in %(base)s', {
1305+ 'result': output,
1306+ 'base': self._base_name(base_to),
1307+ })
1308
1309- if base_to == 64 and [True for plugin in ibid.processors if getattr(plugin, "feature", None) == "base64"]:
1310- event.addresponse(u'If you want a base64 encoding, use the "base64" feature.')
1311+ if base_to == 64 and [True for plugin in ibid.processors if getattr(plugin, 'feature', None) == 'base64']:
1312+ event.addresponse(u'If you want a base64 encoding, use the "base64" feature')
1313
1314 @handler
1315 def ascii_encode(self, event, source, base_from):
1316@@ -266,11 +271,11 @@
1317 if len(buf) > 0:
1318 output += process_buf(buf)
1319 except ValueError, e:
1320- event.addresponse(e.message)
1321+ event.addresponse(u'%s', e.message)
1322 return
1323
1324- event.addresponse(u'That is "%s".' % output)
1325- if base_from == 64 and [True for plugin in ibid.processors if getattr(plugin, "feature", None) == "base64"]:
1326- event.addresponse(u'If you want a base64 encoding, use the "base64" feature.')
1327+ event.addresponse(u'That is "%s"', output)
1328+ if base_from == 64 and [True for plugin in ibid.processors if getattr(plugin, 'feature', None) == 'base64']:
1329+ event.addresponse(u'If you want a base64 encoding, use the "base64" feature')
1330
1331 # vi: set et sta sw=4 ts=4:
1332
1333=== modified file 'ibid/plugins/memo.py'
1334--- ibid/plugins/memo.py 2009-03-01 23:01:30 +0000
1335+++ ibid/plugins/memo.py 2009-03-08 13:16:28 +0000
1336@@ -60,11 +60,11 @@
1337 if not identity:
1338 identity = account.identities[0]
1339 if not to:
1340- event.addresponse(u"I don't know who %s is" % who)
1341+ event.addresponse(u"I don't know who %s is", who)
1342 return
1343
1344 if permission(u'recvmemo', to.account and to.account.id or None, to.source) != 'yes':
1345- event.addresponse(u'Just tell %s yourself' % who)
1346+ event.addresponse(u'Just tell %s yourself', who)
1347 return
1348
1349 memo = Memo(event.identity, to.id, memo, how.lower() in ('pm', 'privmsg', 'msg'))
1350@@ -95,11 +95,22 @@
1351 memos = get_memos(session, event)
1352
1353 for memo in memos:
1354- message = '%s: By the way, %s on %s told me to tell you %s %s ago' % (event.sender['nick'], memo.sender.identity, memo.sender.source, memo.memo, ago(datetime.now()-memo.time))
1355 if memo.private:
1356+ message = u'By the way, %(sender)s on %(source)s told me to tell you %(message)s %(ago)s ago' % {
1357+ 'sender': memo.sender.identity,
1358+ 'source': memo.sender.source,
1359+ 'message': memo.memo,
1360+ 'ago': ago(datetime.now()-memo.time),
1361+ }
1362 event.addresponse({'reply': message, 'target': event.sender['id']})
1363 else:
1364- event.addresponse(message)
1365+ event.addresponse(u'%(recipient)s: By the way, %(sender)s on %(source)s told me to tell you %(message)s %(ago)s ago', {
1366+ 'recipient': event.sender['nick'],
1367+ 'sender': memo.sender.identity,
1368+ 'source': memo.sender.source,
1369+ 'message': memo.memo,
1370+ 'ago': ago(datetime.now()-memo.time),
1371+ })
1372
1373 memo.delivered = True
1374 session.save_or_update(memo)
1375@@ -128,7 +139,7 @@
1376 memos = get_memos(session, event)
1377
1378 if len(memos) > 0:
1379- event.addresponse({'reply': 'You have %s messages' % len(memos), 'target': event.sender['id']})
1380+ event.addresponse({'reply': u'You have %s messages' % len(memos), 'target': event.sender['id']})
1381 else:
1382 memo_cache[event.identity] = None
1383
1384@@ -145,7 +156,7 @@
1385 def messages(self, event):
1386 session = ibid.databases.ibid()
1387 memos = get_memos(session, event, True)
1388- event.addresponse(', '.join(['%s: %s (%s)' % (memos.index(memo), memo.sender.identity, memo.time.strftime(self.datetime_format)) for memo in memos]))
1389+ event.addresponse(u'%s', u', '.join(['%s: %s (%s)' % (memos.index(memo), memo.sender.identity, memo.time.strftime(self.datetime_format)) for memo in memos]))
1390 session.close()
1391
1392 @match(r'message\s+(\d+)$')
1393@@ -153,7 +164,12 @@
1394 session = ibid.databases.ibid()
1395 memos = get_memos(session, event, True)
1396 memo = memos[int(number)]
1397- event.addresponse(u"From %s on %s at %s: %s" % (memo.sender.identity, memo.sender.source, memo.time.strftime(self.datetime_format), memo.memo))
1398+ event.addresponse(u"From %(sender)s on %(source)s at %(time)s: %(message)s", {
1399+ 'sender': memo.sender.identity,
1400+ 'source': memo.sender.source,
1401+ 'time': memo.time.strftime(self.datetime_format),
1402+ 'message': memo.memo,
1403+ })
1404 session.close()
1405
1406
1407
1408=== modified file 'ibid/plugins/misc.py'
1409--- ibid/plugins/misc.py 2009-03-03 22:52:47 +0000
1410+++ ibid/plugins/misc.py 2009-03-08 13:16:28 +0000
1411@@ -25,13 +25,13 @@
1412
1413 self.pot = [event.sender['nick']]
1414 sleep(self.time)
1415- event.addresponse(u"Coffee's ready for %s!" % u', '.join(self.pot))
1416+ event.addresponse(u"Coffee's ready for %s!", u', '.join(self.pot))
1417 self.pot = None
1418
1419 @match('^coffee\s+(?:please|pls)$')
1420 def coffee_accept(self, event):
1421 if not self.pot:
1422- event.addresponse(u"There isn't a pot on.")
1423+ event.addresponse(u"There isn't a pot on")
1424
1425 elif len(self.pot) >= self.cups:
1426 event.addresponse(u"Sorry, there aren't any more cups left")
1427@@ -47,7 +47,10 @@
1428
1429 @match(r'^version$')
1430 def show_version(self, event):
1431- event.addresponse(ibid_version() and u"I am version %s" % ibid_version() or u"I don't know what version I am :-(")
1432+ if ibid_version():
1433+ event.addresponse(u'I am version %s', ibid_version())
1434+ else:
1435+ event.addresponse(u"I don't know what version I am :-(")
1436
1437 help['dvorak'] = u"Makes text typed on a QWERTY keyboard as if it was Dvorak work, and vice-versa"
1438 class Dvorak(Processor):
1439@@ -65,10 +68,10 @@
1440
1441 @match(r'(?:asdf|dvorak)\s+(.+)')
1442 def convert_from_qwerty(self, event, text):
1443- event.addresponse(text.translate(self.typed_on_qwerty))
1444+ event.addresponse(u'%s', text.translate(self.typed_on_qwerty))
1445
1446 @match(r'(?:aoeu|qwerty)\s+(.+)')
1447 def convert_from_dvorak(self, event, text):
1448- event.addresponse(text.translate(self.typed_on_dvorak))
1449+ event.addresponse(u'%s', text.translate(self.typed_on_dvorak))
1450
1451 # vi: set et sta sw=4 ts=4:
1452
1453=== modified file 'ibid/plugins/morse.py'
1454--- ibid/plugins/morse.py 2009-03-05 16:33:12 +0000
1455+++ ibid/plugins/morse.py 2009-03-08 13:16:28 +0000
1456@@ -70,12 +70,12 @@
1457
1458 def morse2text(morse):
1459 rtable = dict((v, k) for k, v in table.items())
1460- toks = morse.split(' ')
1461+ toks = morse.split(u' ')
1462 return u" ".join(rtable.get(t, t) for t in toks)
1463
1464 if message.replace('-', '').replace('.', '').isspace():
1465- event.addresponse(morse2text(message))
1466+ event.addresponse(u'Decodes as %s', morse2text(message))
1467 else:
1468- event.addresponse(text2morse(message))
1469+ event.addresponse(u'Encodes as %s', text2morse(message))
1470
1471 # vi: set et sta sw=4 ts=4:
1472
1473=== modified file 'ibid/plugins/network.py'
1474--- ibid/plugins/network.py 2009-03-02 09:38:47 +0000
1475+++ ibid/plugins/network.py 2009-03-08 13:16:28 +0000
1476@@ -35,17 +35,20 @@
1477 try:
1478 answers = resolver.query(host, str(record))
1479 except NoAnswer:
1480- event.addresponse(u"I couldn't find any %s records for %s" % (record, host))
1481+ event.addresponse(u"I couldn't find any %(type)s records for %(host)s", {
1482+ 'type': record,
1483+ 'host': host,
1484+ })
1485 return
1486 except NXDOMAIN:
1487- event.addresponse(u"I couldn't find the domain %s" % host)
1488+ event.addresponse(u"I couldn't find the domain %s", host)
1489 return
1490
1491 responses = []
1492 for rdata in answers:
1493 responses.append(unicode(rdata))
1494
1495- event.addresponse(u', '.join(responses))
1496+ event.addresponse(u'Records: %s', u', '.join(responses))
1497
1498 help['ping'] = u'ICMP pings the specified host.'
1499 class Ping(Processor):
1500@@ -69,11 +72,12 @@
1501 code = ping.wait()
1502
1503 if code == 0:
1504- output = unicode_output(' '.join(output.splitlines()[-2:]))
1505- event.addresponse(output)
1506+ output = unicode_output(output)
1507+ output = u' '.join(output.splitlines()[-2:])
1508+ event.addresponse(u'%s', output)
1509 else:
1510- error = unicode_output(error.replace('\n', ' ').replace('ping:', '', 1).strip())
1511- event.addresponse(error)
1512+ error = unicode_output(error).replace(u'\n', u' ').replace(u'ping:', u'', 1).strip()
1513+ event.addresponse(u'Error: %s', error)
1514
1515 help['tracepath'] = u'Traces the path to the given host.'
1516 class Tracepath(Processor):
1517@@ -96,10 +100,10 @@
1518 if code == 0:
1519 output = unicode_output(output)
1520 for line in output.splitlines():
1521- event.addresponse(line)
1522+ event.addresponse(u'%s', line)
1523 else:
1524 error = unicode_output(error.strip())
1525- event.addresponse(error.replace('\n', ' '))
1526+ event.addresponse(u'Error: %s', error.replace(u'\n', u' '))
1527
1528 help['ipcalc'] = u'IP address calculator'
1529 class IPCalc(Processor):
1530@@ -133,14 +137,14 @@
1531
1532 if code == 0:
1533 output = unicode_output(output)
1534- if output.startswith("INVALID ADDRESS"):
1535+ if output.startswith(u"INVALID ADDRESS"):
1536 event.addresponse(u"That's an invalid address. Try something like 192.168.1.0/24")
1537 else:
1538 for line in output.splitlines():
1539 if line.strip():
1540- event.addresponse(line)
1541+ event.addresponse(u'%s', line)
1542 else:
1543 error = unicode_output(error.strip())
1544- event.addresponse(error.replace('\n', ' '))
1545+ event.addresponse(u'%s', error.replace(u'\n', u' '))
1546
1547 # vi: set et sta sw=4 ts=4:
1548
1549=== modified file 'ibid/plugins/rfc.py'
1550--- ibid/plugins/rfc.py 2009-03-05 12:23:21 +0000
1551+++ ibid/plugins/rfc.py 2009-03-08 13:16:28 +0000
1552@@ -157,9 +157,12 @@
1553
1554 number = int(number)
1555 if number in rfcs:
1556- event.addresponse(u"%s http://www.rfc-editor.org/rfc/rfc%i.txt " % (rfcs[number].record, number))
1557+ event.addresponse(u"%(record)s http://www.rfc-editor.org/rfc/rfc%(number)i.txt", {
1558+ 'record': rfcs[number].record,
1559+ 'number': number,
1560+ })
1561 else:
1562- event.addresponse(u"Sorry, no such RFC.")
1563+ event.addresponse(u"Sorry, no such RFC")
1564
1565 @match(r'^rfc\s+(?:for\s+)?(.+)$')
1566 def search(self, event, terms):
1567@@ -188,14 +191,16 @@
1568 pool.reverse()
1569
1570 if pool:
1571- response = u"Found %i matching RFC%s. Listing %i: " % (len(pool), len(pool) > 1 and u"s" or u"", min(len(pool), 5))
1572 results = []
1573 for result in pool[:5]:
1574 result.parse()
1575 results.append("%04i: %s" % (result.number, result.summary))
1576- response += u", ".join(results)
1577- event.addresponse(response)
1578+ event.addresponse(u'Found %(found)i matching RFCs. Listing %(listing)i: %(results)', {
1579+ 'found': len(pool),
1580+ 'listing': min(len(pool), 5),
1581+ 'results': u', '.join(results),
1582+ })
1583 else:
1584- event.addresponse(u"Sorry, can't find anything.")
1585+ event.addresponse(u"Sorry, can't find anything")
1586
1587 # vi: set et sta sw=4 ts=4:
1588
1589=== modified file 'ibid/plugins/roshambo.py'
1590--- ibid/plugins/roshambo.py 2009-03-02 09:21:35 +0000
1591+++ ibid/plugins/roshambo.py 2009-03-08 13:16:28 +0000
1592@@ -17,12 +17,12 @@
1593 bchoice = randint(0, 2)
1594
1595 if uchoice == bchoice:
1596- reply = u'We drew! I also chose %s' % choices[bchoice]
1597+ reply = u'We drew! I also chose %s'
1598 elif (uchoice + 1) % 3 == bchoice:
1599- reply = u'You win! I chose %s :-(' % choices[bchoice]
1600+ reply = u'You win! I chose %s :-('
1601 else:
1602- reply = u'I win! I chose %s' % choices[bchoice]
1603+ reply = u'I win! I chose %s'
1604
1605- event.addresponse(reply)
1606+ event.addresponse(reply, choices[bchoice])
1607
1608 # vi: set et sta sw=4 ts=4:
1609
1610=== modified file 'ibid/plugins/seen.py'
1611--- ibid/plugins/seen.py 2009-03-02 09:21:35 +0000
1612+++ ibid/plugins/seen.py 2009-03-08 13:16:28 +0000
1613@@ -82,7 +82,7 @@
1614 account = session.query(Account).filter_by(username=who).first()
1615
1616 if not identity and not account:
1617- event.addresponse(u"I don't know who %s is" % who)
1618+ event.addresponse(u"I don't know who %s is", who)
1619 return
1620
1621 messages = []
1622@@ -102,26 +102,26 @@
1623 states.append(sighting)
1624
1625 if len(messages) == 0 and len(states) == 0:
1626- event.addresponse(u"I haven't seen %s" % who)
1627+ event.addresponse(u"I haven't seen %s", who)
1628 return
1629
1630 messages.sort(key=lambda x: x.time, reverse=True)
1631 states.sort(key=lambda x: x.time, reverse=True)
1632
1633- reply = ''
1634+ reply = u''
1635 if len(messages) > 0:
1636 sighting = messages[0]
1637 delta = datetime.now() - sighting.time
1638 reply = u"%s was last seen %s ago in %s on %s" % (who, ago(delta), sighting.channel or 'private', sighting.identity.source)
1639- reply = u'%s [%s]' % (reply, sighting.time.strftime(self.datetime_format))
1640+ reply += u' [%s]' % sighting.time.strftime(self.datetime_format)
1641
1642 if len(states) > 0:
1643 sighting = states[0]
1644 if reply:
1645- reply = reply + u', and'
1646+ reply += u', and'
1647 else:
1648 reply = who
1649- reply = reply + u" has been %s on %s since %s" % (sighting.value, sighting.identity.source, sighting.time.strftime(self.datetime_format))
1650+ reply += u" has been %s on %s since %s" % (sighting.value, sighting.identity.source, sighting.time.strftime(self.datetime_format))
1651
1652 event.addresponse(reply)
1653 session.close()
1654
1655=== modified file 'ibid/plugins/sources.py'
1656--- ibid/plugins/sources.py 2009-03-01 23:01:30 +0000
1657+++ ibid/plugins/sources.py 2009-03-08 13:16:28 +0000
1658@@ -15,26 +15,26 @@
1659 def connect(self, event, source):
1660
1661 if ibid.sources[source.lower()].connect():
1662- event.addresponse(u'Connecting to %s' % source)
1663+ event.addresponse(u'Connecting to %s', source)
1664 else:
1665- event.addresponse(u"I couldn't connect to %s" % source)
1666+ event.addresponse(u"I couldn't connect to %s", source)
1667
1668 @match(r'^disconnect\s+(?:from\s+)?(\S+)$')
1669 @authorise
1670 def disconnect(self, event, source):
1671
1672 if ibid.sources[source.lower()].disconnect():
1673- event.addresponse(u'Disconnecting from %s' % source)
1674+ event.addresponse(u'Disconnecting from %s', source)
1675 else:
1676- event.addresponse(u"I couldn't disconnect from %s" % source)
1677+ event.addresponse(u"I couldn't disconnect from %s", source)
1678
1679 @match(r'^(?:re)?load\s+(\S+)\s+source$')
1680 @authorise
1681 def load(self, event, source):
1682 if ibid.reloader.load_source(source, ibid.service):
1683- event.addresponse(u"%s source loaded" % source)
1684+ event.addresponse(u"%s source loaded", source)
1685 else:
1686- event.addresponse(u"Couldn't load %s source" % source)
1687+ event.addresponse(u"Couldn't load %s source", source)
1688
1689 class Info(Processor):
1690 u"""(sources|list configured sources)"""
1691@@ -45,11 +45,11 @@
1692 sources = []
1693 for name, source in ibid.sources.items():
1694 url = source.url()
1695- sources.append(url and '%s (%s)' % (name, url) or name)
1696- event.addresponse(u', '.join(sources))
1697+ sources.append(url and u'%s (%s)' % (name, url) or name)
1698+ event.addresponse(u'Sources: %s', u', '.join(sorted(sources)))
1699
1700 @match(r'^list\s+configured\s+sources$')
1701 def listall(self, event):
1702- event.addresponse(', '.join(ibid.config.sources.keys()))
1703+ event.addresponse(u'Configured sources: %s', u', '.join(sorted(ibid.config.sources.keys())))
1704
1705 # vi: set et sta sw=4 ts=4:
1706
1707=== modified file 'ibid/plugins/test.py'
1708--- ibid/plugins/test.py 2009-03-01 14:29:51 +0000
1709+++ ibid/plugins/test.py 2009-03-08 13:16:28 +0000
1710@@ -8,7 +8,7 @@
1711 @match(r'^delay\s+(\d+\.?\d*)$')
1712 def handler(self, event, delay):
1713 sleep(float(delay))
1714- event.addresponse('Done')
1715+ event.addresponse(True)
1716
1717 class Authorise(Processor):
1718
1719@@ -23,14 +23,14 @@
1720
1721 @match(r'^email\s+(.+)$')
1722 def email(self, event, address):
1723- event.addresponse({'reply': 'Test message', 'source': 'email', 'target': unicode(address)})
1724- event.addresponse(u"I've emailed %s" % address)
1725+ event.addresponse({'reply': u'Test message', 'source': 'email', 'target': unicode(address)})
1726+ event.addresponse(u"I've emailed %s", address)
1727
1728 class Except(Processor):
1729
1730 @match(r'^raise\s+exception$')
1731 def handler(self, event):
1732- event.addresponse("I'll except in a moment")
1733+ event.addresponse(u"I'll except in a moment")
1734 raise Exception("Ow, that hurt.")
1735
1736 # vi: set et sta sw=4 ts=4:
1737
1738=== modified file 'ibid/plugins/tools.py'
1739--- ibid/plugins/tools.py 2009-03-02 09:38:47 +0000
1740+++ ibid/plugins/tools.py 2009-03-08 13:16:28 +0000
1741@@ -25,11 +25,11 @@
1742 @match('^rand(?:om)?(?:\s+(\d+)(?:\s+(\d+))?)?$')
1743 def random(self, event, begin, end):
1744 if not begin and not end:
1745- event.addresponse(unicode(random()))
1746+ event.addresponse(u'I always liked %f', random())
1747 else:
1748 begin = int(begin)
1749 end = end and int(end) or 0
1750- event.addresponse(unicode(randint(min(begin,end), max(begin,end))))
1751+ event.addresponse(u'I always liked %i', randint(min(begin,end), max(begin,end)))
1752
1753 help['units'] = 'Converts values between various units.'
1754 class Units(Processor):
1755@@ -91,13 +91,20 @@
1756 result = output.splitlines()[0].strip()
1757
1758 if code == 0:
1759- event.addresponse(result)
1760+ event.addresponse(u'%s', result)
1761 elif code == 1:
1762 if result == "conformability error":
1763- event.addresponse(u"I don't think %s can be converted to %s." % (frm, to))
1764+ event.addresponse(u"I don't think %(from)s can be converted to %(to)s", {
1765+ 'from': frm,
1766+ 'to': to,
1767+ })
1768 elif result.startswith("conformability error"):
1769- event.addresponse(u"I don't think %s can be converted to %s: %s" % (frm, to, result.split(":", 1)[1]))
1770+ event.addresponse(u"I don't think %(from)s can be converted to %(to)s: %(error)s", {
1771+ 'from': frm,
1772+ 'to': to,
1773+ 'error': result.split(":", 1)[1],
1774+ })
1775 else:
1776- event.addresponse(u"I can't do that: %s" % result)
1777+ event.addresponse(u"I can't do that: %s", result)
1778
1779 # vi: set et sta sw=4 ts=4:
1780
1781=== modified file 'ibid/plugins/trac.py'
1782--- ibid/plugins/trac.py 2009-03-06 13:50:19 +0000
1783+++ ibid/plugins/trac.py 2009-03-08 13:16:28 +0000
1784@@ -77,7 +77,19 @@
1785 ticket = self.get_ticket(int(number))
1786
1787 if ticket:
1788- event.addresponse(u'Ticket %s (%s %s %s in %s for %s) reported %s ago assigned to %s: "%s" %sticket/%s' % (ticket.id, ticket.status, ticket.priority, ticket.type, ticket.component, ticket.milestone, ago(datetime.now() - datetime.fromtimestamp(ticket.time), 2), ticket.owner, ticket.summary, self.url, ticket.id))
1789+ event.addresponse(u'Ticket %(id)s (%(status)s %(priority)s %(type)s in %(component)s for %(milestone)s) '
1790+ u'reported %(ago)s ago assigned to %(owner)s: "%(summary)s" %(url)sticket/%(id)s', {
1791+ 'id': ticket.id,
1792+ 'status': ticket.status,
1793+ 'priority': ticket.priority,
1794+ 'type': ticket.type,
1795+ 'component': ticket.component,
1796+ 'milestone': ticket.milestone,
1797+ 'ago': ago(datetime.now() - datetime.fromtimestamp(ticket.time), 2),
1798+ 'owner': ticket.owner,
1799+ 'summary': ticket.summary,
1800+ 'url': self.url,
1801+ })
1802 else:
1803 event.addresponse(u"No such ticket")
1804
1805@@ -108,7 +120,7 @@
1806 tickets = query.order_by(Ticket.id).all()
1807
1808 if len(tickets) > 0:
1809- event.addresponse(', '.join(['%s (%s): "%s"' % (ticket.id, ticket.owner, ticket.summary) for ticket in tickets]))
1810+ event.addresponse(u'%s', u', '.join(['%s (%s): "%s"' % (ticket.id, ticket.owner, ticket.summary) for ticket in tickets]))
1811 else:
1812 event.addresponse(u"No tickets found")
1813
1814
1815=== modified file 'ibid/plugins/url.py'
1816--- ibid/plugins/url.py 2009-03-01 23:01:30 +0000
1817+++ ibid/plugins/url.py 2009-03-08 13:16:28 +0000
1818@@ -56,7 +56,7 @@
1819 shortened = f.read()
1820 f.close()
1821
1822- event.addresponse(unicode(shortened))
1823+ event.addresponse(u'That reduces to: %s', shortened)
1824
1825 class NullRedirect(HTTPRedirectHandler):
1826
1827@@ -83,7 +83,7 @@
1828 f = opener.open(url)
1829 except HTTPError, e:
1830 if e.code in (301, 302, 303, 307):
1831- event.addresponse(unicode(e.hdrs['location']))
1832+ event.addresponse(u'That expands to: %s', e.hdrs['location'])
1833 return
1834
1835 f.close()

Subscribers

People subscribed via source and target branches