mirror of https://gitlab.com/litecord/litecord.git
Merge branch 'master' into voice
This commit is contained in:
commit
67ae2385b5
|
|
@ -108,3 +108,4 @@ images/*
|
||||||
attachments/*
|
attachments/*
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ took a shot at writing it again. It works.
|
||||||
## Caveats
|
## Caveats
|
||||||
|
|
||||||
- Unit testing is incomplete.
|
- 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
|
- 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
|
distribute official client code from Discord nor provide ways to modify the
|
||||||
official client.
|
official client.
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,9 @@ async def _create_message(channel_id):
|
||||||
await _dm_pre_dispatch(channel_id, user_id)
|
await _dm_pre_dispatch(channel_id, user_id)
|
||||||
await _dm_pre_dispatch(channel_id, guild_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,
|
await app.dispatcher.dispatch('channel', channel_id,
|
||||||
'MESSAGE_CREATE', payload)
|
'MESSAGE_CREATE', payload)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ async def send_icon(scope, key, icon_hash, **kwargs):
|
||||||
"""Send an icon."""
|
"""Send an icon."""
|
||||||
icon = await app.icons.generic_get(
|
icon = await app.icons.generic_get(
|
||||||
scope, key, icon_hash, **kwargs)
|
scope, key, icon_hash, **kwargs)
|
||||||
|
|
||||||
if not icon:
|
if not icon:
|
||||||
return '', 404
|
return '', 404
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class EmbedURL:
|
||||||
|
|
||||||
EMBED_FOOTER = {
|
EMBED_FOOTER = {
|
||||||
'text': {
|
'text': {
|
||||||
'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': True},
|
'type': 'string', 'minlength': 1, 'maxlength': 1024, 'required': True},
|
||||||
|
|
||||||
'icon_url': {
|
'icon_url': {
|
||||||
'coerce': EmbedURL, 'required': False,
|
'coerce': EmbedURL, 'required': False,
|
||||||
|
|
@ -65,7 +65,7 @@ EMBED_THUMBNAIL = EMBED_IMAGE
|
||||||
|
|
||||||
EMBED_AUTHOR = {
|
EMBED_AUTHOR = {
|
||||||
'name': {
|
'name': {
|
||||||
'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': False
|
'type': 'string', 'minlength': 1, 'maxlength': 256, 'required': False
|
||||||
},
|
},
|
||||||
'url': {
|
'url': {
|
||||||
'coerce': EmbedURL, 'required': False,
|
'coerce': EmbedURL, 'required': False,
|
||||||
|
|
@ -79,10 +79,10 @@ EMBED_AUTHOR = {
|
||||||
|
|
||||||
EMBED_FIELD = {
|
EMBED_FIELD = {
|
||||||
'name': {
|
'name': {
|
||||||
'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': True
|
'type': 'string', 'minlength': 1, 'maxlength': 256, 'required': True
|
||||||
},
|
},
|
||||||
'value': {
|
'value': {
|
||||||
'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': True
|
'type': 'string', 'minlength': 1, 'maxlength': 1024, 'required': True
|
||||||
},
|
},
|
||||||
'inline': {
|
'inline': {
|
||||||
'type': 'boolean', 'required': False, 'default': True,
|
'type': 'boolean', 'required': False, 'default': True,
|
||||||
|
|
@ -91,10 +91,10 @@ EMBED_FIELD = {
|
||||||
|
|
||||||
EMBED_OBJECT = {
|
EMBED_OBJECT = {
|
||||||
'title': {
|
'title': {
|
||||||
'type': 'string', 'minlength': 1, 'maxlength': 128, 'required': False},
|
'type': 'string', 'minlength': 1, 'maxlength': 256, 'required': False},
|
||||||
# NOTE: type set by us
|
# NOTE: type set by us
|
||||||
'description': {
|
'description': {
|
||||||
'type': 'string', 'minlength': 1, 'maxlength': 1024, 'required': False,
|
'type': 'string', 'minlength': 1, 'maxlength': 2048, 'required': False,
|
||||||
},
|
},
|
||||||
'url': {
|
'url': {
|
||||||
'coerce': EmbedURL, 'required': False,
|
'coerce': EmbedURL, 'required': False,
|
||||||
|
|
|
||||||
|
|
@ -287,8 +287,6 @@ class IconManager:
|
||||||
async def generic_get(self, scope, key, icon_hash,
|
async def generic_get(self, scope, key, icon_hash,
|
||||||
**kwargs) -> Optional[Icon]:
|
**kwargs) -> Optional[Icon]:
|
||||||
"""Get any icon."""
|
"""Get any icon."""
|
||||||
if icon_hash is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
log.debug('GET {} {} {}', scope, key, icon_hash)
|
log.debug('GET {} {} {}', scope, key, icon_hash)
|
||||||
key = str(key)
|
key = str(key)
|
||||||
|
|
@ -360,6 +358,9 @@ class IconManager:
|
||||||
elif 'size' in kwargs:
|
elif 'size' in kwargs:
|
||||||
image = Image.open(data_fd)
|
image = Image.open(data_fd)
|
||||||
|
|
||||||
|
if mime == 'image/jpeg':
|
||||||
|
image = image.convert("RGB")
|
||||||
|
|
||||||
want = kwargs['size']
|
want = kwargs['size']
|
||||||
|
|
||||||
log.info('resizing from {} to {}',
|
log.info('resizing from {} to {}',
|
||||||
|
|
|
||||||
|
|
@ -638,8 +638,10 @@ class Storage:
|
||||||
return [r[0] for r in rows]
|
return [r[0] for r in rows]
|
||||||
|
|
||||||
async def _msg_regex(self, regex, func, content) -> List[Dict]:
|
async def _msg_regex(self, regex, func, content) -> List[Dict]:
|
||||||
res = []
|
if content is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
res = []
|
||||||
for match in regex.finditer(content):
|
for match in regex.finditer(content):
|
||||||
found_id = match.group(1)
|
found_id = match.group(1)
|
||||||
|
|
||||||
|
|
@ -798,6 +800,9 @@ class Storage:
|
||||||
res['type'] = res['message_type']
|
res['type'] = res['message_type']
|
||||||
res.pop('message_type')
|
res.pop('message_type')
|
||||||
|
|
||||||
|
if res['content'] is None:
|
||||||
|
res['content'] = ""
|
||||||
|
|
||||||
channel_id = int(row['channel_id'])
|
channel_id = int(row['channel_id'])
|
||||||
content = row['content']
|
content = row['content']
|
||||||
guild_id = await self.guild_from_channel(channel_id)
|
guild_id = await self.guild_from_channel(channel_id)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ class Color:
|
||||||
"""Give the actual RGB integer encoding this color."""
|
"""Give the actual RGB integer encoding this color."""
|
||||||
return int('%02x%02x%02x' % (self.red, self.green, self.blue), 16)
|
return int('%02x%02x%02x' % (self.red, self.green, self.blue), 16)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def to_json(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
def __int__(self):
|
def __int__(self):
|
||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue