Open Mrfull opened 3 years ago
When i try to handle lobby_changed and check all_members bot return this:
lobby_changed
all_members
[2021-07-17 17:33:05,837] DEBUG Dota2Client.socache: Emit event: ('updated', <ESOType.CSODOTALobby: 2004>) [2021-07-17 17:33:05,838] DEBUG Dota2Client: Emit event: 'lobby_changed' [2021-07-17 17:33:05,838] INFO root: Event: Lobby Change: lobby_id: 27287648318433685 game_mode: 21 state: UI leader_id: 76561199183817488 lobby_type: PRACTICE allow_cheats: false fill_with_bots: false intro_mode: false game_name: "CyberT | test" server_region: 0 cm_pick: DOTA_CM_RANDOM allow_spectating: true bot_difficulty_radiant: BOT_DIFFICULTY_PASSIVE game_version: GAME_VERSION_CURRENT leagueid: 0 penalty_level_radiant: 0 penalty_level_dire: 0 series_type: 0 radiant_series_wins: 0 dire_series_wins: 0 allchat: false dota_tv_delay: LobbyDotaTV_120 lan: false visibility: DOTALobbyVisibility_Public previous_match_override: 0 pause_setting: LobbyDotaPauseSetting_Unlimited bot_difficulty_dire: BOT_DIFFICULTY_PASSIVE bot_radiant: 0 bot_dire: 0 selection_priority_rules: k_DOTASelectionPriorityRules_Manual league_node_id: 0 league_phase: 0 all_members { id: 76561199183817488 team: DOTA_GC_TEAM_PLAYER_POOL name: "cybertbot3" slot: 0 leaver_status: DOTA_LEAVER_DISCONNECTED partner_account_type: PARTNER_NONE favorite_team_packed: 0 is_plus_subscriber: true was_mvp_last_game: false } all_members { id: 76561198254757677 team: DOTA_GC_TEAM_PLAYER_POOL name: "Mr.full" leaver_status: DOTA_LEAVER_DISCONNECTED channel: 6 partner_account_type: PARTNER_NONE favorite_team_packed: 0 is_plus_subscriber: false was_mvp_last_game: false } member_indices: 0 member_indices: 1 [2021-07-17 17:33:05,838] INFO root: Event: State: 0 all members len: 2 All members: [id: 76561199183817488 team: DOTA_GC_TEAM_PLAYER_POOL name: "cybertbot3" slot: 0 leaver_status: DOTA_LEAVER_DISCONNECTED partner_account_type: PARTNER_NONE favorite_team_packed: 0 is_plus_subscriber: true was_mvp_last_game: false , id: 76561198254757677 team: DOTA_GC_TEAM_PLAYER_POOL name: "Mr.full" leaver_status: DOTA_LEAVER_DISCONNECTED channel: 6 partner_account_type: PARTNER_NONE favorite_team_packed: 0 is_plus_subscriber: false was_mvp_last_game: false ]
And that is correct, but if player leave lobby i get:
[2021-07-17 17:33:12,487] DEBUG Dota2Client: Emit event: 'lobby_changed' [2021-07-17 17:33:12,487] INFO root: Event: Lobby Change: lobby_id: 27287648318433685 game_mode: 21 state: UI leader_id: 76561199183817488 lobby_type: PRACTICE allow_cheats: false fill_with_bots: false intro_mode: false game_name: "CyberT | test" server_region: 0 cm_pick: DOTA_CM_RANDOM allow_spectating: true bot_difficulty_radiant: BOT_DIFFICULTY_PASSIVE game_version: GAME_VERSION_CURRENT leagueid: 0 penalty_level_radiant: 0 penalty_level_dire: 0 series_type: 0 radiant_series_wins: 0 dire_series_wins: 0 allchat: false dota_tv_delay: LobbyDotaTV_120 lan: false visibility: DOTALobbyVisibility_Public previous_match_override: 0 pause_setting: LobbyDotaPauseSetting_Unlimited bot_difficulty_dire: BOT_DIFFICULTY_PASSIVE bot_radiant: 0 bot_dire: 0 selection_priority_rules: k_DOTASelectionPriorityRules_Manual league_node_id: 0 league_phase: 0 all_members { id: 76561199183817488 team: DOTA_GC_TEAM_PLAYER_POOL name: "cybertbot3" slot: 0 leaver_status: DOTA_LEAVER_DISCONNECTED partner_account_type: PARTNER_NONE favorite_team_packed: 0 is_plus_subscriber: true was_mvp_last_game: false } all_members { } member_indices: 0 free_member_indices: 1 [2021-07-17 17:33:12,487] INFO root: Event: State: 0 all members len: 2 All members: [id: 76561199183817488 team: DOTA_GC_TEAM_PLAYER_POOL name: "cybertbot3" slot: 0 leaver_status: DOTA_LEAVER_DISCONNECTED partner_account_type: PARTNER_NONE favorite_team_packed: 0 is_plus_subscriber: true was_mvp_last_game: false , ]
So, as you can see script don't clear array of all_members
My code:
class DotaController: def __init__(self): self.client = SteamClient() self.dota = Dota2Client(self.client) # get lobby proto CSODOTALobbyProto = so.find_so_proto(ESOType.CSODOTALobby) LobbyState = CSODOTALobbyProto.State # add this callback for event 'lobby_changed' self.dota.on('lobby_changed', self.lobby_change_handler) self.client.on('disconnected', self.reconnect_client) # lobby state handler dispatch self.state_handler_dispatch = dict([ (LobbyState.UI, self.test), (LobbyState.READYUP, self.test), (LobbyState.NOTREADY, self.test), (LobbyState.SERVERSETUP, self.test), (LobbyState.RUN, self.test), (LobbyState.POSTGAME, self.post_game_handler), (LobbyState.SERVERASSIGN, self.test) ]) def lobby_change_handler(self, message): logging.info(f"Event: Lobby Change: {message}") # if message field has state print("all members: " + str(len(message.all_members))) if message.HasField('state'): # call appropriate handler for lobby state self.state_handler_dispatch[message.state](message) def post_game_handler(self, message): print("message: " + str(message)) print("match_outcome: " + str(message.match_outcome)) def test(self, message): logging.info(f"Event: State: {message.state}")
For sure i'm authorised
When i try to handle
lobby_changed
and checkall_members
bot return this:And that is correct, but if player leave lobby i get:
So, as you can see script don't clear array of
all_members
My code: