Properly masquerade chat messages sent via the bridge to elasticsearch

Conserve the original nested message in the unformatted chat field
feature/embed-uploads
Tristan Gosselin-Hane 7 years ago
parent f24d730294
commit d31913134a
  1. 14
      webhook-bridge.py

@ -296,11 +296,21 @@ def main():
regexp_match = re.match("<(.*?)> (.*)", chat_string, re.M|re.I) regexp_match = re.match("<(.*?)> (.*)", chat_string, re.M|re.I)
if regexp_match: if regexp_match:
username = regexp_match.group(1) username = regexp_match.group(1)
original_message = regexp_match.group(2)
player_uuid = mc_username_to_uuid(username)
if username.lower() == BOT_USERNAME.lower(): if username.lower() == BOT_USERNAME.lower():
# Don't relay our own messages # Don't relay our own messages
if config.es_enabled:
bot_message_match = re.match("<{}> (.*?): (.*)".format(
BOT_USERNAME.lower()), chat_string, re.M | re.I)
if bot_message_match:
es_chat_message(
uuid=UUID_CACHE.inv[bot_message_match.group(1)],
display_name=bot_message_match.group(1),
message=bot_message_match.group(2),
message_unformatted=chat_string)
es_raw_message(type=ChatType(chat_packet.position).name, message=chat_packet.json_data)
return return
original_message = regexp_match.group(2)
player_uuid = mc_username_to_uuid(username)
logging.info("Username: {} Message: {}".format(username, original_message)) logging.info("Username: {} Message: {}".format(username, original_message))
logging.debug("msg: {}".format(repr(original_message))) logging.debug("msg: {}".format(repr(original_message)))
message = remove_emoji(original_message.strip().replace("@", "@\N{zero width space}")) message = remove_emoji(original_message.strip().replace("@", "@\N{zero width space}"))

Loading…
Cancel
Save