Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #122 from kelltom/osr-28-add-latest-msg-features-t…
Browse files Browse the repository at this point in the history
…o-morg-api-utility

Added function to get latest chat message
  • Loading branch information
kelltom authored Jan 28, 2023
2 parents b6cd88a + f548e06 commit 9981298
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/utilities/api/morg_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ def get_game_tick(self) -> int:
data = self.__do_get(endpoint=self.events_endpoint)
return int(data["game tick"]) if "game tick" in data else -1

def get_latest_chat_message(self) -> str:
"""
Fetches the most recent chat message in the chat box.
Returns:
A string representing the latest chat message.
"""
data = self.__do_get(endpoint=self.events_endpoint)
return data["latest msg"] if "latest msg" in data else ""

def get_player_position(self) -> Tuple[int, int, int]:
"""
Fetches the world point of a player.
Expand Down Expand Up @@ -420,10 +429,14 @@ def convert_player_position_to_pixels(self):
print("No xp gained.")

# Equipment Data
if True:
if False:
print(f"Is bronze axe equipped?: {api.get_is_item_equipped(ids.BRONZE_AXE)}")
print(f"How many bronze arrows equipped?: {api.get_equipped_item_quantity(ids.BRONZE_ARROW)}")

# Chatbox Data
if True:
print(f"Latest chat message: {api.get_latest_chat_message()}")

time.sleep(2)

print("\n--------------------------\n")

0 comments on commit 9981298

Please sign in to comment.