diff --git a/.gitignore b/.gitignore index b024370..39e220b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ __pycache__ .env error_* *.log -test.py +*test*.py *.pyc .pytest_cache .coverage -tmp \ No newline at end of file +tmp diff --git a/miniscord/_bot.py b/miniscord/_bot.py index 20f2f71..55949c0 100644 --- a/miniscord/_bot.py +++ b/miniscord/_bot.py @@ -31,7 +31,7 @@ class Bot(object): def __init__(self, app_name: str, version: str, *, alias: str = None): # constants self.token_env_var = "DISCORD_TOKEN" - self.remove_mentions = True # remove mentions from arguments + self.remove_mentions = False # remove mentions from arguments self.alias = alias # can call bot with {alias}{command_name} self.any_mention = False # bot mention can be anywhere self.log_calls = False @@ -48,6 +48,7 @@ class Bot(object): self.__t0 = None self.__last_error = None # init + self.__watcher = None self.__commands = [] self.__fallback = None self.games = [f"v{version}", @@ -133,6 +134,9 @@ class Bot(object): if message.author == self.client.user: return # Ignore self messages + if self.__watcher is not None: + await self.__watcher(self.client, message) + is_direct = message.channel.type == discord.ChannelType.private is_mention = self.any_mention and self.client.user in message.mentions \ @@ -201,6 +205,9 @@ class Bot(object): def register_fallback(self, compute: CommandFunction): self.__fallback = compute + def register_watcher(self, compute: CommandFunction): + self.__watcher = compute + def start(self): logging.info(f"Current PID: {os.getpid()}") env_file_found = load_dotenv()