Browse Source

A bit more

pull/3/head
Andrei 9 years ago
parent
commit
64386e6a29
  1. 9
      README.md
  2. 5
      disco/bot/bot.py
  3. 11
      disco/bot/command.py

9
README.md

@ -1,2 +1,11 @@
# disco # disco
A Discord Python bot built to be easy to use and scale. 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

5
disco/bot/bot.py

@ -73,8 +73,9 @@ class Bot(object):
return False return False
for command in self.commands: for command in self.commands:
if command.compiled_regex.match(content): match = command.compiled_regex.match(content)
command.execute(msg) if match:
command.execute(msg, match)
return False return False

11
disco/bot/command.py

@ -5,6 +5,13 @@ from disco.util.cache import cached_property
ARGS_REGEX = '( (.*)$|$)' 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): class Command(object):
def __init__(self, func, trigger, aliases=None, group=None, is_regex=False): def __init__(self, func, trigger, aliases=None, group=None, is_regex=False):
self.func = func self.func = func
@ -13,8 +20,8 @@ class Command(object):
self.group = group self.group = group
self.is_regex = is_regex self.is_regex = is_regex
def execute(self, msg): def execute(self, msg, match):
self.func(msg) self.func(CommandEvent(msg, match))
@cached_property @cached_property
def compiled_regex(self): def compiled_regex(self):

Loading…
Cancel
Save