Selaa lähdekoodia

Experimenting with /pattern options

pull/13/head
Rocketsoup 2 kuukautta sitten
vanhempi
commit
92bc12f2eb
2 muutettua tiedostoa jossa 33 lisäystä ja 7 poistoa
  1. 27
    2
      rocketbot/cogs/patterncog.py
  2. 6
    5
      rocketbot/cogsetting.py

+ 27
- 2
rocketbot/cogs/patterncog.py Näytä tiedosto

3
 automated actions on them.
3
 automated actions on them.
4
 """
4
 """
5
 from datetime import datetime
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
 from discord.ext import commands
10
 from discord.ext import commands
10
 
11
 
11
 from config import CONFIG
12
 from config import CONFIG
198
 			did_kick=context.is_kicked,
199
 			did_kick=context.is_kicked,
199
 			did_ban=context.is_banned))
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
 	@commands.group(
226
 	@commands.group(
202
 		brief='Manages message pattern matching',
227
 		brief='Manages message pattern matching',
203
 	)
228
 	)

+ 6
- 5
rocketbot/cogsetting.py Näytä tiedosto

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

Loading…
Peruuta
Tallenna