# 音频控制
# 使用示例
import botpy
from botpy.audio import Audio
class MyClient(botpy.Client):
async def on_audio_start(self, audio: Audio):
audio_control={
"audio_url":"url",
"text":"简单爱-周杰伦",
"status":"START",
}
await self.api.update_audio(audio.channel_id, audio_control=audio_control)
intents = botpy.Intents(audio_action=True)
client = MyClient(intents=intents)
client.run(appid={appid}, token={token})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 参数说明
字段名 | 类型 | 描述 |
---|---|---|
channel_id | String | 子频道 id |
audio_control | AudioControl | audio 控制参数 |
# 返回说明
字段参见 AudioControl
# 语音对象
# AudioControl
字段名 | 类型 | 描述 |
---|---|---|
audio_url | string | 音频数据的 url status 为 0 时传 |
text | string | 状态文本(比如:简单爱-周杰伦),可选,status 为 0 时传,其他操作不传 |
status | STATUS | 播放状态,参考 STATUS |
# STATUS
字段名 | 值 | 描述 |
---|---|---|
START | 0 | 开始播放操作 |
PAUSE | 1 | 暂停播放操作 |
RESUME | 2 | 继续播放操作 |
STOP | 3 | 停止播放操作 |