quotes.py: allow opting out of quotes

This commit is contained in:
David Schultz 2021-06-24 20:57:14 -05:00
parent 0fa184d48f
commit b7e1cc96f1
No known key found for this signature in database
GPG key ID: F6DED672FFFD5E5E

View file

@ -5,6 +5,9 @@ from src import ModuleManager, utils
@utils.export("channelset", utils.BoolSetting("channel-quotes",
"Whether or not quotes added from this channel are kept in this channel"))
@utils.export("set", utils.BoolSetting("quotable",
"Whether or not you wish to be quoted"))
class Module(ModuleManager.BaseModule):
def category_and_quote(self, s):
category, sep, quote = s.partition("=")
@ -31,6 +34,11 @@ class Module(ModuleManager.BaseModule):
"channel-quotes", False):
target = event["target"]
if not event["server"].get_user(category).get_setting(
"quotable", True):
event["stderr"].write("%s does not wish to be quoted" % category)
return
quotes = self._get_quotes(target, category)
quotes.append([event["user"].name, int(time.time()), quote])
self._set_quotes(target, category, quotes)
@ -148,6 +156,10 @@ class Module(ModuleManager.BaseModule):
text = " ".join(lines_str)
quote_category = line.sender
if not event["server"].get_user(quote_category).get_setting(
"quotable", True):
event["stderr"].write("%s does not wish to be quoted" % quote_category)
return
if event["server"].has_user(quote_category):
quote_category = event["server"].get_user_nickname(
event["server"].get_user(quote_category).get_id())