### Install dota2 from PyPI Source: https://github.com/valvepython/dota2/blob/master/README.rst Installs the latest stable version of the dota2 package from the Python Package Index (PyPI). This is the recommended way to install the package for general use. ```shell pip install dota2 ``` -------------------------------- ### Install dota2 Development Version from GitHub Source: https://github.com/valvepython/dota2/blob/master/README.rst Installs the current development version of the dota2 package directly from its GitHub repository. This is useful for testing the latest features or contributing to the project. The `--upgrade-strategy only-if-needed` flag ensures that dependencies are only updated if necessary. ```shell pip install git+https://github.com/ValvePython/dota2 ``` ```shell pip install -U --upgrade-strategy only-if-needed git+https://github.com/ValvePython/dota2 ``` -------------------------------- ### Initialize Dota 2 Client and Login Source: https://github.com/valvepython/dota2/blob/master/docs/user_guide.rst This snippet demonstrates how to initialize the SteamClient and Dota2Client, log in, and launch the Dota 2 client upon successful connection. It also shows how to set up a callback for when the Dota 2 client is ready. ```python from steam.client import SteamClient from dota2.client import Dota2Client client = SteamClient() dota = Dota2Client(client) @client.on('logged_on') def start_dota(): dota.launch() @dota.on('ready') def do_dota_stuff(): # talk to GC client.cli_login() client.run_forever() ``` -------------------------------- ### Handle Dota 2 Events Source: https://github.com/valvepython/dota2/blob/master/docs/user_guide.rst This section explains how to work with events using the gevent-eventemitter library. It shows how to register callbacks for events, call them once, and block until an event occurs. It also demonstrates how to emit events with optional arguments. ```python @dota.on('my event') def do_stuff(a, b): print "Hey!" dota.on('my event', do_stuff) dota.once('my event', do_stuff) # call do_stuff just one time dota.wait_event('my event') # blocks and returns arguments, if any dota.emit("my event") dota.emit("my event", 1, [3,4,5]) # optional arguments ``` -------------------------------- ### Configure Console Logging for Dota 2 Project Source: https://github.com/valvepython/dota2/blob/master/docs/user_guide.rst This code snippet demonstrates how to configure basic console logging for the project, setting a specific format and level (DEBUG) to capture detailed messages during runtime. This is useful for debugging and understanding the client's internal operations. ```python import logging logging.basicConfig(format='[%(asctime)s] %(levelname)s %(name)s: %(message)s', level=logging.DEBUG) ``` -------------------------------- ### Fetch and Display Dota 2 Player Profile Card Source: https://github.com/valvepython/dota2/blob/master/docs/user_guide.rst This snippet shows how to request a player's profile card using their account ID and how to handle the 'profile_card' event to display the received data. It also illustrates an alternative method using job IDs to wait for the response. ```python @dota.on('ready') def fetch_profile_card(): dota.request_profile_card(70388657) @dota.on('profile_card'): def print_profile_card(account_id, profile_card): if account_id == 70388657: print str(profile_card) @dota.on('ready') def fetch_profile_card(): jobid = dota.request_profile_card(70388657) profile_card = dota.wait_msg(jobid, timeout=10) if profile_card: print str(profile_card) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.