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
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
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

11
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):

Loading…
Cancel
Save