summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2009-06-18 14:20:12 +0100
committerSean B. Palmer <http://inamidst.com/sbp/>2009-06-18 14:20:12 +0100
commit5d48dd8ca7a317daf772d0627f0843d315c49876 (patch)
tree65244001e5d3a118cf7e29aeb5c5612016018551 /modules
parentb35681c7593bc2935d1421d4de342a1453878445 (diff)
downloadbot-5d48dd8ca7a317daf772d0627f0843d315c49876.tar.gz
bot-5d48dd8ca7a317daf772d0627f0843d315c49876.tar.bz2
bot-5d48dd8ca7a317daf772d0627f0843d315c49876.zip
Run setup when reloading a module.
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/clock.py8
-rwxr-xr-xmodules/oblique.py2
-rwxr-xr-xmodules/reload.py2
3 files changed, 10 insertions, 2 deletions
diff --git a/modules/clock.py b/modules/clock.py
index 80d1c73..e648f41 100755
--- a/modules/clock.py
+++ b/modules/clock.py
@@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2.
http://inamidst.com/phenny/
"""
-import math, time, urllib
+import re, math, time, urllib, locale
from tools import deprecated
TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9,
@@ -190,6 +190,8 @@ TZ3 = {
TimeZones.update(TZ1)
TimeZones.update(TZ3)
+r_local = re.compile(r'\([a-z]+_[A-Z]+\)')
+
@deprecated
def f_time(self, origin, match, args):
"""Returns the current time."""
@@ -211,6 +213,10 @@ def f_time(self, origin, match, args):
if (TZ == 'UTC') or (TZ == 'Z'):
msg = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
self.msg(origin.sender, msg)
+ elif r_local.match(tz): # thanks to Mark Shoulsdon (clsn)
+ locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8'))
+ msg = time.strftime("%A, %d %B %Y %H:%M:%SZ", time.gmtime())
+ self.msg(origin.sender, msg)
elif TimeZones.has_key(TZ):
offset = TimeZones[TZ] * 3600
timenow = time.gmtime(time.time() + offset)
diff --git a/modules/oblique.py b/modules/oblique.py
index 49e7d8c..b4efa77 100755
--- a/modules/oblique.py
+++ b/modules/oblique.py
@@ -23,7 +23,7 @@ def mappings(uri):
if not ' ' in item: continue
command, template = item.split(' ', 1)
- if not command.isalpha(): continue
+ if not command.isalnum(): continue
if not template.startswith('http://'): continue
result[command] = template.replace('&amp;', '&')
return result
diff --git a/modules/reload.py b/modules/reload.py
index a48b625..fc508a6 100755
--- a/modules/reload.py
+++ b/modules/reload.py
@@ -25,6 +25,8 @@ def f_reload(phenny, input):
except ImportError:
module = getattr(__import__('opt.' + name), name)
reload(module)
+ if hasattr(module, 'setup'):
+ module.setup(phenny)
if hasattr(module, '__file__'):
import os.path, time