-
Notifications
You must be signed in to change notification settings - Fork 41
lol chat
XHXIAIEIN edited this page Jun 1, 2022
·
3 revisions
API 笔记: lol-chat
import asyncio
import willump
async def main():
wllp = await willump.start()
friends = await (await wllp.request("GET", "/lol-chat/v1/friends")).json()
print([e['name'] for e in friends])
await wllp.close()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
/lol-chat/v1/conversations
返回数据
[
{
"gameName": "",
"gameTag": "",
"id": "",
"inviterId": "",
"isMuted": false,
"lastMessage":
{
"body": "你好",
"fromId": "",
"fromPid": "",
"fromSummonerId": 0,
"id": "",
"isHistorical": false,
"timestamp": "2021-02-01T09:17:17.662Z",
"type": "chat"
},
"name": "",
"password": "",
"pid": "",
"targetRegion": "",
"type": "championSelect",
"unreadMessageCount": 0
}
]
主要是获取这几个信息
- id 信息的ID,作为其他API的参数。
- lastMessage['body'] 消息主体,就是具体发了什么内容。
- lastMessage['fromSummonerId'] 是哪位召唤师发送的消息,这里获得的是
SummonerId
,而不是召唤师名称。 - lastMessage['timestamp'] 发送时间。这个是已经被格式化的时间戳。可以用
new Date()
将strtime
转换成Unix timestamp