]> jfr.im git - erebus.git/blobdiff - modules/subtext.py
subtext - allow empty replace
[erebus.git] / modules / subtext.py
index 88a2368e5747dc37f705f9938e10338f5587db86..c0c0fd1ec2c768a812aefd2aa86a0b74961f0e03 100644 (file)
@@ -23,7 +23,7 @@ modstop = lib.modstop
 # module code
 import re
 from collections import namedtuple
-re_findsub = re.compile(r"""s([/'";:!@#$%^&-_=`~])(?P<search>.+?)\1(?P<replace>.+?)(?:\1(?P<global>g)?|$)""")
+re_findsub = re.compile(r"""s([/'";:!@#$%^&-_=`~])(?P<search>.+?)\1(?P<replace>.*?)(?:\1(?P<global>g)?|$)""")
 Line = namedtuple('Line', ['sender', 'msg'])
 lastline = {}
 @lib.hooknum("PRIVMSG")
@@ -31,7 +31,9 @@ def privmsg_hook(bot, line):
        pieces = line.split(None, 3)
        fromnick = pieces[0][1:].split('!')[0]
        chan = pieces[2]
+       if chan[0] != "#": return
        msg = pieces[3][1:]
+
        mo = re_findsub.match(msg)
        if mo:
                if mo.group('global') is not None: