Apricot-S / majsoulrpa

A Robotic Process Automation (RPA) framework for Mahjong Soul (雀魂)
Other
19 stars 5 forks source link

A new API found: `.lq.Lobby.fetchManagerCustomizedContestList` #281

Closed Apricot-S closed 2 weeks ago

Apricot-S commented 1 month ago

概要

大会に入室した際、新しい API .lq.Lobby.fetchManagerCustomizedContestList がやり取りされた。 現在 majsoulrpa に同梱している liqi_pb2.py に入っていないため、 liqi_pb2.py の更新およびメッセージ処理の追加が必要である。

詳細

実行したスクリプト

examples\enter_tournament.py

エラーメッセージ

(前略)
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.loginSuccess', {}, {}, datetime.datetime(2024, 7, 24, 9, 30, 10, 983251, tzinfo=datetime.timezone.utc))
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.heatbeat', {'no_operation_counter': 0}, {'error': {'code': 0, 'u32_params': [], 'str_params': [], 'json_param': ''}}, datetime.datetime(2024, 7, 24, 9, 30, 11, 390945, tzinfo=datetime.timezone.utc))
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.heatbeat', {'no_operation_counter': 0}, {'error': {'code': 0, 'u32_params': [], 'str_params': [], 'json_param': ''}}, datetime.datetime(2024, 7, 24, 9, 30, 12, 542528, tzinfo=datetime.timezone.utc))
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.loginBeat', {'contract': 'DF2vkXCnfeXp4WoGSBGNcJBufZiMN3UP'}, {}, datetime.datetime(2024, 7, 24, 9, 30, 12, 793821, tzinfo=datetime.timezone.utc))
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.loginBeat', {'contract': 'DF2vkXCnfeXp4WoGSBGNcJBufZiMN3UP'}, {}, datetime.datetime(2024, 7, 24, 9, 30, 12, 823415, tzinfo=datetime.timezone.utc))
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.heatbeat', {'no_operation_counter': 0}, {'error': {'code': 0, 'u32_params': [], 'str_params': [], 'json_param': ''}}, datetime.datetime(2024, 7, 24, 9, 30, 16, 452128, tzinfo=datetime.timezone.utc))
Tournament ID: 000000
INFO:majsoulrpa.presentation.home:('outbound', '.lq.Lobby.heatbeat', {'no_operation_counter': 0}, {'error': {'code': 0, 'u32_params': [], 'str_params': [], 'json_param': ''}}, datetime.datetime(2024, 7, 24, 9, 30, 20, 460244, tzinfo=datetime.timezone.utc))
Traceback (most recent call last):
  File "C:\Users\K_K\Documents\Program\mahjong\majsoulrpa\src\majsoulrpa\_impl\zmq_client.py", line 124, in jsonize
    parser = self._message_type_map[name][0]()
             ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: '.lq.Lobby.fetchManagerCustomizedContestList'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\xxx\Documents\Program\mahjong\majsoulrpa\examples\enter_tournament.py", line 61, in <module>
    presentation.enter_tournament(tournament_id)
  File "C:\Users\xxx\Documents\Program\mahjong\majsoulrpa\src\majsoulrpa\presentation\home.py", line 504, in enter_tournament
    message = self._message_queue_client.dequeue_message(1)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\Documents\Program\mahjong\majsoulrpa\src\majsoulrpa\_impl\zmq_client.py", line 147, in dequeue_message
    jsonized_request = jsonize(name, request_data, is_response=False)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\Documents\Program\mahjong\majsoulrpa\src\majsoulrpa\_impl\zmq_client.py", line 137, in jsonize
    raise RuntimeError(msg) from ke
RuntimeError: A new API found:
  name: .lq.Lobby.fetchManagerCustomizedContestList
Raw data was saved to 2024-07-24-09-30-28-.lq.Lobby.fetchManagerCustomizedContestList.bin.
Please cooperate by providing data. Thank you for your cooperation.

生データ

バイナリのため Hex Editor で表示した内容を添付する

0A 02 6A 70
Apricot-S commented 1 month ago

liqi_pb2.py を更新したあとの上記メッセージのログ

majsoulrpa.presentation.exceptions.InconsistentMessageError: ("('outbound', '.lq.Lobby.fetchManagerCustomizedContestList', {'lang': 'jp'}, {'contests': []}, datetime.datetime(2024, 7, 24, 10, 30, 56, 677216, tzinfo=datetime.timezone.utc))", '2024-07-24-10-30-57-InconsistentMessageError')
Apricot-S commented 1 month ago

API に関するメモ

新しい liqi.proto から .lq.Lobby.fetchCustomizedContestExtendInfo が削除されている

新旧ファイルの差分から

などに分解されたと推測される

Apricot-S commented 1 month ago

大会ロビーで以下のメッセージが 20 秒間隔でやり取りされる 以下は mitmdump のエラーメッセージ

[19:30:12.087] Addon error: An unknown WebSocket message:
direction: outbound
content: b'<= heartbeat -'
Traceback (most recent call last):
  File "C:\Users\xxx\Documents\Program\mahjong\majsoulrpa\src\majsoulrpa\_mitmproxy\sniffer.py", line 128, in websocket_message
    raise RuntimeError(msg)
RuntimeError: An unknown WebSocket message:
direction: outbound
content: b'<= heartbeat -'
Apricot-S commented 2 weeks ago

b'<= heartbeat -' に関しては mitmdump 側で読み捨ててメッセージキューには保存しないこととする。

Apricot-S commented 2 weeks ago

develop を main にマージしたあとクローズする予定です。