diff --git a/modules/alias/__init__.py b/modules/alias/__init__.py index 65b1b71..f655c0d 100644 --- a/modules/alias/__init__.py +++ b/modules/alias/__init__.py @@ -68,7 +68,7 @@ def parseanswer (msg): def parseask (msg): global ALIAS if re.match(".*(set|cr[ée]{2}|nouvel(le)?) alias.*", msg.content) is not None: - result = re.match(".*alias !?([a-zA-Z0-9_-]+) (pour|=|:) (.+)$", msg.content) + result = re.match(".*alias !?([^ ]+) (pour|=|:) (.+)$", msg.content) if result.group(1) in DATAS.getNode("aliases").index or result.group(3).find("alias") >= 0: msg.send_snd("Cet alias est déjà défini.") else: diff --git a/modules/ddg/__init__.py b/modules/ddg/__init__.py index 6227bde..5708049 100644 --- a/modules/ddg/__init__.py +++ b/modules/ddg/__init__.py @@ -1,8 +1,10 @@ # coding=utf-8 +import imp + nemubotversion = 3.0 -from .DDGSearch import DDGSearch +from . import DDGSearch from . import WFASearch lastSearch = dict() @@ -11,6 +13,10 @@ def load(): global CONF WFASearch.CONF = CONF +def reload(): + imp.reload(DDGSearch) + imp.reload(WFASearch) + def parseanswer(msg): global lastSearch req = None @@ -30,11 +36,12 @@ def parseanswer(msg): if len(msg.cmd) > 1: if req == "wfa": s = WFASearch.WFASearch(' '.join(msg.cmd[1:])) + #print (s.wfares) if not s.success: - msg.send_chn("An error occurs during computation") + msg.send_chn(s.error) return True else: - s = DDGSearch(' '.join(msg.cmd[1:])) + s = DDGSearch.DDGSearch(' '.join(msg.cmd[1:])) if req == "def": msg.send_chn(s.definition) diff --git a/modules/events/__init__.py b/modules/events/__init__.py index 1aceb2b..be29c61 100644 --- a/modules/events/__init__.py +++ b/modules/events/__init__.py @@ -1,5 +1,6 @@ # coding=utf-8 +import imp import re import sys from datetime import timedelta @@ -7,10 +8,10 @@ from datetime import datetime import time import threading -from module_state import ModuleState - nemubotversion = 3.0 +from module_state import ModuleState + from . import Manager def help_tiny (): @@ -32,6 +33,9 @@ def load(): threadManager = Manager.Manager(DATAS, SRVS) threadManager.start() +def reload(): + imp.reload(Manager) + def close(): global threadManager if threadManager is not None: diff --git a/modules/ycc/Tinyfier.py b/modules/ycc/Tinyfier.py index 33f015d..2132805 100644 --- a/modules/ycc/Tinyfier.py +++ b/modules/ycc/Tinyfier.py @@ -2,6 +2,7 @@ import http.client import threading +import re class Tinyfier(threading.Thread): def __init__(self, url, msg): diff --git a/modules/ycc/__init__.py b/modules/ycc/__init__.py index 46f74b2..23ef418 100644 --- a/modules/ycc/__init__.py +++ b/modules/ycc/__init__.py @@ -1,10 +1,11 @@ # coding=utf-8 import http.client +import imp import re import sys -from .Tinyfier import Tinyfier +from . import Tinyfier nemubotversion = 3.0 @@ -13,8 +14,10 @@ def help_tiny (): return "Gets YCC urls" def help_full (): - return "TODO" + return "!ycc []: with an argument, reduce the given thanks to ycc.fr; without argument, reduce the last URL said on the current channel." +def reload(): + imp.reload(Tinyfier) def parseanswer(msg): global LAST_URLS @@ -22,14 +25,14 @@ def parseanswer(msg): if len(msg.cmd) == 1: if msg.channel in LAST_URLS and len(LAST_URLS[msg.channel]) > 0: url = LAST_URLS[msg.channel].pop() - t = Tinyfier(url, msg) + t = Tinyfier.Tinyfier(url, msg) t.start() else: msg.send_chn("%s: je n'ai pas d'autre URL reduire" % msg.sender) else: if len(msg.cmd) < 6: for url in msg.cmd[1:]: - t = Tinyfier(url, msg) + t = Tinyfier.Tinyfier(url, msg) t.start() else: msg.send_chn("%s: je ne peux pas réduire autant d'URL d'un seul coup." % msg.sender) diff --git a/prompt.py b/prompt.py index 546588a..6e4e1b0 100644 --- a/prompt.py +++ b/prompt.py @@ -120,6 +120,10 @@ def load_module_from_name(name, servers, config=None): if md.name == name: mod = imp.reload(md) loaded = True + try: + mod.reload() + except AttributeError: + pass break if not loaded: mod = __import__(name)