소스 검색

Documentation updates

tags/2.0.0
Rocketsoup 2 달 전
부모
커밋
613d33aef8
6개의 변경된 파일480개의 추가작업 그리고 55개의 파일을 삭제
  1. 17
    36
      README.md
  2. 278
    0
      docs/commands.md
  3. BIN
      docs/icon.png
  4. 51
    18
      docs/patterns.md
  5. 133
    0
      docs/setup.md
  6. 1
    1
      rocketbot/cogs/patterncog.py

+ 17
- 36
README.md 파일 보기

@@ -1,48 +1,29 @@
1
-# python-app-rocketbot
1
+# Rocketbot
2 2
 
3
-Experimental Discord bot written in Python.
3
+Discord bot for detecting and dealing with jerks. This bot is Rocketsoup's fault.
4 4
 
5 5
 ## Requirements
6 6
 
7
-* Written for Python 3.9
8
-* Install dependencies with `pip3.9 install -r requirements.txt`
7
+* Python 3.9
8
+
9
+## Setup
10
+
11
+See main document, [docs/setup.md](Setup).
12
+
13
+In brief, the full setup process is:
14
+- create a Discord application in their developer portal
15
+- configure a `config.py`
16
+- install Python dependencies
17
+- run the `bot.py` script
18
+- invite the bot to your server
19
+- do additional configuration for your guild using chat commands
9 20
 
10 21
 ## Usage
11 22
 
23
+See main document, [docs/commands.md](Commands).
24
+
12 25
 * To see the list of commands, type `$rb_help`.
