没有项目描述

lcu-driver的Python项目详细描述


LCU驱动器

用于lcu api的python接口。仅支持Windows平台。灵感来自lcu-connector

下载

  • pip install lcu-driver

代码示例

每次运行应用程序时,更改为随机的中文图标。
fromjsonimportdumpsfromrandomimportrandintfromlcu_driverimportConnectorconnector=Connector()asyncdefset_random_icon():# random number of a chinese iconrandom_number=randint(50,78)# make the request to set the iconicon=awaitconnector.request('put','/lol-summoner/v1/current-summoner/icon',data=dumps({'profileIconId':random_number}))# if HTTP status code is 201 the icon was applied successfullyificon.status==201:print(f'Chinese icon number {random_number} was set correctly.')else:print('Unknown problem, the icon was not set.')# fired when LCU API is ready to be used@connector.eventasyncdefconnect():print('LCU API is ready to be used.')# check if the user is already logged into his accountsummoner=awaitconnector.request('get','/lol-summoner/v1/current-summoner')ifsummoner.status==200:data=awaitsummoner.json()# calls login method and update login.left_calls to 0# when login.left_calls is 0 the function can't be fired any more neither by websocket nor manuallyawaitlogin(None,None,data)else:print('Please login into your account to change your icon...')# fired when League Client is closed (or disconnected from websocket)@connector.eventasyncdefdisconnect():print('The client have been closed!')# subscribe to the login websocket event, and calls the function only one time@connector.ws_events(['/lol-summoner/v1/current-summoner'],event_types=['Update'],max_calls=1)asyncdeflogin(typ,uri,data):print('Logged as',data['displayName'])awaitset_random_icon()# opens websocket connection (may be used to wait until the client is closed)connector.listen()# starts everythingconnector.start()

类和方法

class连接器

  • 初始化(自,*,循环=无)

    • 循环

属性

  • PID

    进程ID.
  • 协议 允许协议的元组。

  • 端口

  • 验证键

  • 安装路径

  • 地址

  • WS-U地址

方法

  • 开始()

    启动司机。

  • 听()

    在客户端关闭之前保持连接。(打开WebSocket连接)。

  • <;协同工作>;停止工作

    优雅地停止WebSocket循环。

  • coroutine请求(方法:str,端点:str,**kwargs)

    • 方法-http动词。
    • endpoint-没有协议和主机名的资源url。
    • **kwargs
  • ws_事件(端点:list,*,事件类型:list,max_calls=-1)

    • endpoints-uri列表。
    • 事件类型-事件类型列表(创建、更新或删除)。
    • {STR 1 } $ Max调用< <强> >最大事件事件函数可由WebSoCor或手动调用。将其设置为负数以删除限制。

内置库事件

  • 连接

    在LCU API启动时激发。
  • 断开 在客户端关闭时激发。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
从源WSO2标识服务器生成时发生java错误   java如何在icefaces项目中启用url   java将堆栈中的每个元素打印到文本文件中的新行   java如何将导航抽屉的所有片段放在全屏上?   java EHCache如何实现其事务?   Selenide中的java捕获shouldHave/shouldBe方法   从CSV文件读取java   java如何在ListView行中显示长文本视图高度?   java Tapestry内部重定向到静态页面   TFS使用Java和Eclipse构建   多线程Java线程是否可以在已经持有锁的情况下获得锁?   JavaSwing:使用文档侦听器处理返回键   java在Moshi中保存对象关系