X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/a28e2ae95b1012933a01f3fa992d9f6954f82346..3cec5bdc665d310ac628e80b007dd2d71ae7d7bd:/modules/subtext.py diff --git a/modules/subtext.py b/modules/subtext.py index ca0ab04..ca23ec7 100644 --- a/modules/subtext.py +++ b/modules/subtext.py @@ -1,6 +1,7 @@ # Erebus IRC bot - Author: Erebus Team +# vim: fileencoding=utf-8 # module for 's/regex/replacement/' style correction -# see for usage examples: https://github.com/zonidjan/erebus/commit/d7e9802778477f1faa26a03078cb1b3c018a5e5c +# warning: arbitrary regex's are generally capable of various DoS attacks on CPU/memory usage. use with caution. # This file is released into the public domain; see http://unlicense.org/ # module info @@ -21,7 +22,7 @@ modstop = lib.modstop # module code import re from collections import namedtuple -re_findsub = re.compile(r"s(.)(?P[^\1]+)\1(?P[^\1]+)\1(?Pg)?;?") +re_findsub = re.compile(r"""s([/'";:!@#$%^&-_=`~])(?P.+?)\1(?P.*?)(?:\1(?Pg)?|$)""") Line = namedtuple('Line', ['sender', 'msg']) lastline = {} @lib.hooknum("PRIVMSG") @@ -29,7 +30,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: