ValvePython / dota2

🐸 Python package for interacting with Dota 2 Game Coordinator
http://dota2.readthedocs.io
201 stars 32 forks source link

AttributeError: 'Dota2Client' object has no attribute 'get_channel_list' #28

Closed LadaBr closed 7 years ago

LadaBr commented 7 years ago

I updated latest chat files from pull requests and I need to get list of all available dota chat channels. I want to join closest one or at least find them by name but I have problem with getting of the list.

pprint(dota.get_channel_list()) AttributeError: 'Dota2Client' object has no attribute 'get_channel_list' Thu Apr 13 15:58:20 2017 <Greenlet at 0x7f25aa55ad58: do_dota_stuff> failed with AttributeError

    import logging
    logging.basicConfig(format='[%(asctime)s] %(levelname)s %(name)s: %(message)s', level=logging.DEBUG)
    client = SteamClient()
    client.set_credential_location("steam_credentials")
    dota = Dota2Client(client)

    @client.on('connected')
    def login():
        bot = dota_bots.objects.filter(available=True)[0]
        username = bot.username
        password = bot.password
        client.cli_login(username, password)

    @client.on('logged_on')
    def start_dota():
        dota.launch()

    @dota.on('ready')
    def do_dota_stuff():
        pprint(dota.__dict__)
        pprint(dota.get_channel_list())
        dota.exit()

    @dota.on('notready')
    def end():
        client.logout()

    client.connect()
    try:
        client.wait_event("disconnected", timeout=30, raises=True)
    except gevent.Timeout:
        end()
rossengeorgiev commented 7 years ago

Are you using the chat_channel branch? Also, that method will raise an exception as Valve return invalid unicode data resulting in a decode exception within the protobuf package. The only workaround is to patch the protobuf source file to ignore unicode decode exceptions

LadaBr commented 7 years ago

Whats different in last chat update? Nothing works same like before. I cannot call functions like this: dota.join_lobby_channel() dota.get_channel_list() dota.send_message() I guess it has something to do with chat_channel branch. How do I use it?

LadaBr commented 7 years ago

So I finally found out whats different. Now I have to call object like this: dota.channels.join_channel()