From 41be501957a0f6d3fb095553508f2eba51895e29 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Fri, 1 Mar 2019 15:53:32 +0000 Subject: [PATCH 1/5] Update README.md since we are planning to implement voice (but not video, at least for now) stuff. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65ea1f3..4ee38a0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ took a shot at writing it again. It works. ## Caveats - Unit testing is incomplete. -- Currently, there are no plans to support voice chat, or the Discord Store. +- Currently, there are no plans to support video in voice chats, or the Discord Store. - You must figure out how to connect to a Litecord instance. Litecord will not distribute official client code from Discord nor provide ways to modify the official client. From 53bb87c7d1fce9037b075f226bf50cd48231c82e Mon Sep 17 00:00:00 2001 From: gabixdev Date: Fri, 1 Mar 2019 19:42:10 +0100 Subject: [PATCH 2/5] fix JPEG image handling --- litecord/images.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/litecord/images.py b/litecord/images.py index 854e2b9..866955a 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -340,6 +340,9 @@ class IconManager: elif 'size' in kwargs: image = Image.open(data_fd) + if mime == 'image/jpeg': + image = image.convert("RGB") + want = kwargs['size'] log.info('resizing from {} to {}', From 5cf9caeac30e2beaf891d45ee34f779dcb7757ca Mon Sep 17 00:00:00 2001 From: gabixdev Date: Fri, 1 Mar 2019 19:42:50 +0100 Subject: [PATCH 3/5] ignore .vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e4064a2..2ba771e 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,4 @@ images/* attachments/* .DS_Store +.vscode From a7dc9e01dc1c36869fd6072ab411691963b6b382 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Fri, 1 Mar 2019 21:08:58 +0100 Subject: [PATCH 4/5] Embed fixes --- litecord/blueprints/channel/messages.py | 3 +++ litecord/embed/schemas.py | 12 ++++++------ litecord/types.py | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/litecord/blueprints/channel/messages.py b/litecord/blueprints/channel/messages.py index fd8a060..cd978eb 100644 --- a/litecord/blueprints/channel/messages.py +++ b/litecord/blueprints/channel/messages.py @@ -407,6 +407,9 @@ async def _create_message(channel_id): await _dm_pre_dispatch(channel_id, user_id) await _dm_pre_dispatch(channel_id, guild_id) + if payload['webhook_id'] == None: + payload.pop('webhook_id', None) + await app.dispatcher.dispatch('channel', channel_id, 'MESSAGE_CREATE', payload) diff --git a/litecord/embed/schemas.py b/litecord/embed/schemas.py index 2e17bea..61452c6 100644 --- a/litecord/embed/schemas.py +++ b/litecord/embed/schemas.py @@ -46,7 +46,7 @@ class EmbedURL: EMBED_FOOTER = { 'text': { - 'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': True}, + 'type': 'string', 'minlength': 1, 'maxlength': 1024, 'required': True}, 'icon_url': { 'coerce': EmbedURL, 'required': False, @@ -65,7 +65,7 @@ EMBED_THUMBNAIL = EMBED_IMAGE EMBED_AUTHOR = { 'name': { - 'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': False + 'type': 'string', 'minlength': 1, 'maxlength': 256, 'required': False }, 'url': { 'coerce': EmbedURL, 'required': False, @@ -79,10 +79,10 @@ EMBED_AUTHOR = { EMBED_FIELD = { 'name': { - 'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': True + 'type': 'string', 'minlength': 1, 'maxlength': 256, 'required': True }, 'value': { - 'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': True + 'type': 'string', 'minlength': 1, 'maxlength': 1024, 'required': True }, 'inline': { 'type': 'boolean', 'required': False, 'default': True, @@ -91,10 +91,10 @@ EMBED_FIELD = { EMBED_OBJECT = { 'title': { - 'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': False}, + 'type': 'string', 'minlength': 1, 'maxlength': 256, 'required': False}, # NOTE: type set by us 'description': { - 'type': 'string', 'minlength': 1, 'maxlength': 1024, 'required': False, + 'type': 'string', 'minlength': 1, 'maxlength': 2048, 'required': False, }, 'url': { 'coerce': EmbedURL, 'required': False, diff --git a/litecord/types.py b/litecord/types.py index 38888e9..1a845f8 100644 --- a/litecord/types.py +++ b/litecord/types.py @@ -37,6 +37,10 @@ class Color: """Give the actual RGB integer encoding this color.""" return int('%02x%02x%02x' % (self.red, self.green, self.blue), 16) + @property + def to_json(self): + return self.value + def __int__(self): return self.value From e5cff415f5006cd2fd3fb810c1deaa7b4a43cc13 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sat, 2 Mar 2019 00:38:37 +0100 Subject: [PATCH 5/5] fix icons and message history breaking --- litecord/blueprints/icons.py | 1 - litecord/images.py | 2 -- litecord/storage.py | 7 ++++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index 9daa45b..65b8de2 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -27,7 +27,6 @@ async def send_icon(scope, key, icon_hash, **kwargs): """Send an icon.""" icon = await app.icons.generic_get( scope, key, icon_hash, **kwargs) - if not icon: return '', 404 diff --git a/litecord/images.py b/litecord/images.py index 866955a..d4c1ea9 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -274,8 +274,6 @@ class IconManager: async def generic_get(self, scope, key, icon_hash, **kwargs) -> Icon: """Get any icon.""" - if icon_hash is None: - return None log.debug('GET {} {} {}', scope, key, icon_hash) key = str(key) diff --git a/litecord/storage.py b/litecord/storage.py index 83f98fc..15b1871 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -604,8 +604,10 @@ class Storage: return [r[0] for r in rows] async def _msg_regex(self, regex, func, content) -> List[Dict]: - res = [] + if content is None: + return [] + res = [] for match in regex.finditer(content): found_id = match.group(1) @@ -763,6 +765,9 @@ class Storage: res['type'] = res['message_type'] res.pop('message_type') + if res['content'] is None: + res['content'] = "" + channel_id = int(row['channel_id']) content = row['content'] guild_id = await self.guild_from_channel(channel_id)