From 31d107c0bd7fa2e172b09cce9560f3a10c1091af Mon Sep 17 00:00:00 2001 From: "Sean B. Palmer" Date: Sat, 9 Aug 2008 16:01:20 +0100 Subject: [PATCH] Minor fixes, full stop stripping of tell nicknames &c. --- modules/etymology.py | 2 +- modules/head.py | 8 ++++++-- modules/reload.py | 3 +++ modules/tell.py | 5 +++-- opt/freenode.py | 13 ++++++++----- opt/swhack.py | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/modules/etymology.py b/modules/etymology.py index a26f06f..9f3c7b2 100755 --- a/modules/etymology.py +++ b/modules/etymology.py @@ -94,7 +94,7 @@ def f_etymology(self, origin, match, args): msg = 'Can\'t find the etymology for "%s". Try %s' % (word, uri) self.msg(origin.sender, msg) # @@ Cf. http://swhack.com/logs/2006-01-04#T01-50-22 -f_etymology.rule = (['ety'], r"([A-Za-z0-9' -]+)") +f_etymology.rule = (['ety'], r"([A-Za-z0-9' .-]+)") f_etymology.thread = True f_etymology.priority = 'high' diff --git a/modules/head.py b/modules/head.py index c271de1..4cb19e3 100755 --- a/modules/head.py +++ b/modules/head.py @@ -135,8 +135,12 @@ def f_title(self, origin, match, args): return unichr(char).encode('utf-8') title = r_entity.sub(e, title) - if not title: - title = '[Title is the empty document, "".]' + if title: + try: title.decode('iso-8859-1') + except: pass + else: title = title.decode('iso-8859-1').encode('utf-8') + else: title = '[The title is empty.]' + self.msg(origin.sender, origin.nick + ': ' + title) else: self.msg(origin.sender, origin.nick + ': No title found') f_title.commands = ['title'] diff --git a/modules/reload.py b/modules/reload.py index 6e65dd2..a48b625 100755 --- a/modules/reload.py +++ b/modules/reload.py @@ -14,6 +14,9 @@ def f_reload(phenny, input): if not input.admin: return name = input.group(2) + if name == phenny.config.owner: + return phenny.reply('What?') + if (not name) or (name == '*'): phenny.setup() return phenny.reply('done') diff --git a/modules/tell.py b/modules/tell.py index ef9f171..2f39986 100755 --- a/modules/tell.py +++ b/modules/tell.py @@ -39,7 +39,8 @@ def dumpReminders(fn, data): for tellee in data.iterkeys(): for remindon in data[tellee]: line = '\t'.join((tellee,) + remindon) - f.write(line + '\n') + try: f.write(line + '\n') + except IOError: break try: f.close() except IOError: pass return True @@ -64,7 +65,7 @@ def f_remind(phenny, input): tellee = tellee.encode('utf-8') msg = msg.encode('utf-8') - tellee_original = tellee.rstrip(',:;') + tellee_original = tellee.rstrip('.,:;') tellee = tellee_original.lower() if not os.path.exists(phenny.tell_filename): diff --git a/opt/freenode.py b/opt/freenode.py index 7e188f9..91620ce 100755 --- a/opt/freenode.py +++ b/opt/freenode.py @@ -16,20 +16,23 @@ def replaced(phenny, input): 'compare': '.compare has been replaced by .gcs (googlecounts)', 'map': 'the .map command has been removed; ask sbp for details', 'acronym': 'the .acronym command has been removed; ask sbp for details', - 'img': 'the .img command has been removed; ask sbp for details', + # 'img': 'the .img command has been removed; ask sbp for details', 'v': '.v has been replaced by .val', 'validate': '.validate has been replaced by .validate', 'thesaurus': ".thesaurus hasn't been ported to my new codebase yet", - 'rates': "moon wanter. moOOoon wanter!", + # 'rates': "moon wanter. moOOoon wanter!", 'web': 'the .web command has been removed; ask sbp for details', - 'origin': ".origin hasn't been ported to my new codebase yet" + 'origin': ".origin hasn't been ported to my new codebase yet", + # 'gs': 'sorry, .gs no longer works', + 'swhack': 'sorry, .swhack no longer works' } try: response = responses[command] except KeyError: return else: phenny.reply(response) replaced.commands = [ - 'cp', 'pc', 'unicode', 'compare', 'map', 'acronym', 'img', - 'v', 'validate', 'thesaurus', 'rates', 'web', 'mangle', 'origin' + 'cp', 'pc', 'unicode', 'compare', 'map', 'acronym', + 'v', 'validate', 'thesaurus', 'web', 'mangle', 'origin', + 'swhack' ] replaced.priority = 'low' diff --git a/opt/swhack.py b/opt/swhack.py index 60914c0..9183911 100755 --- a/opt/swhack.py +++ b/opt/swhack.py @@ -28,7 +28,7 @@ def swhack(phenny, input): phenny.reply('Sorry, no results found.') u.close() -swhack.commands = ['swhack'] +# swhack.commands = ['swhack'] if __name__ == '__main__': print __doc__.strip()