]> jfr.im git - erebus.git/blobdiff - modules/subtext.py
urls - allow port in url
[erebus.git] / modules / subtext.py
index 894c3f847d221c5c22d3c39d8a6e062471f5c6c2..ca23ec7dda620f4d1aedb75a0d436e8e0d4b3b21 100644 (file)
@@ -2,7 +2,6 @@
 # vim: fileencoding=utf-8
 # module for 's/regex/replacement/' style correction
 # warning: arbitrary regex's are generally capable of various DoS attacks on CPU/memory usage. use with caution.
-# see for usage examples: https://github.com/zonidjan/erebus/commit/d7e9802778477f1faa26a03078cb1b3c018a5e5c
 # This file is released into the public domain; see http://unlicense.org/
 
 # module info
@@ -23,7 +22,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,10 +30,11 @@ 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:
-               bot.msg(chan, `mo.groups()`)
                if mo.group('global') is not None:
                        count = 0 # unlimited
                else: