From 64386e6a2920ab8ed6c2f2ffce08e4dfabd2ca05 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 22 Sep 2016 04:23:46 -0500 Subject: [PATCH] A bit more --- README.md | 9 +++++++++ disco/bot/bot.py | 5 +++-- disco/bot/command.py | 11 +++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ab8dd21..13e3f30 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ # disco A Discord Python bot built to be easy to use and scale. + +## TODOS + +- rate limits +- flesh out gateway paths (reconnect/resume) +- flesh out API client +- flesh out type methods +- plugin reload +- voice support diff --git a/disco/bot/bot.py b/disco/bot/bot.py index bc65b6d..25d95c2 100644 --- a/disco/bot/bot.py +++ b/disco/bot/bot.py @@ -73,8 +73,9 @@ class Bot(object): return False for command in self.commands: - if command.compiled_regex.match(content): - command.execute(msg) + match = command.compiled_regex.match(content) + if match: + command.execute(msg, match) return False diff --git a/disco/bot/command.py b/disco/bot/command.py index 85918b0..c6788eb 100644 --- a/disco/bot/command.py +++ b/disco/bot/command.py @@ -5,6 +5,13 @@ from disco.util.cache import cached_property ARGS_REGEX = '( (.*)$|$)' +class CommandEvent(object): + def __init__(self, msg, match): + self.msg = msg + self.match = match + self.args = self.match.group(1).split(' ') + + class Command(object): def __init__(self, func, trigger, aliases=None, group=None, is_regex=False): self.func = func @@ -13,8 +20,8 @@ class Command(object): self.group = group self.is_regex = is_regex - def execute(self, msg): - self.func(msg) + def execute(self, msg, match): + self.func(CommandEvent(msg, match)) @cached_property def compiled_regex(self):