Skip to content

Commit 55b311f

Browse files
committed
Initial commit
1 parent ae531c4 commit 55b311f

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

bot.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ async def trigger_auto_triggers(self, message, channel, *, cls=commands.Context)
10101010
if trigger:
10111011
invoker = trigger.lower()
10121012

1013+
print("looking for auto trigger", trigger, self.auto_triggers[trigger])
10131014
alias = self.auto_triggers[trigger]
10141015

10151016
ctxs = []
@@ -1019,24 +1020,45 @@ async def trigger_auto_triggers(self, message, channel, *, cls=commands.Context)
10191020
if not aliases:
10201021
logger.warning("Alias %s is invalid as called in autotrigger.", invoker)
10211022

1023+
print("Aliases", aliases)
1024+
10221025
for alias in aliases:
10231026
view = StringView(invoked_prefix + alias)
1027+
invoked_with = view.get_word().lower()
1028+
invoked_with = invoked_with[1:]
1029+
print("Looking for", invoked_with)
1030+
found_command = self.all_commands.get(invoked_with)
1031+
1032+
# Check for alias
1033+
if not found_command:
1034+
print("INVOKED WITH", invoked_with)
1035+
command_alias = self.aliases.get(invoked_with)[1:-1]
1036+
view = StringView(invoked_prefix + command_alias)
1037+
split_cmd = command_alias.split(" ")
1038+
found_command = self.all_commands.get(split_cmd[0])
1039+
10241040
ctx_ = cls(prefix=self.prefix, view=view, bot=self, message=message)
1041+
ctx_.command = found_command
1042+
ctx_.invoked_with = invoked_with
10251043
ctx_.thread = thread
10261044
discord.utils.find(view.skip_string, await self.get_prefix())
1027-
ctx_.invoked_with = view.get_word().lower()
1028-
ctx_.command = self.all_commands.get(ctx_.invoked_with)
1045+
1046+
print("Command info:", view, ctx_, ctx_.thread, ctx_.invoked_with, ctx_.command)
10291047
ctxs += [ctx_]
10301048

10311049
for ctx in ctxs:
10321050
if ctx.command:
1051+
print("Found command")
10331052
old_checks = copy.copy(ctx.command.checks)
1053+
print("Old checks set")
10341054
ctx.command.checks = [checks.has_permissions(PermissionLevel.INVALID)]
1035-
1055+
print("Command checks added, invoking...", ctx)
10361056
await self.invoke(ctx)
10371057

10381058
ctx.command.checks = old_checks
10391059
continue
1060+
else:
1061+
print("unable to find command")
10401062

10411063
async def get_context(self, message, *, cls=commands.Context):
10421064
"""

cogs/modmail.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,10 @@ async def reply(self, ctx, *, msg: str = ""):
818818
Supports attachments and images as well as
819819
automatically embedding image URLs.
820820
"""
821+
821822
ctx.message.content = msg
823+
print("MSG IS", msg)
824+
print("Sending", ctx.message, msg)
822825
async with ctx.typing():
823826
await ctx.thread.reply(ctx.message)
824827

cogs/utility.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,16 @@ async def autotrigger_add(self, ctx, keyword, *, command):
17501750
print(self.bot.get_command(" ".join(split_cmd[0:n])))
17511751
valid = True
17521752
break
1753+
1754+
print("Split command", split_cmd, "Range", range(1, len(split_cmd) + 1), self.bot.aliases)
1755+
1756+
if not valid and self.bot.aliases:
1757+
for n in range(1, len(split_cmd) + 1):
1758+
print(" ".join(split_cmd[0:n]), self.bot.aliases.get(" ".join(split_cmd[0:n])))
1759+
if self.bot.aliases.get(" ".join(split_cmd[0:n])):
1760+
print(self.bot.aliases.get(" ".join(split_cmd[0:n])))
1761+
valid = True
1762+
break
17531763

17541764
if valid:
17551765
self.bot.auto_triggers[keyword] = command
@@ -1784,6 +1794,14 @@ async def autotrigger_edit(self, ctx, keyword, *, command):
17841794
valid = True
17851795
break
17861796

1797+
if not valid and self.bot.aliases:
1798+
for n in range(1, len(split_cmd) + 1):
1799+
print(" ".join(split_cmd[0:n]), self.bot.aliases.get(" ".join(split_cmd[0:n])))
1800+
if self.bot.aliases.get(" ".join(split_cmd[0:n])):
1801+
print(self.bot.aliases.get(" ".join(split_cmd[0:n])))
1802+
valid = True
1803+
break
1804+
17871805
if valid:
17881806
self.bot.auto_triggers[keyword] = command
17891807
await self.bot.config.update()

core/thread.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class Author:
241241
async def activate_auto_triggers():
242242
if initial_message:
243243
message = DummyMessage(copy.copy(initial_message))
244+
244245
try:
245246
return await self.bot.trigger_auto_triggers(message, channel)
246247
except RuntimeError:

0 commit comments

Comments
 (0)