chore: update example
This commit is contained in:
+10
-4
@@ -1,5 +1,4 @@
|
|||||||
import logging
|
import logging
|
||||||
from signal import pause
|
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
@@ -7,13 +6,20 @@ from star_resonance_tracer.proto.enum_chit_chat_channel_type_pb2 import ChitChat
|
|||||||
|
|
||||||
from inventory_wars.game import Game
|
from inventory_wars.game import Game
|
||||||
from inventory_wars.models import Base
|
from inventory_wars.models import Base
|
||||||
|
from inventory_wars.scoring import FirstGuess, HighestAmount
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
engine = create_engine("sqlite:///app.db")
|
engine = create_engine("sqlite:///app.db")
|
||||||
Base.metadata.create_all(engine)
|
Base.metadata.create_all(engine)
|
||||||
|
|
||||||
game = Game(Session(engine), item_id=1040202, listening_channels=[ChitChatChannelType.ChannelTeam])
|
game = Game(Session(engine), listening_channels=[ChitChatChannelType.ChannelTeam])
|
||||||
game.start()
|
while True:
|
||||||
|
item_id = input("Enter item id to start: ")
|
||||||
|
if not item_id:
|
||||||
|
break
|
||||||
|
|
||||||
pause()
|
game.start(int(item_id), HighestAmount())
|
||||||
|
|
||||||
|
input("Enter to end game. ")
|
||||||
|
game.end()
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
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()
|
|
||||||
Reference in New Issue
Block a user