Better logging of incoming and outgoing messages

feature/embed-uploads
Tristan Gosselin-Hane 7 years ago
parent 319c0e911a
commit cdeb7f777d
No known key found for this signature in database
GPG Key ID: 86886FC44C72EAA1
  1. 6
      webhook-bridge.py

@ -358,7 +358,7 @@ def main():
message_unformatted=chat_string) message_unformatted=chat_string)
el.log_raw_message(type=ChatType(chat_packet.position).name, message=chat_packet.json_data) el.log_raw_message(type=ChatType(chat_packet.position).name, message=chat_packet.json_data)
return return
log.info("Username: {} Message: {}".format(username, original_message)) log.info("Incoming message from minecraft: Username: {} Message: {}".format(username, original_message))
log.debug("msg: {}".format(repr(original_message))) log.debug("msg: {}".format(repr(original_message)))
message = escape_markdown(remove_emoji(original_message.strip().replace("@", "@\N{zero width space}"))) message = escape_markdown(remove_emoji(original_message.strip().replace("@", "@\N{zero width space}")))
webhook_payload = { webhook_payload = {
@ -621,8 +621,6 @@ def main():
message.clean_content.encode('utf-8').decode('ascii', 'replace')).strip() message.clean_content.encode('utf-8').decode('ascii', 'replace')).strip()
message_to_discord = escape_markdown(message.clean_content) message_to_discord = escape_markdown(message.clean_content)
log.info(str(len(message_to_send)) + " " + repr(message_to_send))
total_len = padding + len(message_to_send) total_len = padding + len(message_to_send)
if total_len > 256: if total_len > 256:
message_to_send = message_to_send[:(256 - padding)] message_to_send = message_to_send[:(256 - padding)]
@ -659,6 +657,8 @@ def main():
PREVIOUS_MESSAGE = message_to_send PREVIOUS_MESSAGE = message_to_send
NEXT_MESSAGE_TIME = datetime.now(timezone.utc) + timedelta(seconds=config.message_delay) NEXT_MESSAGE_TIME = datetime.now(timezone.utc) + timedelta(seconds=config.message_delay)
log.info("Outgoing message from discord: Username: {} Message: {}".format(minecraft_username, message_to_send))
for channel in channels: for channel in channels:
webhooks = await discord_bot.get_channel(channel.channel_id).webhooks() webhooks = await discord_bot.get_channel(channel.channel_id).webhooks()
for webhook in webhooks: for webhook in webhooks:

Loading…
Cancel
Save