Kaynağa Gözat

Experimenting with /pattern options

pull/13/head
Rocketsoup 2 ay önce
ebeveyn
işleme
92bc12f2eb
2 değiştirilmiş dosya ile 33 ekleme ve 7 silme
  1. 27
    2
      rocketbot/cogs/patterncog.py
  2. 6
    5
      rocketbot/cogsetting.py

+ 27
- 2
rocketbot/cogs/patterncog.py Dosyayı Görüntüle

@@ -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
 	)

+ 6
- 5
rocketbot/cogsetting.py Dosyayı Görüntüle

@@ -25,14 +25,15 @@ from rocketbot.utils import bot_log, TimeDeltaTransformer
25 25
 BaseCog = TypeVar('BaseCog', bound='rocketbot.cogs.BaseCog')
26 26
 
27 27
 class CogSetting:
28
-	permissions: Permissions = Permissions(Permissions.manage_messages.flag)
29
-
30 28
 	"""
31 29
 	Describes a configuration setting for a guild that can be edited by the
32
-	mods of those guilds. BaseCog can generate "get" and "set" commands (or
33
-	"enable" and "disable" commands for boolean values) automatically, reducing
30
+	mods of those guilds. BaseCog can generate "/get" and "/set" commands (or
31
+	"/enable" and "/disable" commands for boolean values) automatically, reducing
34 32
 	the boilerplate of generating commands manually. Offers simple validation rules.
35 33
 	"""
34
+
35
+	permissions: Permissions = Permissions(Permissions.manage_messages.flag)
36
+
36 37
 	def __init__(self,
37 38
 			name: str,
38 39
 			datatype: Optional[Type],
@@ -52,7 +53,7 @@ class CogSetting:
52 53
 		brief: Optional[str]
53 54
 			Description of the setting, starting with lower case.
54 55
 			Will be inserted into phrases like "Sets <brief>" and
55
-			"Gets <brief".
56
+			"Gets <brief>".
56 57
 		description: Optional[str]
57 58
 		  	Long-form description. Min, max, and enum values will be
58 59
 		    appended to the end, so does not need to include these.

Loading…
İptal
Kaydet