-
-
Notifications
You must be signed in to change notification settings - Fork 817
Add warning for the length of the group name #2122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
2e8c005
a58f8d9
19879b2
1bbd2d9
cc46101
50f53bc
48533bd
a13f9eb
792c79e
ae711a3
027aad1
8b6c547
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,11 @@ def valid_channel_name(self, name, receive=False): | |
raise TypeError(self.invalid_name_error.format("Channel", name)) | ||
|
||
def valid_group_name(self, name): | ||
error_message = ( | ||
f"Group name must be less than {self.MAX_NAME_LENGTH} characters." | ||
) | ||
if len(name) >= self.MAX_NAME_LENGTH: | ||
raise TypeError(error_message) | ||
if self.match_type_and_length(name): | ||
if bool(self.group_name_regex.match(name)): | ||
return True | ||
|
@@ -341,7 +346,9 @@ async def group_add(self, group, channel): | |
Adds the channel name to a group. | ||
""" | ||
# Check the inputs | ||
assert self.valid_group_name(group), "Group name not valid" | ||
assert self.valid_group_name(group), ( | ||
f"Group name must be" f"less than {self.MAX_NAME_LENGTH} characters." | ||
) | ||
assert self.valid_channel_name(channel), "Channel name not valid" | ||
# Add to group dict | ||
self.groups.setdefault(group, {}) | ||
|
@@ -350,7 +357,9 @@ async def group_add(self, group, channel): | |
async def group_discard(self, group, channel): | ||
# Both should be text and valid | ||
assert self.valid_channel_name(channel), "Invalid channel name" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here as aboev |
||
assert self.valid_group_name(group), "Invalid group name" | ||
assert self.valid_group_name(group), ( | ||
f"Group name must be" f"less than {self.MAX_NAME_LENGTH} characters." | ||
) | ||
# Remove from group set | ||
group_channels = self.groups.get(group, None) | ||
if group_channels: | ||
|
@@ -363,7 +372,9 @@ async def group_discard(self, group, channel): | |
async def group_send(self, group, message): | ||
# Check types | ||
assert isinstance(message, dict), "Message is not a dict" | ||
assert self.valid_group_name(group), "Invalid group name" | ||
assert self.valid_group_name(group), ( | ||
f"Group name must be" f"less than {self.MAX_NAME_LENGTH} characters." | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per the point about the |
||
# Run clean | ||
self._clean_expired() | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.