|
|
@@ -3,9 +3,10 @@ Cog for matching messages against guild-configurable criteria and taking
|
|
3
|
3
|
automated actions on them.
|
|
4
|
4
|
"""
|
|
5
|
5
|
from datetime import datetime
|
|
6
|
|
-from typing import Optional
|
|
|
6
|
+from typing import Optional, Literal
|
|
7
|
7
|
|
|
8
|
|
-from discord import Guild, Member, Message, utils as discordutils
|
|
|
8
|
+from discord import Guild, Member, Message, utils as discordutils, Permissions, Interaction
|
|
|
9
|
+from discord.app_commands import Group, rename
|
|
9
|
10
|
from discord.ext import commands
|
|
10
|
11
|
|
|
11
|
12
|
from config import CONFIG
|
|
|
@@ -198,6 +199,30 @@ class PatternCog(BaseCog, name='Pattern Matching'):
|
|
198
|
199
|
did_kick=context.is_kicked,
|
|
199
|
200
|
did_ban=context.is_banned))
|
|
200
|
201
|
|
|
|
202
|
+ spattern = Group(
|
|
|
203
|
+ name='pattern',
|
|
|
204
|
+ description='Manages message pattern matching.',
|
|
|
205
|
+ guild_only=True,
|
|
|
206
|
+ default_permissions=Permissions(Permissions.manage_messages.flag),
|
|
|
207
|
+ )
|
|
|
208
|
+ @spattern.command()
|
|
|
209
|
+ @rename(expression='if')
|
|
|
210
|
+ async def test(
|
|
|
211
|
+ self,
|
|
|
212
|
+ interaction: Interaction,
|
|
|
213
|
+ actions: str,
|
|
|
214
|
+ expression: str
|
|
|
215
|
+ ) -> None:
|
|
|
216
|
+ vals = [ actions, expression ]
|
|
|
217
|
+ arg_list = ''
|
|
|
218
|
+ for arg in vals:
|
|
|
219
|
+ if arg is not None:
|
|
|
220
|
+ arg_list += f'- "`{arg}`"\n'
|
|
|
221
|
+ await interaction.response.send_message(
|
|
|
222
|
+ "Got /pattern test call with arguments\n" + arg_list,
|
|
|
223
|
+ ephemeral=True,
|
|
|
224
|
+ )
|
|
|
225
|
+
|
|
201
|
226
|
@commands.group(
|
|
202
|
227
|
brief='Manages message pattern matching',
|
|
203
|
228
|
)
|