Skip to main content

No project description provided

Project description

lcu-driver

Python interface for LCU API. Only support Windows platform. Inspired in lcu-connector

Download

  • pip install lcu-driver

  • pip install git+https://github.com/sousa-andre/lcu-driver.git

Code example

Subclassing Connector:

import lcu_driver


class MyConnector(lcu_driver.Connector):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.subscribe_event('OnJsonApiEvent_lol-summoner_v1_current-summoner')

    @staticmethod
    def connect(process, api):
        con.subscribe_event('OnJsonApiEvent_lol-summoner_v1_current-summoner')

        response = api.fetch('get', '/lol-summoner/v1/current-summoner')
        if response.status_code == 200:
            data = response.json()
            print('You are already logged as {}.'.format(data['displayName']))
        else:
            print('The client is already opened, please login now.')

    @staticmethod
    def disconnect():
        print('The client has been closed!')

    @staticmethod
    def message(data):
        if 'accountId' in data['data']:
            print('Logging in as {}.'.format(data['data']['displayName']))


con = MyConnector()
con.start()

Using decorators:

import lcu_driver


con = lcu_driver.Connector()


@con.event
def connect(process, api):
    response = api.fetch('get', '/lol-summoner/v1/current-summoner')
    if response.status_code == 200:
        data = response.json()
        print('You are already logged as {}.'.format(data['displayName']))
    else:
        print('The client is already opened, please login now.')


@con.event
def disconnect():
    print('The client has been closed!')


@con.event
def message(data):
    if 'accountId' in data['data']:
        print('Logging in as {}.'.format(data['data']['displayName']))


con.start()

Classes and methods

class Connector

  • __init__(keep_running: bool = False, wait_for_client: bool = True, connect_via_websocket: bool = False)

    • keep_running - After disconnect will keep looking for other clients.
    • wait_for_client - Block execution until find a running client.
    • connect_via_websocket - Start websocket connection.

Methods

  • subscribe_event(*events: str)

    Entitle the events to be subscribed by the websocket connection.

  • start()

    Start looking for client using the settings defined in the constructor.

Events

  • connect

    <func>(process: ProcessDTO, api: APIDTO)
    Fired when LCU API start.
  • disconnect

    <func>()
    Fired when the client is closed.
  • message

    <func>(data: dict)
    Fired when a websocket event occurs.

class ProcessDTO

  • __init__(**kwargs)

class APIDTO

  • __init__(**kwargs)

Methods

  • fetch(method: str, endpoint: str, **kwargs) -> requests.request

    • method - HTTP verb
    • endpoint - Resource URL without protocol and host name.
    • **kwargs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lcu-driver, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size lcu_driver-0.0.1-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lcu-driver-0.0.1.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page