Skip to content

Commit 17b2f89

Browse files
committed
add use_random_channel_name, resolve #3143
1 parent fff100d commit 17b2f89

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ however, insignificant breaking changes do not guarantee a major version bump, s
2222
- `plain_snippets` config to force all snippets to be plain. ([GH #3083](https://github.com/kyb3r/modmail/issues/3083))
2323
- `?fpareply` and `?fpreply` to reply to messages with variables plainly.
2424
- `use_nickname_channel_name` config to use nicknames instead of usernames for channel names. ([GH #3112](https://github.com/kyb3r/modmail/issues/3112))
25+
- `use_random_channel_name` config to use random nicknames vaguely tied to user ID. It is unable to be computed in reverse. ([GH #3143](https://github.com/kyb3r/modmail/issues/3143)
2526
- `show_log_url_button` config to show Log URL button. ([GH #3122](https://github.com/kyb3r/modmail/issues/3122))
2627
- Select menus for certain paginators.
2728
- `Title` field in `?logs`. ([GH #3142](https://github.com/kyb3r/modmail/issues/3142))

bot.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
__version__ = "4.0.0-dev11"
1+
__version__ = "4.0.0-dev12"
22

33

44
import asyncio
55
import copy
6+
import hashlib
67
import logging
78
import os
89
import re
@@ -1690,7 +1691,11 @@ def format_channel_name(self, author, exclude_channel=None, force_null=False):
16901691
if force_null:
16911692
name = new_name = "null"
16921693
else:
1693-
if self.config["use_user_id_channel_name"]:
1694+
if self.config["use_random_channel_name"]:
1695+
to_hash = self.token.split(".")[-1] + str(author.id)
1696+
digest = hashlib.md5(to_hash.encode("utf8"))
1697+
name = new_name = digest.hexdigest()[-8:]
1698+
elif self.config["use_user_id_channel_name"]:
16941699
name = new_name = str(author.id)
16951700
elif self.config["use_timestamp_channel_name"]:
16961701
name = new_name = author.created_at.isoformat(sep="-", timespec="minutes")

core/config.py

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ConfigManager:
5353
"use_user_id_channel_name": False,
5454
"use_timestamp_channel_name": False,
5555
"use_nickname_channel_name": False,
56+
"use_random_channel_name": False,
5657
"recipient_thread_close": False,
5758
"thread_show_roles": True,
5859
"thread_show_account_age": True,
@@ -187,6 +188,7 @@ class ConfigManager:
187188
"use_user_id_channel_name",
188189
"use_timestamp_channel_name",
189190
"use_nickname_channel_name",
191+
"use_random_channel_name",
190192
"user_typing",
191193
"mod_typing",
192194
"reply_without_command",

core/config_help.json

+19-6
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
],
107107
"notes": [
108108
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
109-
"This cannot be applied with `use_timestamp_channel_name` or `use_nickname_channel_name`.",
110-
"See also: `use_timestamp_channel_name`, `use_nickname_channel_name`."
109+
"This cannot be applied with `use_timestamp_channel_name`, `use_random_channel_name` or `use_nickname_channel_name`.",
110+
"See also: `use_timestamp_channel_name`, `use_nickname_channel_name`, `use_random_channel_name`."
111111
]
112112
},
113113
"use_timestamp_channel_name": {
@@ -119,8 +119,8 @@
119119
],
120120
"notes": [
121121
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
122-
"This cannot be applied with `use_user_id_channel_name` or `use_nickname_channel_name`.",
123-
"See also: `use_user_id_channel_name`, `use_nickname_channel_name`."
122+
"This cannot be applied with `use_user_id_channel_name`, `use_random_channel_name` or `use_nickname_channel_name`.",
123+
"See also: `use_user_id_channel_name`, `use_nickname_channel_name`, `use_random_channel_name`."
124124
]
125125
},
126126
"use_nickname_channel_name": {
@@ -132,8 +132,21 @@
132132
],
133133
"notes": [
134134
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
135-
"This cannot be applied with `use_timestamp_channel_name` or `use_user_id_channel_name`.",
136-
"See also: `use_timestamp_channel_name`, `use_user_id_channel_name`."
135+
"This cannot be applied with `use_timestamp_channel_name`, `use_random_channel_name` or `use_user_id_channel_name`.",
136+
"See also: `use_timestamp_channel_name`, `use_user_id_channel_name`, `use_random_channel_name`."
137+
]
138+
},
139+
"use_random_channel_name": {
140+
"default": "No",
141+
"description": "When this is set to `yes`, new thread channels will be named with random characters tied to their user ID.",
142+
"examples": [
143+
"`{prefix}config set use_random_channel_name yes`",
144+
"`{prefix}config set use_random_channel_name no`"
145+
],
146+
"notes": [
147+
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
148+
"This cannot be applied with `use_timestamp_channel_name`, `use_nickname_channel_name`, or `use_user_id_channel_name`.",
149+
"See also: `use_timestamp_channel_name`, `use_user_id_channel_name`, `use_nickname_channel_name`."
137150
]
138151
},
139152
"mod_typing": {

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extend-exclude = '''
2121

2222
[tool.poetry]
2323
name = 'Modmail'
24-
version = '4.0.0-dev11'
24+
version = '4.0.0-dev12'
2525
description = "Modmail is similar to Reddit's Modmail, both in functionality and purpose. It serves as a shared inbox for server staff to communicate with their users in a seamless way."
2626
license = 'AGPL-3.0-only'
2727
authors = [

0 commit comments

Comments
 (0)