🏡 index : ~doyle/dave.git

author Jordan Doyle <jordan@doyle.wf> 2017-07-22 11:38:24.0 +01:00:00
committer Jordan Doyle <jordan@doyle.wf> 2017-07-22 11:38:24.0 +01:00:00
commit
553b5296d12cb11053fd60c425bc20a7051fe004 [patch]
tree
a88070dbc90bc4afd702e97cbafc834dce2d8753
parent
95b217b221b230165c8445816e4555f8f4aabc21
download
553b5296d12cb11053fd60c425bc20a7051fe004.tar.gz

bold replacements and fix bug in logging messages beginning with y or s



Diff

 dave/modules/sed.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/dave/modules/sed.py b/dave/modules/sed.py
index 13ae71f..6de4092 100644
--- a/dave/modules/sed.py
+++ a/dave/modules/sed.py
@@ -5,7 +5,6 @@
from twisted.words.protocols.irc import assembleFormattedText, attributes as A
import re


@dave.module.help("Syntax: s/find/replace/flags", "sed")
@dave.module.match(r"^((s|y)(/|\||!)(.*?)(\3)(.*?)(\3)([gIi]+)?)$")
@dave.module.priority(dave.module.Priority.HIGHEST)
@@ -20,11 +19,9 @@
            f = f | re.IGNORECASE

        try:
            replace = re.sub(args[3],
                             assembleFormattedText(A.bold[args[5]]),
                             msg,
                             count=0 if 'g' in flags else 1,
                             flags=f)
            # bold replacements
            replace = re.sub(args[3], "\x02{}\x0F".format(args[5]),
                             msg, count=0 if 'g' in flags else 1, flags=f)
        except Exception as e:
            bot.reply(source, sender,
                      "There was a problem with your sed command: {}".format(str(e)))
@@ -37,9 +34,9 @@
            return


@dave.module.match(r"^(?!(?:s|y)([\x00-\x7F])(?:.*?)(?:\1)(?:.*?)(?:\1)(?:[gIi\d]+)?)(.*)$")
@dave.module.match(r"(.*)")
@dave.module.priority(dave.module.Priority.LOWEST)
def update_cache(bot, args, sender, source):
    key = "msg:{}:{}".format(source, sender)
    dave.config.redis.lpush(key, args[1])
    dave.config.redis.lpush(key, args[0])
    dave.config.redis.ltrim(key, 0, 2)