albibong 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {albibong-1.0.1 → albibong-1.0.2}/.gitignore +7 -0
  2. {albibong-1.0.1 → albibong-1.0.2}/PKG-INFO +1 -1
  3. {albibong-1.0.1 → albibong-1.0.2}/pyproject.toml +1 -1
  4. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/__init__.py +32 -27
  5. albibong-1.0.2/src/albibong/__main__.py +6 -0
  6. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/character.py +3 -0
  7. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/logger.py +13 -2
  8. albibong-1.0.2/src/albibong/classes/utils.py +9 -0
  9. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/world_data.py +31 -17
  10. albibong-1.0.2/src/albibong/resources/EventCode.py +587 -0
  11. albibong-1.0.2/src/albibong/resources/event_code.json +585 -0
  12. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/resources/items.json +15569 -15530
  13. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/threads/http_server.py +3 -3
  14. albibong-1.0.1/src/albibong/__main__.py +0 -4
  15. albibong-1.0.1/src/albibong/resources/EventCode.py +0 -579
  16. albibong-1.0.1/src/albibong/resources/event_code.json +0 -577
  17. {albibong-1.0.1 → albibong-1.0.2}/LICENSE +0 -0
  18. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/__init__.py +0 -0
  19. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/coords.py +0 -0
  20. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/dungeon.py +0 -0
  21. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/item.py +0 -0
  22. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/location.py +0 -0
  23. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/classes/packet_handler.py +0 -0
  24. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/No Equipment.png +0 -0
  25. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/assets/index-BFSx0nua.css +0 -0
  26. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/assets/index-DAndaN_4.js +0 -0
  27. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/fame.png +0 -0
  28. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/index.html +0 -0
  29. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/re_spec.png +0 -0
  30. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/silver.png +0 -0
  31. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/gui_dist/vite.svg +0 -0
  32. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/__init__.py +0 -0
  33. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/command_type.py +0 -0
  34. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/crc_calculator.py +0 -0
  35. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/event_data.py +0 -0
  36. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/message_type.py +0 -0
  37. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/number_serializer.py +0 -0
  38. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/operation_request.py +0 -0
  39. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/operation_response.py +0 -0
  40. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/photon_packet_parser.py +0 -0
  41. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/protocol16_deserializer.py +0 -0
  42. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/protocol16_type.py +0 -0
  43. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/photon_packet_parser/segmented_packet.py +0 -0
  44. {albibong-1.0.1 → albibong-1.0.2/src/albibong}/requirements.txt +0 -0
  45. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/resources/OperationCode.py +0 -0
  46. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/resources/maps.json +0 -0
  47. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/resources/operation_code.json +0 -0
  48. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/threads/__init__.py +0 -0
  49. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/threads/packet_handler_thread.py +0 -0
  50. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/threads/sniffer_thread.py +0 -0
  51. {albibong-1.0.1 → albibong-1.0.2}/src/albibong/threads/websocket_server.py +0 -0
@@ -1,6 +1,13 @@
1
1
  # Created by https://www.toptal.com/developers/gitignore/api/python,macos
2
2
  # Edit at https://www.toptal.com/developers/gitignore?templates=python,macos
3
3
 
4
+
5
+ ## Additional
6
+ dump/
7
+ log/
8
+ pcap/
9
+ .vscode
10
+
4
11
  ### macOS ###
5
12
  # General
6
13
  .DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: albibong
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: A cross-platform Albion Online damage, fame, and dungeon tracker
5
5
  Project-URL: Homepage, https://github.com/imjangkar/albibong
6
6
  Project-URL: Issues, https://github.com/imjangkar/albibong/issues
@@ -19,7 +19,7 @@ albibong = "albibong:main"
19
19
 
20
20
  [project]
21
21
  name = "albibong"
22
- version = "1.0.1"
22
+ version = "1.0.2"
23
23
  authors = [
24
24
  { name="imjangkar", email="imjangkar@gmail.com" },
25
25
  ]
@@ -1,4 +1,5 @@
1
1
  import queue
2
+ import random
2
3
  import sys
3
4
  from time import sleep
4
5
 
