Protocol: Improve machine-readability of prints (#1388)

* Protocol: Improve machine-readability of prints

* Factorio: Make use of new PrintJSON fields for echo detection.

* Protocol: Add message field to chat prints.
This commit is contained in:
recklesscoder
2023-02-13 03:17:25 +01:00
committed by GitHub
parent 9e3c2e2464
commit cc61f16e57
4 changed files with 79 additions and 47 deletions

View File

@@ -341,6 +341,11 @@ class CommonContext:
return self.slot in self.slot_info[slot].group_members
return False
def is_echoed_chat(self, print_json_packet: dict) -> bool:
return print_json_packet.get("type", "") == "Chat" \
and print_json_packet.get("team", None) == self.team \
and print_json_packet.get("slot", None) == self.slot
def is_uninteresting_item_send(self, print_json_packet: dict) -> bool:
"""Helper function for filtering out ItemSend prints that do not concern the local player."""
return print_json_packet.get("type", "") == "ItemSend" \