Skip to content

Commit 038fc61

Browse files
committed
Fix bugs with alias and autotrigger, resolve #2870
1 parent 5c8ee8d commit 038fc61

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Diff for: CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
7-
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugins developer, note the "BREAKING" section.
7+
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.
88

9-
# v3.7.0-dev11
9+
# v3.7.0-dev12
1010

1111
### Added
1212

@@ -31,7 +31,8 @@ however, insignificant breaking changes do not guarantee a major version bump, s
3131
### Fixed
3232

3333
- `?contact` now sends members a DM.
34-
- Fixed issue where `level_permissions` and `command_permissions` would sometimes be reset. ([GH #2856](https://github.com/kyb3r/modmail/issues/2856))
34+
- `level_permissions` and `command_permissions` would sometimes be reset. ([GH #2856](https://github.com/kyb3r/modmail/issues/2856))
35+
- Command truncated after && in alias ([GH #2870](https://github.com/kyb3r/modmail/issues/2870))
3536

3637
### Improved
3738

Diff for: bot.py

+1
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ async def get_contexts(self, message, *, cls=commands.Context):
849849
discord.utils.find(view.skip_string, prefixes)
850850
ctx_.invoked_with = view.get_word().lower()
851851
ctx_.command = self.all_commands.get(ctx_.invoked_with)
852+
print(ctx_.invoked_with, ctx_.args, ctx_.kwargs)
852853
ctxs += [ctx_]
853854
return ctxs
854855

Diff for: core/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ def __init__(self, message):
225225
def __getattr__(self, name: str):
226226
return getattr(self._message, name)
227227

228+
def __bool__(self):
229+
return bool(self._message)
230+
228231
async def delete(self, *, delay=None):
229232
return
230233

Diff for: core/utils.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def create_not_found_embed(word, possibilities, name, n=2, cutoff=0.6) -> discor
270270
return embed
271271

272272

273-
def parse_alias(alias):
273+
def parse_alias(alias, *, split=True):
274274
def encode_alias(m):
275275
return "\x1AU" + base64.b64encode(m.group(1).encode()).decode() + "\x1AU"
276276

@@ -288,7 +288,12 @@ def decode_alias(m):
288288
if not alias:
289289
return aliases
290290

291-
for a in re.split(r"\s*&&\s*", alias):
291+
if split:
292+
iterate = re.split(r"\s*&&\s*", alias)
293+
else:
294+
iterate = [alias]
295+
296+
for a in iterate:
292297
a = re.sub("\x1AU(.+?)\x1AU", decode_alias, a)
293298
if a[0] == a[-1] == '"':
294299
a = a[1:-1]
@@ -299,7 +304,7 @@ def decode_alias(m):
299304

300305
def normalize_alias(alias, message):
301306
aliases = parse_alias(alias)
302-
contents = parse_alias(message)
307+
contents = parse_alias(message, split=False)
303308

304309
final_aliases = []
305310
for a, content in zip_longest(aliases, contents):

0 commit comments

Comments
 (0)