1
0
This repository has been archived on 2026-06-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
inventory-wars/scripts/sniff_items.py
T
2026-06-01 23:38:51 +08:00

41 lines
1.3 KiB
Python

from signal import pause
from star_resonance_tracer.proto.enum_chit_chat_msg_type_pb2 import ChitChatMsgType
from star_resonance_tracer.proto.serv_chit_chat_ntf_pb2 import ChitChatNtf as ChitChatNtfPb
from star_resonance_tracer.proto.stru_place_holder_item_pb2 import PlaceHolderItem
from star_resonance_tracer.sniffer import Sniffer
from inventory_wars.const import ChitChatNtf, decode_placeholder, HypertextVariant
from inventory_wars.sniffer import get_sniffer
def on_chit_chat_msg(event: ChitChatNtfPb.NotifyNewestChitChatMsgs) -> None:
req = event.vRequest
if req.chatMsg.msgInfo.msgType is not ChitChatMsgType.ChatMsgHypertext:
return
hypertext = req.chatMsg.msgInfo.chatHypertext
if hypertext.configId != HypertextVariant.ITEM_SHARING.value:
return
for placeholder in hypertext.hypertextContents:
placeholder_content = decode_placeholder(placeholder)
match placeholder_content:
case PlaceHolderItem() as item:
print(item)
sniffer = Sniffer()
sniffer.set_service_type(
ChitChatNtf.ServiceId.value,
ChitChatNtf.Method.NotifyNewestChitChatMsgs.value,
ChitChatNtfPb.NotifyNewestChitChatMsgs
)
sniffer.on_service(ChitChatNtfPb.NotifyNewestChitChatMsgs, on_chit_chat_msg)
scapy = get_sniffer(sniffer)
scapy.start()
pause()