summaryrefslogtreecommitdiffstats
path: root/modules/reload.py
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2008-02-21 12:06:33 +0000
committerSean B. Palmer <http://inamidst.com/sbp/>2008-02-21 12:06:33 +0000
commit7931fab14599b739c18c8f1ebcc24b75688dbc09 (patch)
treebf4df9757f10c155e3b6f78aed48f15884ebbbe6 /modules/reload.py
downloadbot-7931fab14599b739c18c8f1ebcc24b75688dbc09.tar.gz
bot-7931fab14599b739c18c8f1ebcc24b75688dbc09.tar.bz2
bot-7931fab14599b739c18c8f1ebcc24b75688dbc09.zip
Phenny2, now being tested on Freenode as the main phenny.
Diffstat (limited to 'modules/reload.py')
-rwxr-xr-xmodules/reload.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/reload.py b/modules/reload.py
new file mode 100755
index 0000000..257eaf7
--- /dev/null
+++ b/modules/reload.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+"""
+reload.py - Phenny Module Reloader Module
+Copyright 2008, Sean B. Palmer, inamidst.com
+Licensed under the Eiffel Forum License 2.
+
+http://inamidst.com/phenny/
+"""
+
+import irc
+
+def f_reload(phenny, input):
+ """Reloads a module, for use by admins only."""
+ if not input.admin: return
+
+ name = match.group(2)
+ module = getattr(__import__('modules.' + name), name)
+ reload(module)
+
+ if hasattr(module, '__file__'):
+ import os.path, time
+ mtime = os.path.getmtime(module.__file__)
+ modified = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(mtime))
+ else: modified = 'unknown'
+
+ self.register(vars(module))
+ self.bind_commands()
+
+ phenny.reply('%r (version: %s)' % (module, modified))
+f_reload.name = 'reload'
+f_reload.rule = ('$nick', ['reload'], r'(\S+)')
+
+if __name__ == '__main__':
+ print __doc__.strip()