mirror of
https://github.com/yulinfeng000/blive.git
synced 2025-04-02 15:40:44 +08:00
update README
This commit is contained in:
parent
b75335c306
commit
14c641528a
55
README.md
55
README.md
@ -13,47 +13,48 @@
|
|||||||
|
|
||||||
1. 创建 app
|
1. 创建 app
|
||||||
|
|
||||||
> 目前请克隆该代码仓库,并执行 pip install -r rquirements.txt
|
> 目前请克隆该代码仓库,并执行 pip install -r rquirements.txt
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from blive import BLiver
|
from blive import BLiver
|
||||||
|
|
||||||
app = BLiver(123) #123为房间号
|
app = BLiver(123) #123为房间号
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 创建处理器
|
2. 创建处理器
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from blive import BLiver, Events, BLiverCtx
|
from blive import BLiver, Events, BLiverCtx
|
||||||
|
|
||||||
app = BLiver(123)
|
app = BLiver(123)
|
||||||
|
|
||||||
# 标记该方法监听弹幕消息,更多消息类型请参考 Events 类源代码
|
# 标记该方法监听弹幕消息,更多消息类型请参考 Events 类源代码
|
||||||
@app.on(Events.DANMU_MSG)
|
@app.on(Events.DANMU_MSG)
|
||||||
async def listen_danmu(ctx: BLiverCtx):
|
async def listen_danmu(ctx: BLiverCtx):
|
||||||
danmu = DanMuMsg(ctx.body) #ctx.body 套上相应的消息操作类即可得到消息的基本内容,也可直接操作 ctx.body
|
danmu = DanMuMsg(ctx.body) #ctx.body 套上相应的消息操作类即可得到消息的基本内容,也可直接操作 ctx.body
|
||||||
print(danmu.content)
|
print(danmu.content)
|
||||||
print(danmu.sender)
|
print(danmu.sender)
|
||||||
print(danmu.timestamp)
|
print(danmu.timestamp)
|
||||||
```
|
```
|
||||||
|
|
||||||
3. 运行
|
3. 运行
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
from blive import BLiver, Events, BLiverCtx
|
from blive import BLiver, Events, BLiverCtx
|
||||||
|
|
||||||
app = BLiver(123)
|
app = BLiver(123)
|
||||||
@app.on(Events.DANMU_MSG)
|
|
||||||
async def listen_danmu(ctx: BLiverCtx):
|
|
||||||
danmu = DanMuMsg(ctx.body)
|
|
||||||
print(danmu.content)
|
|
||||||
print(danmu.sender)
|
|
||||||
print(danmu.timestamp)
|
|
||||||
|
|
||||||
app.run() # 运行app!
|
@app.on(Events.DANMU_MSG)
|
||||||
|
async def listen_danmu(ctx: BLiverCtx):
|
||||||
|
danmu = DanMuMsg(ctx.body)
|
||||||
|
print(danmu.content)
|
||||||
|
print(danmu.sender)
|
||||||
|
print(danmu.timestamp)
|
||||||
|
|
||||||
```
|
app.run() # 运行app!
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## 项目简介
|
## 项目简介
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user