@@ -13,7 +14,7 @@ from albibong.threads.sniffer_thread import SnifferThread
13
14
  from albibong.threads.websocket_server import get_ws_server
14
15
 
15
16
  logger = Logger(__name__, stdout=True, log_to_file=False)
16
-
17
+ PORT = random.randrange(8500,8999)
17
18
 
18
19
  def read_pcap(path):
19
20
  packet_handler = PacketHandler()
@@ -22,7 +23,7 @@ def read_pcap(path):
22
23
  packet_handler.handle(packet)
23
24
 
24
25
 
25
- def sniff():
26
+ def sniff(useWebview):
26
27
  _sentinel = object()
27
28
  packet_queue = queue.Queue()
28
29
 
@@ -40,39 +41,43 @@ def sniff():
40
41
  ws_server = get_ws_server()
41
42
  ws_server.start()
42
43
 
43
- http_server = HttpServerThread(name="http_server")
44
- http_server.start()
45
-
46
- # sleep(0.25)
47
- # with open("../gui/dist/index.html", "r") as html:
48
- window = webview.create_window(
49
- "Albibong",
50
- # "../../gui/dist/index.html",
51
- url="http://localhost:8000/",
52
- width=1280,
53
- height=720,
54
- zoomable=True,
55
- )
44
+ if useWebview:
45
+ print("addr",PORT)
46
+
47
+ http_server = HttpServerThread(name="http_server", port=PORT)
48
+ http_server.start()
56
49
 
57
- def on_closing():
58
- c.stop()
59
- p.stop()
60
- ws_server.stop()
61
- http_server.stop()
50
+ window = webview.create_window(
51
+ "Albibong",
52
+ url=f"http://localhost:{PORT}/",
53
+ width=1280,
54
+ height=720,
55
+ zoomable=True,
56
+ )
62
57
 
63
- window.events.closing += on_closing
58
+ def on_closing():
59
+ c.stop()
60
+ p.stop()
61
+ ws_server.stop()
62
+ http_server.stop()
64
63
 
65
- webview.start()
64
+ window.events.closing += on_closing
65
+
66
+ webview.start()
67
+ else:
68
+ try:
69
+ while True:
70
+ sleep(100)
71
+ except KeyboardInterrupt as e:
72
+ p.stop()
73
+ ws_server.stop()
66
74
 
67
75
 
68
- def main():
76
+ def main(useWebview=True):
69
77
  if len(sys.argv) > 1:
70
78
  ws_server = get_ws_server()
71
79
  ws_server.start()
72
80
 
73
- http_server = HttpServerThread(name="http_server")
74
- http_server.start()
75
-
76
81
  read_pcap(sys.argv[1])
77
82
  else:
78
- sniff()
83
+ sniff(useWebview)
@@ -0,0 +1,6 @@
1
+ from albibong import main
2
+ from albibong.classes.logger import use_logger
3
+
4
+ if __name__ == "__main__":
5
+ use_logger(True)
6
+ main(useWebview=False)
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from uuid import UUID
2
3
 
3
4
  from albibong.classes.coords import Coords
4
5
  from albibong.classes.item import Item
@@ -12,6 +13,7 @@ class Character:
12
13
  def __init__(
13
14
  self,
14
15
  id: int,
16
+ uuid: UUID,
15
17
  username: str,
16
18
  guild: str,
17
19
  alliance: str,
@@ -19,6 +21,7 @@ class Character:
19
21
  equipment: list[Item] = [Item.get_item_from_code("0")] * 10,
20
22
  ):
21
23
  self.id = id
24
+ self.uuid = uuid
22
25
  self.username = username
23
26
  self.guild = guild
24
27
  self.alliance = alliance
@@ -7,6 +7,13 @@ from scapy.all import wrpcap
7
7
 
8
8
  from albibong.photon_packet_parser import EventData, OperationRequest, OperationResponse
9
9
 
10
+ isUsingLogger = False
11
+
12
+
13
+ def use_logger(value):
14
+ global isUsingLogger
15
+ isUsingLogger = value
16
+
10
17
 
11
18
  class Logger(logging.Logger):
