From fa2f915de5c906a0dad9906a253ec95cd91549b1 Mon Sep 17 00:00:00 2001 From: Andrei Date: Sun, 13 Nov 2016 01:37:04 -0600 Subject: [PATCH] Remove some debug stuff --- disco/api/client.py | 18 ++++++++++++++---- disco/bot/bot.py | 2 +- disco/bot/command.py | 3 +++ disco/types/message.py | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/disco/api/client.py b/disco/api/client.py index 3a15171..c8fe702 100644 --- a/disco/api/client.py +++ b/disco/api/client.py @@ -23,16 +23,26 @@ def optional(**kwargs): class APIClient(LoggingClass): """ - An abstraction over the :class:`disco.api.http.HTTPClient` that composes requests, and fits - the models with the returned data. + An abstraction over a :class:`disco.api.http.HTTPClient`, which composes + requests from provided data, and fits models with the returned data. The APIClient + is the only path to the API used within models/other interfaces, and it's + the recommended path for all third-party users/implementations. Args ---- token : str The Discord authentication token (without prefixes) to be used for all HTTP requests. - client : :class:`disco.client.Client` - The base disco client which will be used when constructing models. + client : Optional[:class:`disco.client.Client`] + The Disco client this APIClient is a member of. This is used when constructing + and fitting models from response data. + + Attributes + ---------- + client : Optional[:class:`disco.client.Client`] + The Disco client this APIClient is a member of. + http : :class:`disco.http.HTTPClient` + The HTTPClient this APIClient uses for all requests. """ def __init__(self, token, client=None): super(APIClient, self).__init__() diff --git a/disco/bot/bot.py b/disco/bot/bot.py index 2f97832..e4ba373 100644 --- a/disco/bot/bot.py +++ b/disco/bot/bot.py @@ -203,7 +203,7 @@ class Bot(object): grp = group while grp: # If the group already exists, means someone else thought they - # could use it so we need to + # could use it so we need yank it from them (and not use it) if grp in list(six.itervalues(self.group_abbrev)): self.group_abbrev = {k: v for k, v in six.iteritems(self.group_abbrev) if v != grp} else: diff --git a/disco/bot/command.py b/disco/bot/command.py index 1cf00a1..6eb7cc4 100644 --- a/disco/bot/command.py +++ b/disco/bot/command.py @@ -50,6 +50,9 @@ class CommandEvent(object): @property def codeblock(self): + if '`' not in self.msg.content: + return ' '.join(self.args) + _, src = self.msg.content.split('`', 1) src = '`' + src diff --git a/disco/types/message.py b/disco/types/message.py index e7b2873..500428f 100644 --- a/disco/types/message.py +++ b/disco/types/message.py @@ -368,7 +368,7 @@ class Message(SlottedModel): if user_replace: replace_user = functools.partial(replace, self.mentions.get, user_replace) - content = re.sub('(<@!?([0-9]+)>)', replace_user, self.content) + content = re.sub('(<@!?([0-9]+)>)', replace_user, content) if role_replace: replace_role = functools.partial(replace, lambda v: (self.guild and self.guild.roles.get(v)), role_replace)