瀏覽代碼

Adding syntax cheat sheet to pattern

pull/13/head
Rocketsoup 2 月之前
父節點
當前提交
e5716dce5a
共有 1 個檔案被更改,包括 32 行新增8 行删除
  1. 32
    8
      rocketbot/cogs/patterncog.py

+ 32
- 8
rocketbot/cogs/patterncog.py 查看文件

@@ -6,8 +6,8 @@ import re
6 6
 from datetime import datetime
7 7
 from typing import Optional
8 8
 
9
-from discord import Guild, Member, Message, utils as discordutils, Permissions, Interaction
10
-from discord.app_commands import Choice, Group, autocomplete, rename
9
+from discord import Guild, Member, Message, utils as discordutils, Interaction
10
+from discord.app_commands import Choice, Group, autocomplete
11 11
 from discord.ext.commands import Cog
12 12
 
13 13
 from config import CONFIG
@@ -85,6 +85,33 @@ async def priority_autocomplete(interaction: Interaction, current: str) -> list[
85 85
 		Choice(name='very high (150)', value=150),
86 86
 	]
87 87
 
88
+_long_help = \
89
+"""Patterns are a powerful but complex topic. See <https://git.rixafrix.com/ialbert/python-app-rocketbot/src/branch/main/docs/patterns.md> for full documentation.
90
+
91
+### Quick cheat sheet
92
+
93
+> `/pattern add` _pattern\\_name_ _action\\_list_ `if` _expression_
94
+
95
+- _pattern\\_name_ is a brief name for identifying the pattern later (not shown to user)
96
+- _action\\_list_ is a comma-delimited list of actions to take on matching messages and is any of:
97
+   - `ban`
98
+   - `delete`
99
+   - `kick`
100
+   - `modinfo` - logs a message but doesn't tag mods
101
+   - `modwarn` - tags mods
102
+   - `reply` "message text"
103
+- _expression_ determines which messages match, of the form _field_ _op_ _value_.
104
+   - Fields:
105
+      - `content.markdown`: string
106
+      - `content.plain`: string
107
+      - `author`: user
108
+      - `author.id`: id
109
+      - `author.joinage`: timespan
110
+      - `author.name`: string
111
+      - `lastmatched`: timespan
112
+   - Operators: `==`, `!=`, `<`, `>`, `<=`, `>=`, `contains`, `!contains`, `matches`, `!matches`, `containsword`, `!containsword`
113
+   - Can combine multiple expressions with `!`, `and`, `or`, and parentheses."""
114
+
88 115
 class PatternCog(BaseCog, name='Pattern Matching'):
89 116
 	"""
90 117
 	Highly flexible cog for performing various actions on messages that match
@@ -100,7 +127,7 @@ class PatternCog(BaseCog, name='Pattern Matching'):
100 127
 			bot,
101 128
 			config_prefix='patterns',
102 129
 			short_description='Manages message pattern matching.',
103
-			long_description='Patterns are a powerful but complex topic. See <https://git.rixafrix.com/ialbert/python-app-rocketbot/src/branch/main/docs/patterns.md> for full documentation.'
130
+			long_description=_long_help
104 131
 		)
105 132
 		PatternCog.shared = self
106 133
 
@@ -264,17 +291,14 @@ class PatternCog(BaseCog, name='Pattern Matching'):
264 291
 		guild_only=True,
265 292
 		default_permissions=MOD_PERMISSIONS,
266 293
 		extras={
267
-			'long_description': 'Patterns are a powerful but complex topic. '
268
-								'See <https://git.rixafrix.com/ialbert/python-app-rocketbot/src/branch/main/docs/patterns.md> for full documentation.'
294
+			'long_description': _long_help,
269 295
 		},
270 296
 	)
271 297
 
272 298
 	@pattern.command(
273 299
 		description='Adds or updates a custom pattern.',
274 300
 		extras={
275
-			'long_description': 'Patterns use a simplified expression language. Full '
276
-								'documentation found here: '
277
-								'<https://git.rixafrix.com/ialbert/python-app-rocketbot/src/branch/main/docs/patterns.md>',
301
+			'long_description': _long_help,
278 302
 		},
279 303
 	)
280 304
 	@autocomplete(

Loading…
取消
儲存