Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from steam import SteamClient
- from dota2 import Dota2Client
- from steam.enums import EResult
- from steam.core.msg import MsgProto
- from steam.enums.emsg import EMsg
- import vdf
- client = SteamClient()
- dota = Dota2Client(client)
- game_modes={
- 1:"All Pick", 2:"Captains Mode", 3:"Random Draft", 4:"Single Draft",
- 5:"All Random", 6:"Intro", 7:"Diretide", 8:"Reverse Captains Mode",
- 9:"The Greeviling", 10:"Tutorial", 11:"Mid Only", 12:"Least Played",
- 13:"New Player Pool", 14:"Compendium Matchmaking", 15:"Custom Game",
- 16:"Captains Draft", 18:"Ability Draft", 19:"Frostivus",
- 20:"All Random Deathmatch", 21:"1v1 Mid Only", 22:"All Pick",
- 23:"TURBO", 24:"Mutation"
- }
- @client.on('logged_on')
- def start_dota():
- dota.launch()
- @dota.on('ready')
- def do_dota_stuff():
- message = MsgProto(EMsg.ClientRichPresenceRequest)
- message.body.steamid_request.extend([76561198834285820,76561198821117459,76561198402813610,76561198804617230, 76561198431841319])
- message.header.routing_appid=570
- resp = client.send_message_and_wait(message, EMsg.ClientRichPresenceInfo)
- lobbies= []
- for rich_presence in resp.rich_presence:
- rp = vdf.binary_loads(rich_presence.rich_presence_kv)['RP']
- if 'WatchableGameID' in rp:
- print(rp['WatchableGameID'])
- lobbies.append(int(rp['WatchableGameID']))
- dota.request_top_source_tv_games(lobby_ids=lobbies)
- @dota.on('top_source_tv_games')
- def watchtabresponse(result):
- if result.specific_games == True:
- #print(result)
- for game in result.game_list:
- txt = ''
- if game.game_mode in game_modes:
- txt+=game_modes[game.game_mode]
- else:
- txt+='None'
- print(txt)
- print(len(result.game_list))
- client.cli_login()
- client.run_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement