没有项目描述

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第三方库


热门话题
java二进制到十进制   使用GSON时发生java非法状态异常   java ImageJ API:如何将一个图像插入另一个图像   java使用ajax从servlet获取价值   每个容器每个bean的JavaSpring单例作用域   VTD XML查找重影/不存在路径时出现java错误   RPC方法调用中的java Nullpointer异常   java使用索引排序是否有效   安卓 java中Json类中get和getJSONObject的区别是什么   java为什么要添加系统。出来println能让线程运行得更快吗?   java标识符预期问题   反射可以在Java中反射私有静态方法吗   Java SonarQube错误“最终公开静态字段”   终端一直在请求输入?[爪哇]