Skip to content

Commit

Permalink
Fix bugs with alias and autotrigger, resolve #2870
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Nov 10, 2020
1 parent 5c8ee8d commit 038fc61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
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.
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.

# v3.7.0-dev11
# v3.7.0-dev12

### Added

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

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

### Improved

Expand Down
1 change: 1 addition & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ async def get_contexts(self, message, *, cls=commands.Context):
discord.utils.find(view.skip_string, prefixes)
ctx_.invoked_with = view.get_word().lower()
ctx_.command = self.all_commands.get(ctx_.invoked_with)
print(ctx_.invoked_with, ctx_.args, ctx_.kwargs)
ctxs += [ctx_]
return ctxs

Expand Down
3 changes: 3 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def __init__(self, message):
def __getattr__(self, name: str):
return getattr(self._message, name)

def __bool__(self):
return bool(self._message)

async def delete(self, *, delay=None):
return

Expand Down
11 changes: 8 additions & 3 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def create_not_found_embed(word, possibilities, name, n=2, cutoff=0.6) -> discor
return embed


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

Expand All @@ -288,7 +288,12 @@ def decode_alias(m):
if not alias:
return aliases

for a in re.split(r"\s*&&\s*", alias):
if split:
iterate = re.split(r"\s*&&\s*", alias)
else:
iterate = [alias]

for a in iterate:
a = re.sub("\x1AU(.+?)\x1AU", decode_alias, a)
if a[0] == a[-1] == '"':
a = a[1:-1]
Expand All @@ -299,7 +304,7 @@ def decode_alias(m):

def normalize_alias(alias, message):
aliases = parse_alias(alias)
contents = parse_alias(message)
contents = parse_alias(message, split=False)

final_aliases = []
for a, content in zip_longest(aliases, contents):
Expand Down

0 comments on commit 038fc61

Please sign in to comment.