13 26
 * To get help on a specific command, type `$rb_help commandname` (don't prefix the command name you want help on). E.g. `$rb_help hello`.
14 27
 * To get help on a command group, type `$rb_help groupname`. E.g. `$rb_help config`.
15 28
 * To get help on a subcommand in a group, type `$rb_help groupname commandname`. E.g. `$rb_help config setwarningchannel`.
16 29
 * To see if the bot is alive, type `$rb_hello`.
17
-* Other commands are too numerous and always changing to document here, so see `$rb_help` for more.
18
-
19
-## Setup
20
-
21
-Currently the bot is just run in the console locally. It blocks until Ctrl+C is
22
-pressed. Before running, you must copy config.py.sample to config.py and fill
23
-in the "client_token" value. To get a token, visit
24
-https://discord.com/developers/applications and create an application. Then
25
-create a bot for the application and enable the "server members intent". Click
26
-the "copy" button in the "token" section near the top and paste this value into
27
-config.py's "client_token" attribute.
28
-
29
-Create a "config" subdirectory under your source folder. This is where guild-specific configuration is written as JSON files.
30
-
31
-To start, run `python3 bot.py`. Then visit
32
-https://discord.com/oauth2/authorize?client_id=[application_id]&scope=bot&permissions=395204357318,
33
-where [application_id] is the "application id" value on your app configuration
34
-"general information" page. Once invited, test if the bot is working by typing
35
-`$rb_hello` in your Discord server.
36
-
37
-Once running, you should immediately set up a warning channel and optionally a
38
-user/role to tag in warning messages. Go to a channel you want warnings to be
39
-posted (typically a channel the general userbase cannot see) and type
40
-`$rb_config setwarningchannel`. This will set that channel as the destination
41
-for warnings about suspicious behavior on the server. To have these messages
42
-tag a user or role (such as `@Mods`), type `$rb_config setwarningmention @userorrole`.
43
-This must be an actual autocompleted @ mention that shows up in a different
44
-color, not just the name of the user/role. Otherwise warning messages will
45
-be prefixed with that plaintext name, not with an actual @. To mention several
46
-people or roles, enclose the whole list in double quotes. E.g.
47
-`$rb_config setwarningmention "@Mod @Admin"`. You can test out this configuration
48
-by entering `$rb_testwarn` to issue a test warning.

+ 278
- 0
docs/commands.md 파일 보기

@@ -0,0 +1,278 @@
1
+# Commands
2
+
3
+Rocketbot's functionality is broken into different functional areas that
4
+typically have a master switch to enable/disable it and some other configuration.
5
+Configuration is specific to each server the bot is invited to.
6
+
7
+For all the examples here, I'm assuming the default command prefix of `$rb_`.
8
+If you set a different one in `config.py`, translate accordingly.
9
+
10
+## Log channel
11
+
12
+The first thing you'll want to do is configure a channel where bot messages
13
+can go. This should be a channel only mods can see. Go into that channel and
14
+type
15
+
16
+```
17
+$rb_config setwarningchannel
18
+```
19
+
20
+This ensures warnings will go somewhere appropriate.
21
+
22
+You will probably also want to set a role to tag for important warnings to get
23
+their attention. E.g. to tag the `@Mod` role type
24
+
25
+```
26
+$rb_config setwarningmention @Mod
27
+```
28
+
29
+Entering that will configure who to mention, and it will also mention them right
30
+now in that message you just typed. Apologize to all the mods who you just
31
+bothered and explain you were just configuring a cool new bot.
32
+
33
+## Help!!
34
+
35
+I don't remember the commands for my own bot, so I don't expect you will either.
36
+The only thing you need to remember is `$rb_help`. The bot will reply with a
37
+summary of all the top-level commands available. As an example:
38
+
39
+```
40
+Auto Kick:
41
+  autokick       Automatically kicks all new users as soon as they join
42
+Configuration:
43
+  config         Manages general bot configuration
44
+Crosspost Detection:
45
+  crosspost      Manages crosspost detection and handling
46
+General:
47
+  deletemessages Mass deletes messages
48
+  hello          Simple test reply
49
+  shutdown       Shuts down the bot
50
+  testwarn       Posts a test warning
51
+Join Age:
52
+  joinage        Tracks recently joined users with options to mass kick or ban
53
+Join Raids:
54
+  joinraid       Manages join raid detection and handling
55
+Logging:
56
+  logging        Manages event logging
57
+Pattern Matching:
58
+  pattern        Manages message pattern matching
59
+URL Spam:
60
+  urlspam        Manages URL spam detection
61
+Username Pattern:
62
+  username       Manages username pattern detection
63
+No Category:
64
+  help           Shows this message
65
+
66
+Type $rb_help command for more info on a command.
67
+You can also type $rb_help category for more info on a category.
68
+```
69
+
70
+Each section is known internally as a "cog". If you're mucking around in the code,
71
+each cog is its own source file in the `rocketbot/cogs` directory. But you can
72
+just think of them as categories. Some of these are commands of their own (e.g.
73
+`hello`, invoked with `$rb_hello`) but most have subcommands. You can find out
74
+more using `$rb_help commandname`, e.g. `$rb_help config` will show subcommands for
75
+config.
76
+
77
+```
78
+$rb_config
79
+
80
+General guild configuration command group
81
+
82
+Commands:
83
+  getwarningchannel Shows the mod warning channel
84
+  getwarningmention Shows the user/role to mention in warning messages
85
+  setwarningchannel Sets the mod warning channel
86
+  setwarningmention Sets a user/role to mention in warning messages
87
+
88
+Type $rb_help command for more info on a command.
89
+You can also type $rb_help category for more info on a category.
90
+```
91
+
92
+And then you can invoke a subcommand with `$rb_commandname subcommandname`. e.g.
93
+`$rb_config setwarningchannel`. To get more info about a subcommand, use `$rb_help`
94
+again. e.g. `$rb_help config setwarningchannel`.
95
+
96
+## Cogs
97
+
98
+This section goes through each cog, what it does, and how to use it.
99
+
100
+### Autokick
101
+
102
+Autokick is a feature of last resort, a sort of lockdown mode that immediately
103
+kicks all new users who join. (Users who joined before enabling this are fine.)
104
+We have on one occasion had some kind of bot that was doing tons and tons of
105
+joins, and there was no other way to stop them. Obviously something you want to
106
+supervise and disable as soon as the threat has passed.
107
+
108
+Subcommands
109
+- `enable`/`disable` - Toggle autokicking
110
+- `getbancount`/`setbancount` - If the same person keeps rejoining after being
111
+    kicked, ban them after this many rejoins.
112
+- `getofflineonly`/`setofflineonly` - Whether to only kick users who join with
113
+    a status of offline. That's not impossible in ordinary use, but it's
114
+    suspect and likely indicative of bots versus real users.
115
+
116
+### Config
117
+
118
+General config that isn't specific to one cog.
119
+
120
+Subcommands
121
+- `getwarningchannel`/`setwarningchannel` - Determines the channel where log
122
+    messages are posted. Setting the warning channel doesn't take an argument; it
123
+    uses the current channel you typed the command in.
124
+- `getwarningmention`/`setwarningmention` - The user or role you want tagged when
125
+    the bot needs to alert someone of suspicious activity. Needs to be a proper
126
+    autocompleted @ mention, not just the name.
127
+
128
+### Crosspost detection
129
+
130
+Detects an extremely common pattern we see of someone joining and copy/pasting
131
+the exact same message in as many channels as possible. This cog will look at
132
+recent messages from a user and see which ones contain the exact same text in
133
+multiple channels, and if it exceeds the configured number within the configured
134
+time span, it's ban hammer time.
135
+
136
+Subcommands
137
+- `enable`/`disable` - Master toggle for this entire feature.
138
+- `getwarncount`/`setwarncount` - How many duplicate messages will cause a
139
+    warning message to be posted that alerts the mods.
140
+- `getbancount`/`setbancount` - How many duplicate messages should result in an
141
+    automatic ban. Should be greater than the warning count.
142
+- `gettimespan`/`settimespan` - Sets the time window within which to look for
143
+    duplicates. Value is in seconds. Spammers usually fire these off very quickly,
144
+    so a minute or less is more than enough.
145
+- `getminlength`/`setminlength` - For text-only messages, sets the minimum length
146
+    to be considered for duplicate detection. Maybe a benign (but annoying) user
147
+    posts "lol" at everything in multiple channels. Use this to filter for that
148
+    case.
149
+
150
+### General
151
+
152
+These are just general top-level commands, not subcommands.
153
+
154
+Commands
155
+- `deletemessages <@user> <timespan>` - Manually deletes a bunch of messages by a
156
+    particular user. Useful if you banned but accidentally forgot to delete
157
+    recent history, or to clean up after someone had a bit of a manic posting
158
+    spree. The timespan is a value like "30s" for 30 seconds, "5m" for 5
159
+    minutes, or "1h30m" for an hour and a half. NOTE: This only works for fairly
160
+    recent messages. You can't use it to delete things posted way back in the
161
+    scrollback.
162
+- `hello` - Just for testing bot responsiveness. Or a desperate need to be seen.
163
+- `shutdown` - Terminates the bot. I forgot this was here. I've never needed it.
164
+    If somehow the bot goes rogue and you're not there to ctrl+C it, use this.
165
+- `testwarn` - Posts a test mod warning in the configured warning channel with
166
+    the configured mention user/role.
167
+
168
+### Join age
169
+
170
+This cog isn't really needed any more since the Members tab was added to Discord.
171
+It's used for seeing who joined most recently. The list of recent joins is only
172
+kept in memory, and it keeps a limited number, so it's really only useful for
173
+the past few days.
174
+
175
+Subcommands
176
+- `enable`/`disable` - Toggle join tracking.
177
+- `getjointime`/`setjointime` - How long to track a join, in seconds.
178
+- `search <timespan>` - Shows all users who joined in the last x length of time.
179
+    Values are like `30s` for 30 seconds, `5m` for 5 minutes, `1h30m` for an hour
180
+    and a half, etc.
181
+
182
+### Join raids
183
+
184
+While not as common in the past year or two, we used to get a suspicious number
185
+of users all joining in very close succession with no obvious cause, followed
186
+by users being spammed in DMs by them. This cog attempts to alert us to such
187
+spikes in joins.
188
+
189
+Subcommands
190
+- `enable`/`disable` - Toggle the feature.
191
+- `getjoincount`/`setjoincount` - Sets the minimum number of suspicious joins.
192
+- `getjointime`/`setjointime` - Sets the span of time that number of joins must
193
+    occur to be suspicious, in seconds.
194
+
195
+### Logging
196
+
197
+We found it valuable to log certain events, namely message edits and deletions,
198
+due to some users frequently saying something questionable and then covering
199
+their tracks. We used to use another bot to do that until it silently just
200
+decided to stop being maintained. Thanks. So this cog attempts to reproduce
201
+that, logging as many meaningful events as possible.
202
+
203
+Subcommands
204
+- `enable`/`disable` - You get the full firehose or you get nothing.
205
+
206
+### Patterns
207
+
208
+This is the most flexible cog. It can match arbitrary messages with complex
209
+criteria and take a number of automatic actions on them. The full syntax is kind
210
+of complex and is detailed in its [own document](patterns.md).
211
+
212
+Subcommands
213
+- `add ...` - Adds a new pattern to look for (see [Patterns](patterns.md)).
214
+- `remove <name>` - Removes a previously added pattern by name.
215
+- `list` - Show all configured patterns.
216
+- `setpriority <name> <priority>` - Alters the priority of a pattern. The
217
+    priority is a unitless value used to pick which pattern wins if a message
218
+    matches more than one. Patterns without priorities set have a default value
219
+    of 100. The highest value wins.
220
+
221
+### URL spam
222
+
223
+This cog detects two kinds of suspicious link post behaviors.
224
+
225
+The first is posting a link suspiciously soon after joining. Honestly, this has
226
+had a pretty low hit rate. Join age seems unreliable. Supposedly, Discord
227
+imposes a 10m cooldown after joining a server before you can post, but I've
228
+seen people post within the first minute. And they are usually benign, like a
229
+reaction GIF or relevant Twitch clip. While the actual spammers don't seem to
230
+get flagged, as they seem to use accounts that have been lying in wait a long
231
+time. YMMV.
232
+
233
+The second is deceptive links. Discord added the ability in 2024 or 25 to change
234
+the text of a link instead of it always just showing the URL using the markdown
235
+syntax `[link text](https://urlhere)` which shows up as "link text" in blue.
236
+While Discord does warn users whenever they click a link where the text isn't
237
+exactly the same as the URL, this happens in benign circumstances often enough
238
+that users may ignore it. Discord prevents posting mismatching URLs like
239
+`[https://goodsite.com](https://badsite.com)`, however it doesn't prevent posting
240
+things that are URL-like, like `[goodsite.com](https://badsite.com)` (without
241
+the `https://`). Our deceptive link detection catches these URL-like link labels.
242
+
243
+Subcommands
244
+- `enable`/`disable` - Toggle the feature.
245
+- `getjoinage`/`setjoinage` - Sets the length of time after joining when posted
246
+    links are considered suspicious, in seconds.
247
+- `getaction`/`setaction` - Action to take when a join age link is detected.
248
+    One of these values:
249
+    - `nothing` - Ignore
250
+    - `modwarn` - Post a warning message in the log channel and tag mods.
251
+    - `delete` - Delete the message.
252
+    - `kick` - Kick the user.
253
+    - `ban` - Ban the user.
254
+- `getdeceptiveaction`/`setdeceptiveaction` - Action to take when a deceptive
255
+    link is detected. One of these values:
256
+    - `nothing` - Ignore
257
+    - `modwarn` - Post a warning message in the log channel and tag mods.
258
+    - `modwarndelete` - Post a mod warning message and delete the message.
259
+    - `chatwarn` - Reply to the message in the same channel calling out the
260
+        suspicious link.
261
+    - `chatwarndelete` - Reply to the message and delete it.
262
+    - `delete` - Delete the message.
263
+    - `kick` - Kick the user.
264
+    - `ban` - Ban the user.
265
+
266
+### Username patterns
267
+
268
+Notifies us when users with certain usernames join a server. Problem users will
269
+often get banned and just create another similarly named account, so this
270
+helps us catch ban evasion. When a matching username joins the server, a mod
271
+warning message will be posted in the log channel. The pattern is just a simple
272
+substring matched case-insensitively.
273
+
274
+Subcommands
275
+- `enable`/`disable` - Toggle the feature.
276
+- `add <pattern>` - Adds a substring to look for in usernames of newly joined members.
277
+- `remove <pattern>` - Removes a pattern.
278
+- `list` - Lists all tracked patterns.

BIN
docs/icon.png 파일 보기


patterns.md → docs/patterns.md 파일 보기

@@ -1,28 +1,39 @@
1 1
 # Patterns
2 2
 
3
-The PatternCog offers a way of creating custom message filters of moderate complexity without needing to make code changes in the bot and redeploy it. A guild can have any number of custom patterns. The commands are:
3
+The PatternCog offers a way of creating custom message filters of moderate
4
+complexity without needing to make code changes in the bot and redeploy it. A
5
+guild can have any number of custom patterns. The commands are:
4 6
 
5 7
 * `$rb_pattern add <name> <statement>` - Add a new named pattern
6 8
 * `$rb_pattern remove <name>` - Remove a named pattern
7 9
 * `$rb_pattern list` - List all named patterns
8 10
 
9
-The pattern `<name>` can be anything. If it contains spaces, enclose it in double quotes, e.g. `"my filter"`.
11
+The pattern `<name>` can be anything. If it contains spaces, enclose it in
12
+double quotes, e.g. `"my filter"`.
10 13
 
11 14
 ## Statements
12 15
 
13
-A statement consists of one or more actions to take on a message followed by an expression defining the criteria for which messages match. For example:
16
+A statement consists of one or more actions to take on a message followed by an
17
+expression defining the criteria for which messages match. For example:
14 18
 
15 19
 ```
16 20
 reply "You can't say that word!", delete if message contains "heck"
17 21
 ```
18 22
 
19
-This statement has two actions: replying, then deleting the original message. It will match any message that contains the word "heck".
23
+This statement has two actions (separated by a comma): replying, then deleting
24
+the original message. It will match any message that contains the word "heck".
20 25
 
21
-The list of actions and the matching expression are separated by the word "if", which must be present in every statement.
26
+The list of actions and the matching expression are separated by the word "if",
27
+which must be present in every statement.
28
+
29
+```
30
+<action>, <action>, ..., <action> if <condition>
31
+```
22 32
 
23 33
 ### Actions
24 34
 
25
-One or more actions can be added to the statement. If there is more than one, they are separated with commas. Example:
35
+One or more actions can be added to the statement. If there is more than one,
36
+they are separated with commas. Example:
26 37
 
27 38
 ```
28 39
 delete, kick, modwarn
@@ -33,13 +44,20 @@ Available actions:
33 44
 * `ban` - Bans the user. The "reason" in the audit log will reference the pattern name.
34 45
 * `delete` - Deletes the message.
35 46
 * `kick` - Kicks the user. The "reason" in the audit log will reference the pattern name.
36
-* `modinfo` - Posts an informative message in the bot warning channel but does not tag the mods. Useful for logging a pattern that is mildly harmful but not worth getting immediate mod attention. Message will have reactions to delete, kick, or ban.
37
-* `modwarn` - Tags the mods in a warning message. The message will offer quick actions to manually delete the message, kick the user, and ban the user (assuming the other actions didn't already do one or more of these things)
38
-* `reply "message"` - Makes Rocketbot automatically reply to their message with the given text.
47
+* `modinfo` - Posts an informative message in the bot warning channel but does
48
+    not tag the mods. Useful for logging a pattern that is mildly harmful but
49
+    not worth getting immediate mod attention. Message will have options to
50
+    delete, kick, or ban.
51
+* `modwarn` - Tags the mods in a warning message. The message will offer quick
52
+    actions to manually delete the message, kick the user, and ban the user
53
+    (assuming the other actions didn't already do one or more of these things)
54
+* `reply "message"` - Makes Rocketbot automatically reply to their message with
55
+    the given text.
39 56
 
40 57
 ### Expressions
41 58
 
42
-The simplest expression just consists of a message field, a comparison operator, and a value to compare it to. For example:
59
+The simplest expression just consists of a message field, a comparison operator,
60
+and a value to compare it to. For example:
43 61
 
44 62
 ```
45 63
 content.plain contains "forbidden"
@@ -51,13 +69,28 @@ The available operators and type of value depends on the field being accessed.
51 69
 
52 70
 #### Fields
53 71
 
54
-* `author` - Who sent the message. Available operators: `==`, `!=`. Comparison value must be a user mention (an @ that Discord will tab-complete for you).
55
-* `author.id` - The numeric ID of the user who sent the message. Available operators: `==`, `!=`. Comparison value must be a numeric user ID.
56
-* `author.joinage` - How much time has elapsed from when the author joined and when the message was sent. If the user has joined and left multiple times this is the most recent join time. Available operators: `==`, `!=`, `<`, `>`, `<=`, `>=`. Comparison value must be a timespan (see below)
57
-* `author.name` - The username of the author. Available operators: `==`, `!=`, `contains`, `!contains`, `containsword`, `!containsword`, `matches`, `!matches`. Comparison value must be a quoted string.
58
-* `content.plain` - The plain text of the message. All markdown formatting is removed, and mentions look like the `@Username` text name that gets displayed.
59
-* `content.markdown` - The raw markdown of the message. This contains all markdown characters, and mentions are of the `<@!0000000>` form. Available operators: `==`, `!=`, `contains`, `!contains`, `matches`, `!matches`. Comparison value must be a quoted string.
60
-* `lastmatched` - How long ago this pattern matched a message. Used for imposing a cooldown, especially for autoresponses. If the pattern has never matched it will be treated as if it last ran 100 years ago for comparison purposes. Available operators: `==`, `!=`, `<`, `>`, `<=`, `>=`. Comparison value must be a timespan (see below).
72
+* `author` - Who sent the message. Available operators: `==`, `!=`. Comparison
73
+    value must be a user mention (an @ that Discord will tab-complete for you).
74
+* `author.id` (alias `author`) - The numeric ID of the user who sent the message. Available
75
+    operators: `==`, `!=`. Comparison value must be a numeric user ID.
76
+* `author.joinage` - How much time has elapsed from when the author joined and
77
+    when the message was sent. If the user has joined and left multiple times
78
+    this is since the most recent join. Available operators: `==`, `!=`, `<`,
79
+    `>`, `<=`, `>=`. Comparison value must be a timespan (see below)
80
+* `author.name` - The username of the author. Available operators: `==`, `!=`,
81
+    `contains`, `!contains`, `containsword`, `!containsword`, `matches`,
82
+    `!matches`. Comparison value must be a quoted string.
83
+* `content.plain` - The plain text of the message. All markdown formatting is
84
+    removed, and mentions look like the `@Username` text name that gets displayed.
85
+* `content.markdown` (alias `content`) - The raw markdown of
86
+    the message. This contains all markdown characters, and mentions are of the
87
+    `<@!0000000>` form. Available operators: `==`, `!=`, `contains`, `!contains`,
88
+    `matches`, `!matches`. Comparison value must be a quoted string.
89
+* `lastmatched` - How long ago this pattern matched a message. Used for imposing
90
+    a cooldown, especially for autoresponses. If the pattern has never matched
91
+    it will be treated as if it last ran 100 years ago for comparison purposes.
92
+    Available operators: `==`, `!=`, `<`, `>`, `<=`, `>=`. Comparison value must
93
+    be a timespan (see below).
61 94
 
62 95
 #### Operators
63 96
 
@@ -140,7 +173,7 @@ $rb_pattern add "lunch" reply "Lunch is at noon." if content.plain == "When is l
140 173
 
141 174
 `<ws>` ::= SPACE | TAB | CR | LF | `<ws>` `<ws>`
142 175
 
143
-`<actions>` ::= `<action>` | `<action>` `<ws>` `<actions>`
176
+`<actions>` ::= `<action>` | `<action>` "," `<ws>` `<actions>`
144 177
 
145 178
 `<action>` ::= "ban" | "delete" | "kick" | "modinfo" | "modwarn" | "reply" `<ws>` `<quoted_string>`
146 179
 

+ 133
- 0
docs/setup.md 파일 보기

@@ -0,0 +1,133 @@
1
+# Setup
2
+
3
+## Make Discord application
4
+
5
+A Discord application is the record in Discord's servers about your bot. An
6
+application can be a lot of things, not just bots, but we only care about bots.
7
+You can think of it sort of like the bot's Discord account but with more nerdy
8
+settings. When you run the bot script, it will authenticate as this application
9
+and assume the identify of the bot user in Discord. Authentication is done via
10
+a client token, discussed more later.
11
+
12
+Rocketsoup is currently running the bot under an application entry he created
13
+under his own account, and running the bot script in a terminal on his own computer.
14
+Professional! If someone will be taking over the bot, they'll likely want to
15
+create their own application under their own account (or a shared account perhaps).
16
+
17
+The application portal can be found here: https://discord.com/developers/applications
18
+Click "New Application" and give it a name, e.g. Rocketbot. Then click into it
19
+to see its settings. It's been a while since I set this up, and things are
20
+always changing, but settings of note:
21
+- **General Information > App Icon** - You can use this or some other 1024x1024 image:
22
+    [icon.png](icon.png). This is what shows up when inviting the bot to a server.
23
+- **General Information > Application ID** - Take note of this. You'll need it later.
24
+- **Installation > Installation Contexts** - Enable "Guild Install", disable "User Install"
25
+- **Bot > Icon** - Same image as the App Icon above. This is what actually shows
26
+    as the bot's avatar in Discord.
27
+- **Bot > Username** - What the bot shows up as in Discord.
28
+- **Bot > Token** - ⚠️ IMPORTANT. This is the client token to authenticate the
29
+    bot. It needs to be filled in the config. You will only be shown the value
30
+    ONCE!! So store it somewhere safe, like a password manager! If you lose it
31
+    you can create a new one. More below on what to do with this value.
32
+- **Bot > Privileged Gateway Intents** - These give the bot broad categories of
33
+    privileges for certain kinds of data. Since Rocketbot is pretty broad in its
34
+    functionality, it needs a lot. Enable:
35
+    - **Presence Intent** - For tracking joins/leaves, I think
36
+    - **Server Members Intent** - For getting member info
37
+    - **Message Content Intent** - To be able to get the text and other details about messages
38
+
39
+> [!TIP]
40
+> It can be useful to set up a second application specifically for testing.
41
+> e.g. I have a "Rocketbot Test" application, configured exactly the same as
42
+> the production application, but it can be in a completely independent
43
+> list of servers for testing and can run at the same time as the production
44
+> one.
45
+
46
+## Configure bot script
47
+
48
+The bot relies on `config.py` for its general configuration. (Settings for each
49
+individual guild are stored elsewhere; more on that later.) You'll want to rename
50
+or copy `config.sample.py` to `config.py` and open it in an editor. The file
51
+consists of a single `CONFIG` dict.
52
+
53
+The most essential value to set is `CONFIG.client_token`. The client token you got
54
+above in the Discord application portal that you _definitely stored in a safe
55
+place like I told you_ is what you want to paste here.
56
+
57
+You may also want to set `CONFIG.config_path`. In retrospect, that's confusing
58
+naming. Anyway, it's the path to a directory where guild-specific settings will
59
+be stored. It can be wherever makes sense to you. I just store em in a `config`
60
+subdirectory in the project itself. That's probably a bad idea for reasons I'm
61
+too bad a programmer to know about. Store 'em wherever you want. (These guild
62
+setting files are a good candidate for timely backups, btw, if that influences
63
+your choice. Maybe a synced cloud folder?)
64
+
65
+If you'd like, you can also change the command prefix. The bot recognizes commands
66
+by looking for messages that start with this prefix. E.g. if the prefix is `$rb_`
67
+(the default) then typing the message `$rb_help` will invoke the `help` command
68
+and respond with a list of other commands.
69
+
70
+## Run the script
71
+
72
+I wrote this for Python 3.9, and its only dependency is the Discord.py library.
73
+I am bad at Python, so use these instructions only until a grown up programmer
74
+can be found to give you better ones. I'm on Mac, so apologies for any inadvertent
75
+Mac-specificness. Linux will be similar. Windows probably won't be as similar.
76
+
77
+1. Set up a virtual environment and install dependencies (only need to do this once)
78
+    ```shell
79
+    python3.9 -m venv .venv
80
+    source .venv/bin/activate
81
+    pip install -r requirements.txt
82
+    ```
83
+2. Run the bot
84
+    ```shell
85
+    source .venv/bin/activate   # skip if you already just did it above
86
+    python bot.py
87
+    ```
88
+
89
+It will take a few seconds to connect and when you see output like this it means
90
+it's ready and listening for things to happen.
91
+
92
+```
93
+[2025-12-11T16:30:51|-|-] Bot initializing...
94
+[2025-12-11T16:30:51|-|-] Type $rb_help in Discord for available commands.
95
+[2025-12-11T16:30:52|GeneralCog|-] Connected
96
+[2025-12-11T16:30:54|GeneralCog|-] Bot done initializing
97
+----------------------------------------------------------
98
+```
99
+
100
+Leave it running and, I dunno, minimize the window or something. You can see
101
+events logged here as they come up. If you wanna stop the bot, just hit ctrl+C.
102
+
103
+## Invite bot to your server
104
+
105
+You can invite the bot to your server by constructing a link like so:
106
+```
107
+https://discord.com/oauth2/authorize?client_id=APPIDHERE&scope=bot&permissions=4290289506188502
108
+```
109
+The `APPIDHERE` is the value in the application portal under General Information >
110
+Application ID. ⚠️IMPORTANT: It is NOT your client token. That's a secret; your
111
+application ID isn't. It's an 18-digit number, give or take. That URL can be used
112
+by anyone to invite the bot to their server. It will prompt you for which server
113
+to invite it to and ask you if you want to grant it a bunch of server permissions.
114
+Give it everything it asks for. It'll probably be fine.
115
+
116
+> [!NOTE] The other big multidigit number in that URL is the permissions mask, and
117
+> it affects what checkboxes appear in that invite screen. That number is determined
118
+> using the calculator in the application dashboard at the bottom of the Bot section.
119
+> While I started out being more selective in only requesting the permissions I
120
+> knew I needed, I kept bumping into access errors for one thing or another. So
121
+> now I'm just like gimme damn near everything unless I know for sure I don't need it.
122
+
123
+## Configure bot for your server
124
+
125
+You can verify the bot is working by typing `$rb_hello` in chat on that server
126
+and it should reply to you.
127
+
128
+The bot has a number of "cogs" (a term the Discord.py library uses) for distinct
129
+bits of functionality with their own commands and subcommands. E.g. the thingy
130
+that detects join raids is its own cog. They're all disabled by default, so
131
+you'll want to enable whichever ones suit you.
132
+
133
+More details in [Commands][commands.md].

+ 1
- 1
rocketbot/cogs/patterncog.py 파일 보기

@@ -204,7 +204,7 @@ class PatternCog(BaseCog, name='Pattern Matching'):
204 204
 		description='Adds a custom pattern. Patterns use a simplified ' + \
205 205
 			'expression language. Full documentation found here: ' + \
206 206
 			'https://git.rixafrix.com/ialbert/python-app-rocketbot/src/' + \
207
-			'branch/master/patterns.md',
207
+			'branch/main/docs/patterns.md',
208 208
 		usage='<pattern_name> <expression...>',
209 209
 		ignore_extra=True
210 210
 	)

Loading…
취소
저장