Handle DMs, reply in DM
This commit is contained in:
+11
-3
@@ -34,7 +34,13 @@ def component_text(value):
|
||||
if 'text' in fields:
|
||||
return component_text(fields['text']) + component_text(fields.get('extra', []))
|
||||
if 'translate' in fields:
|
||||
return component_text(fields['translate']) + component_text(fields.get('with', []))
|
||||
translation = component_text(fields['translate'])
|
||||
arguments = fields.get('with', [])
|
||||
if translation == 'commands.message.display.incoming' and len(arguments) >= 2:
|
||||
return '{} whispers to you: {}'.format(
|
||||
component_text(arguments[0]),
|
||||
component_text(arguments[1]))
|
||||
return translation + component_text(arguments)
|
||||
return ''.join(component_text(v) for v in fields.values())
|
||||
if isinstance(value, (list, tuple)):
|
||||
return ''.join(component_text(item) for item in value)
|
||||
@@ -135,12 +141,14 @@ def main(global_state=None):
|
||||
@connection.listener(SystemChat)
|
||||
def on_system_chat(packet):
|
||||
message = component_text(packet.content)
|
||||
chat_handled = False
|
||||
if global_state is not None:
|
||||
global_state.last_chat = message
|
||||
chat = global_state.get('chat')
|
||||
if chat is not None:
|
||||
chat.handle_system_chat(packet, message)
|
||||
print('[server] ' + message, flush=True)
|
||||
chat_handled = chat.handle_system_chat(packet, message)
|
||||
if not chat_handled:
|
||||
print('[server] ' + message, flush=True)
|
||||
lowered = message.lower()
|
||||
if 'already registered' in lowered:
|
||||
send_auth_command('login')
|
||||
|
||||
Reference in New Issue
Block a user