Run setup when reloading a module.
parent
b35681c759
commit
5d48dd8ca7
|
@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2.
|
||||||
http://inamidst.com/phenny/
|
http://inamidst.com/phenny/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import math, time, urllib
|
import re, math, time, urllib, locale
|
||||||
from tools import deprecated
|
from tools import deprecated
|
||||||
|
|
||||||
TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9,
|
TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9,
|
||||||
|
@ -190,6 +190,8 @@ TZ3 = {
|
||||||
TimeZones.update(TZ1)
|
TimeZones.update(TZ1)
|
||||||
TimeZones.update(TZ3)
|
TimeZones.update(TZ3)
|
||||||
|
|
||||||
|
r_local = re.compile(r'\([a-z]+_[A-Z]+\)')
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
def f_time(self, origin, match, args):
|
def f_time(self, origin, match, args):
|
||||||
"""Returns the current time."""
|
"""Returns the current time."""
|
||||||
|
@ -211,6 +213,10 @@ def f_time(self, origin, match, args):
|
||||||
if (TZ == 'UTC') or (TZ == 'Z'):
|
if (TZ == 'UTC') or (TZ == 'Z'):
|
||||||
msg = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
|
msg = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
|
||||||
self.msg(origin.sender, msg)
|
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):
|
elif TimeZones.has_key(TZ):
|
||||||
offset = TimeZones[TZ] * 3600
|
offset = TimeZones[TZ] * 3600
|
||||||
timenow = time.gmtime(time.time() + offset)
|
timenow = time.gmtime(time.time() + offset)
|
||||||
|
|
|
@ -23,7 +23,7 @@ def mappings(uri):
|
||||||
if not ' ' in item: continue
|
if not ' ' in item: continue
|
||||||
|
|
||||||
command, template = item.split(' ', 1)
|
command, template = item.split(' ', 1)
|
||||||
if not command.isalpha(): continue
|
if not command.isalnum(): continue
|
||||||
if not template.startswith('http://'): continue
|
if not template.startswith('http://'): continue
|
||||||
result[command] = template.replace('&', '&')
|
result[command] = template.replace('&', '&')
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -25,6 +25,8 @@ def f_reload(phenny, input):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
module = getattr(__import__('opt.' + name), name)
|
module = getattr(__import__('opt.' + name), name)
|
||||||
reload(module)
|
reload(module)
|
||||||
|
if hasattr(module, 'setup'):
|
||||||
|
module.setup(phenny)
|
||||||
|
|
||||||
if hasattr(module, '__file__'):
|
if hasattr(module, '__file__'):
|
||||||
import os.path, time
|
import os.path, time
|
||||||
|
|
Loading…
Reference in New Issue