Browse Source

Merge branch 'master' into master

pull/68/head
Andrei Zbikowski 8 years ago
committed by GitHub
parent
commit
21a3ad0290
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      CHANGELOG.md
  2. 2
      disco/__init__.py
  3. 2
      disco/bot/bot.py
  4. 5
      disco/cli.py
  5. 10
      disco/types/channel.py
  6. 7
      disco/types/guild.py
  7. 3
      disco/types/message.py
  8. 10
      disco/util/token.py
  9. 2
      docs/bot_tutorial/first_steps.md
  10. 2
      setup.py
  11. 1
      tests/imports.py

17
CHANGELOG.md

@ -1,5 +1,22 @@
# CHANGELOG
## v0.0.12-rc.3
### Additions
- **BREAKING** Updated holster to v2.0.0 which changes the way emitters work (and removes the previous priorities). A migration guide will be provided post-RC cycle.
- Added the concept of a `shared_config` which propgates its options to all plugin configs (@enkoder)
### Fixes
- Fixed using the ETF encoder while also using zlib-stream
- Fixed overwrite calculations in `Channel.get_permissions` (@cookkkie)
### Etc
- Cleaned up various documentation
- Removed some outdated storage/etc examples
## v0.0.12-rc.2
### Fixes

2
disco/__init__.py

@ -1 +1 @@
VERSION = '0.0.12-rc.2'
VERSION = '0.0.12-rc.3'

2
disco/bot/bot.py

@ -506,7 +506,7 @@ class Bot(LoggingClass):
data = {}
if self.config.shared_config:
data.update(self.config.shared)
data.update(self.config.shared_config)
if name in self.config.plugin_config:
data.update(self.config.plugin_config[name])

5
disco/cli.py

@ -42,7 +42,6 @@ def disco_main(run=False):
from disco.client import Client, ClientConfig
from disco.bot import Bot, BotConfig
from disco.util.token import is_valid_token
from disco.util.logging import setup_logging
if os.path.exists(args.config):
@ -60,10 +59,6 @@ def disco_main(run=False):
if hasattr(config, k) and v is not None:
setattr(config, k, v)
if not is_valid_token(config.token):
print('Invalid token passed')
return
if args.shard_auto:
from disco.gateway.sharder import AutoSharder
AutoSharder(config).run()

10
disco/types/channel.py

@ -518,6 +518,8 @@ class MessageIterator(object):
def fill(self):
"""
Fills the internal buffer up with :class:`disco.types.message.Message` objects from the API.
Returns a boolean indicating whether items were added to the buffer.
"""
self._buffer = self.client.api.channels_messages_list(
self.channel.id,
@ -526,7 +528,7 @@ class MessageIterator(object):
limit=self.chunk_size)
if not len(self._buffer):
return
return False
self.after = None
self.before = None
@ -538,6 +540,8 @@ class MessageIterator(object):
self._buffer.reverse()
self.after = self._buffer[-1].id
return True
def next(self):
return self.__next__()
@ -546,7 +550,9 @@ class MessageIterator(object):
def __next__(self):
if not len(self._buffer):
self.fill()
filled = self.fill()
if not filled:
raise StopIteration
if self.bulk:
res = self._buffer

7
disco/types/guild.py

@ -54,6 +54,8 @@ class GuildEmoji(Emoji):
Whether this emoji is managed by an integration.
roles : list(snowflake)
Roles this emoji is attached to.
animated : bool
Whether this emoji is animated.
"""
id = Field(snowflake)
guild_id = Field(snowflake)
@ -61,9 +63,10 @@ class GuildEmoji(Emoji):
require_colons = Field(bool)
managed = Field(bool)
roles = ListField(snowflake)
animated = Field(bool)
def __str__(self):
return u'<:{}:{}>'.format(self.name, self.id)
return u'<{}:{}:{}>'.format('a' if self.animated else '', self.name, self.id)
def update(self, **kwargs):
return self.client.api.guilds_emojis_modify(self.guild_id, self.id, **kwargs)
@ -73,7 +76,7 @@ class GuildEmoji(Emoji):
@property
def url(self):
return 'https://discordapp.com/api/emojis/{}.png'.format(self.id)
return 'https://discordapp.com/api/emojis/{}.{}'.format(self.id, 'gif' if self.animated else 'png')
@cached_property
def guild(self):

3
disco/types/message.py

@ -37,9 +37,12 @@ class Emoji(SlottedModel):
The emoji ID (will be none if this is not a custom emoji).
name : str
The name of this emoji.
animated : bool
Whether this emoji is animated.
"""
id = Field(snowflake)
name = Field(text)
animated = Field(bool)
@cached_property
def custom(self):

10
disco/util/token.py

@ -1,10 +0,0 @@
import re
TOKEN_RE = re.compile(r'M\w{23}\.[\w-]{6}\..{27}')
def is_valid_token(token):
"""
Validates a Discord authentication token, returning true if valid.
"""
return bool(TOKEN_RE.match(token))

2
docs/bot_tutorial/first_steps.md

@ -21,7 +21,7 @@ The \_\_init\_\_.py file is required for Python to find your plugin, but it can
{% endhint %}
Now lets setup the configuration file. To start off with we'll paste the following template in and modify our token key (`MY_BOT_TOKEN_HERE`) to be the token we obtained above. The plugins section tells disco what plugins to load, based on a module path (similar to how Python imports work). In this example we're asking disco to load the plugin contained in the tutorial file within the plugins directory (or "module"). Disco by default loads the first plugin it finds within the module, so you want to make sure each plugin class is contained within its own file.
Now let's setup the configuration file. To start off with we'll paste the following template in and modify our token key (`MY_BOT_TOKEN_HERE`) to be the token we obtained above. The plugins section tells disco what plugins to load, based on a module path (similar to how Python imports work). In this example we're asking disco to load the plugin contained in the tutorial file within the plugins directory (or "module"). Disco by default loads the first plugin it finds within the module, so you want to make sure each plugin class is contained within its own file.
```yaml
token: 'MY_BOT_TOKEN_HERE'

2
setup.py

@ -13,7 +13,7 @@ extras_require = {
'voice': ['pynacl==1.2.1'],
'http': ['flask==0.12.2'],
'yaml': ['pyyaml==3.12'],
'music': ['youtube_dl>=2017.12.31'],
'music': ['youtube_dl>=2018.1.14'],
'performance': ['erlpack==0.3.2' if sys.version_info.major == 2 else 'earl-etf==2.1.2', 'ujson==1.35'],
'sharding': ['gipc==0.6.0'],
'docs': ['biblio==0.0.4'],

1
tests/imports.py

@ -33,7 +33,6 @@ from disco.util.limiter import *
from disco.util.logging import *
from disco.util.serializer import *
from disco.util.snowflake import *
from disco.util.token import *
from disco.util.websocket import *
from disco.voice.client import *
from disco.voice.opus import *

Loading…
Cancel
Save