]> jfr.im git - erebus.git/commitdiff
minor updates to nitterize and subtext to ignore DMs
authorJohn Runyon <redacted>
Sat, 12 Aug 2023 03:53:24 +0000 (21:53 -0600)
committerJohn Runyon <redacted>
Sat, 12 Aug 2023 03:53:24 +0000 (21:53 -0600)
modules/nitterize.py
modules/subtext.py

index 2b4251f9559e713f424297e731e15836544c9b54..a0978fe7db1d3da8897bcbc86251a99f7025d194 100644 (file)
@@ -22,14 +22,15 @@ modstop = lib.modstop
 
 # module code
 import re
-from collections import namedtuple
 re_findtwitter = re.compile(r"""https?://(?:www\.)?(?:twitter|x)\.com/([-.a-z0-9/]+)""", re.I)
 
 @lib.hooknum("PRIVMSG")
 def privmsg_hook(bot, line):
        pieces = line.split(None, 3)
        chan = pieces[2]
+       if chan[0] != "#": return
        msg = pieces[3][1:]
+
        replaced = ""
        for mo in re_findtwitter.finditer(msg):
                replaced += re_findtwitter.sub(r"https://nitter.projectsegfau.lt/\1", mo.group(0)) + " "
index 88a2368e5747dc37f705f9938e10338f5587db86..2a87c0efd1d102b03937d275b304f0402b7fca0c 100644 (file)
@@ -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: