# Erebus IRC bot - Author: Erebus Team
# 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
+# nitterize twitter links
# This file is released into the public domain; see http://unlicense.org/
# module info
'author': 'Erebus Team',
'license': 'public domain',
'compatible': [0], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'depends': ['urls'], # other modules required to work properly?
'softdeps': [], # modules which are preferred but not required
}
replaced = ""
for mo in re_findtwitter.finditer(msg):
- replaced += re_findtwitter.sub(r"https://nitter.projectsegfau.lt/\1", mo.group(0)) + " "
+ replaced += re_findtwitter.sub(bot.parent.cfg.get('nitterize', 'instance', 'https://nitter.net') + r"\1", mo.group(0)) + " "
if replaced:
- bot.msg(chan, "%s" % (replaced))
+ bot.msg(chan, replaced)
+ titles = lib.mod('urls').process_line(replaced)
+ lib.mod('urls').send_response(bot, chan, titles)
+
+@lib.hook(glevel=lib.STAFF, needchan=False)
+@lib.argsEQ(1)
+def setnitter(bot, user, chan, realtarget, *args):
+ newnitter = args[0]
+ if newnitter[-1] != "/":
+ newnitter += "/"
+ bot.parent.cfg.set('nitterize', 'instance', newnitter)
+ return 'Done'