12
19
  def __init__(
@@ -25,7 +32,7 @@ class Logger(logging.Logger):
25
32
 
26
33
  self.file_timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H%M%S")
27
34
  log_filepath = os.path.join(
28
- os.path.expanduser("~"), f"Albibong/log/log_{self.file_timestamp}.txt"
35
+ os.path.dirname(__file__), f"../../../log/log_{self.file_timestamp}.txt"
29
36
  )
30
37
  os.makedirs(os.path.dirname(log_filepath), exist_ok=True)
31
38
 
@@ -63,6 +70,9 @@ class Logger(logging.Logger):
63
70
  return datetime.now(timezone.utc).strftime("%H:%M:%S")
64
71
 
65
72
  def log_payload(self, payload):
73
+ if not isUsingLogger:
74
+ return
75
+
66
76
  if type(payload) == EventData:
67
77
  self.log_event(payload)
68
78
  elif type(payload) == OperationRequest:
@@ -72,8 +82,9 @@ class Logger(logging.Logger):
72
82
 
73
83
  def log_dps_meter_state(self, state: bool):
74
84
  text = f"{self.get_timestamp()} DPS METER IS {'RUNNING. The damages below this point will be recorded.' if state else 'PAUSED. The damages below this point will NOT be recorded.'}"
75
- self.info(text)
76
85
  print(text)
86
+ if isUsingLogger:
87
+ self.info(text)
77
88
 
78
89
  def log_event(self, payload: EventData):
79
90
  if self.ignore_event:
@@ -0,0 +1,9 @@
1
+ from uuid import UUID
2
+
3
+
4
+ class Utils:
5
+
6
+ @staticmethod
7
+ def convert_int_arr_to_uuid(arr):
8
+ b = bytes(arr)
9
+ return UUID(bytes=b)
@@ -1,12 +1,14 @@
1
1
  import json
2
2
  import os
3
3
  from collections import deque
4
+ from uuid import UUID
4
5
 
5
6
  from albibong.classes.character import Character
6
7
  from albibong.classes.coords import Coords
7
8
  from albibong.classes.dungeon import Dungeon
8
9
  from albibong.classes.item import Item
9
10
  from albibong.classes.location import Location
11
+ from albibong.classes.utils import Utils
10
12
  from albibong.resources.EventCode import EventCode
11
13
  from albibong.resources.OperationCode import OperationCode
12
14
  from albibong.threads.websocket_server import send_event
@@ -20,6 +22,7 @@ class WorldData:
20
22
  def __init__(self) -> None:
21
23
  self.me: Character = Character(
22
24
  id=None,
25
+ uuid=None,
23
26
  username="not initialized",
24
27
  guild="not initialized",
25
28
  alliance="not initialized",
@@ -29,6 +32,7 @@ class WorldData:
29
32
  self.current_dungeon: Dungeon = None
30
33
  self.characters: dict[str, Character] = {}
31
34
  self.char_id_to_username: dict[int, str] = {self.me.id: self.me.username}
35
+ self.char_uuid_to_username: dict[UUID, str] = {self.me.uuid: self.me.username}
32
36
  self.change_equipment_log: dict[int, list] = {}
33
37
  self.party_members: set[str] = set()
34
38
  self.is_dps_meter_running: bool = True
@@ -39,6 +43,8 @@ class WorldData:
39
43
  self.handle_join_response(parameters)
40
44
  elif parameters[253] == OperationCode.CHANGE_CLUSTER.value:
41
45
  self.set_location(parameters)
46
+ # elif parameters[253] == OperationCode.PARTY_LEAVE.value:
47
+ # self.party_members = set(self.me.username)
42
48
 
43
49
  def handle_event(self, parameters):
44
50
  if 252 in parameters:
@@ -73,6 +79,7 @@ class WorldData:
73
79
  elif parameters[252] == EventCode.NEW_CHARACTER.value:
74
80
  self.create_character(
75
81
  id=parameters[0],
82
+ uuid=parameters[7],
76
83
  username=parameters[1],
77
84
  guild=parameters[8] if 8 in parameters else "",
78
85
  alliance=parameters[49] if 49 in parameters else "",
@@ -159,19 +166,20 @@ class WorldData:
159
166
  send_event(event)
160
167
 
161
168
  def update_party_member(self, parameters):
162
- if self.me != None:
163
- self.party_members.add(self.me.username)
164
169
  if parameters[252] == EventCode.PARTY_JOINED.value:
165
- for member in parameters[5]:
166
- self.party_members.add(member)
170
+ self.party_members = set(parameters[5])
167
171
  elif parameters[252] == EventCode.PARTY_DISBANDED.value:
168
172
  self.party_members = set()
169
173
  elif parameters[252] == EventCode.PARTY_PLAYER_JOINED.value:
170
174
  self.party_members.add(parameters[2])
171
175
  elif parameters[252] == EventCode.PARTY_PLAYER_LEFT.value:
172
- if parameters[0] in self.char_id_to_username:
173
- name = self.char_id_to_username[parameters[0]]
174
- self.party_members.remove(name)
176
+ uuid = UUID(bytes=bytes(parameters[1]))
177
+ if uuid in self.char_uuid_to_username:
178
+ name = self.char_uuid_to_username[uuid]
179
+ if name == self.me.username:
180
+ self.party_members = set()
181
+ if self.me.id != None:
182
+ self.party_members.add(self.me.username)
175
183
  event = {
176
184
  "type": "update_dps",
177
185
  "payload": {"party_members": self.serialize_party_members()},
@@ -193,14 +201,17 @@ class WorldData:
193
201
  def change_character_equipment(self, parameters):
194
202
  if 2 in parameters:
195
203
  if parameters[0] in self.char_id_to_username:
196
- char = self.characters[self.char_id_to_username[parameters[0]]]
197
- if char.username in self.party_members:
198
- char.update_equipment(parameters[2])
199
- event = {
200
- "type": "update_dps",
201
- "payload": {"party_members": self.serialize_party_members()},
202
- }
203
- send_event(event)
204
+ if self.char_id_to_username[parameters[0]] != "not initialized":
205
+ char = self.characters[self.char_id_to_username[parameters[0]]]
206
+ if char.username in self.party_members:
207
+ char.update_equipment(parameters[2])
208
+ event = {
209
+ "type": "update_dps",
210
+ "payload": {
211
+ "party_members": self.serialize_party_members()
212
+ },
213
+ }
214
+ send_event(event)
204
215
  else:
205
216
  self.change_equipment_log[parameters[0]] = parameters[2]
206
217
 
@@ -209,15 +220,15 @@ class WorldData:
209
220
 
210
221
  self.convert_id_to_name(old_id=self.me.id, new_id=parameters[0], char=self.me)
211
222
 
223
+ self.me.uuid = Utils.convert_int_arr_to_uuid(parameters[1])
212
224
  self.me.username = parameters[2]
213
225
  self.me.guild = parameters[57] if 57 in parameters else ""
214
226
  self.me.alliance = parameters[77] if 77 in parameters else ""
215
227
  self.characters[self.me.username] = self.me
228
+ self.char_uuid_to_username[self.me.uuid] = self.me.username
216
229
  if self.me.id in self.change_equipment_log:
217
230
  self.me.update_equipment(self.change_equipment_log[self.me.id])
218
231
 
219
- self.party_members.add(self.me.username)
220
-
221
232
  # set map my character is currently in
222
233
  if parameters[8][0] == "@":
223
234
  area = parameters[8].split("@")
@@ -258,6 +269,7 @@ class WorldData:
258
269
  def create_character(
259
270
  self,
260
271
  id: int,
272
+ uuid: list[int],
261
273
  username: str,
262
274
  guild: str,
263
275
  alliance: str,
@@ -269,6 +281,7 @@ class WorldData:
269
281
  if username not in self.characters:
270
282
  char: Character = Character(
271
283
  id=id,
284
+ uuid=Utils.convert_int_arr_to_uuid(uuid),
272
285
  username=username,
273
286
  guild=guild,
274
287
  alliance=alliance,
@@ -277,6 +290,7 @@ class WorldData:
277
290
  char.update_equipment(equipments)
278
291
  self.characters[char.username] = char
279
292
  self.char_id_to_username[char.id] = char.username
293
+ self.char_uuid_to_username[char.uuid] = char.username
280
294
 
281
295
  # change map
282
296
  else: