2019-05-25 20:40:06 +00:00
|
|
|
#--depends-on config
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import ModuleManager, utils
|
2018-09-30 19:12:11 +00:00
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.export("serverset", {"setting": "strip-color",
|
2018-09-30 19:12:11 +00:00
|
|
|
"help": "Set whether I strip colors from my messages on this server",
|
2019-05-23 09:28:14 +00:00
|
|
|
"validate": utils.bool_or_none, "example": "on"})
|
2019-03-09 13:37:59 +00:00
|
|
|
@utils.export("channelset", {"setting": "strip-color",
|
|
|
|
"help": "Set whether I strip colors from my messages on in this channel",
|
2019-05-23 09:28:14 +00:00
|
|
|
"validate": utils.bool_or_none, "example": "on"})
|
2018-09-30 19:12:11 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2019-02-23 21:40:11 +00:00
|
|
|
@utils.hook("preprocess.send.privmsg")
|
|
|
|
@utils.hook("preprocess.send.notice")
|
2018-09-30 19:12:11 +00:00
|
|
|
def preprocess(self, event):
|
2019-06-16 08:52:04 +00:00
|
|
|
if len(event["line"].args) > 1:
|
|
|
|
strip_color = event["server"].get_setting("strip-color", False)
|
|
|
|
target = event["line"].args[0]
|
|
|
|
if not strip_color and target in event["server"].channels:
|
|
|
|
channel = event["server"].channels.get(target)
|
|
|
|
strip_color = channel.get_setting("strip-color", False)
|
2019-03-10 13:09:37 +00:00
|
|
|
|
2019-06-16 08:52:04 +00:00
|
|
|
if strip_color:
|
|
|
|
message = event["line"].args[1]
|
|
|
|
event["line"].args[1] = utils.irc.strip_font(message)
|