Skip to content

Commit

Permalink
feat black_canned_message chanel options
Browse files Browse the repository at this point in the history
  • Loading branch information
a3510377 committed Feb 1, 2024
1 parent aec4cb1 commit ae8f5a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ async def on_message(self, msg: Message):
"canned_message",
{},
)
if (key := msg.content) in canned_message:
if (
(key := msg.content) in canned_message
and msg.channel.id
not in (self.config.get("black_canned_message_channel", {})).get(key, [])
and msg.channel.parent_id
not in (self.config.get("black_canned_message_parent", {})).get(key, [])
):
await msg.channel.send(
random.choice(value)
if type(value := canned_message[key]) is list
Expand Down
2 changes: 2 additions & 0 deletions plugins/discord/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class DiscordConfig(Config):
online_display_name = "雲鎮工藝"
online_icon_url = "AUTO"
canned_message: dict[str, str | list[str]] = {}
black_canned_message_channel: dict[str, list[int]] = {}
black_canned_message_parent: dict[str, list[int]] = {}


class Discord(Plugin, config=DiscordConfig):
Expand Down

0 comments on commit ae8f5a4

Please sign in to comment.