bitbot-3.11-fork/modules/strip_color.py

23 lines
1 KiB
Python
Raw Normal View History

from src import ModuleManager, utils
2018-09-30 19:12:11 +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"})
@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):
@utils.hook("preprocess.send.privmsg")
@utils.hook("preprocess.send.notice")
2018-09-30 19:12:11 +00:00
def preprocess(self, event):
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)
if strip_color:
message = event["line"].args.get(-1)
if not message == None:
event["line"].args[-1] = utils.irc.strip_font(message)