bennetgallein/ts3ab-api

TS3AudioBot WebAPI的OOP API包装器

v1.3 2019-11-15 21:03 UTC

This package is auto-updated.

Last update: 2024-09-16 08:18:22 UTC


README

TS3AudioBot WebAPI的OOP API包装器

此包装器旨在使通过PHP使用TS3AudioBot WebAPI变得更容易。它提供(将来)所有机器人支持的功能。

警告:这是基于开发分支!不要使用仅在开发分支中可用的功能,否则您会遇到一些错误!

意图

这更像是边项目而不是专用项目,因为我需要一个更容易的方法来在PHP后端与机器人的API之间进行通信。

安装

所需PHP版本:7.1

安装view composer

composer require bennetgallein/ts3ab-api

开始使用

  1. 建立连接
$bot = new \TS3AB\Ts3AudioBot("192.168.1.104", "3306");
  1. 认证
$bot->basicAuth("j+W41OpXcHv8In9vt/Q2x+UmUPs=:ts3ab:X38WCfV3srBQBYUYZVkMnpxyBPWlMxZs");

在官方Wiki中了解更多关于认证的信息。

  1. 选择正确的机器人。由于TS3AB允许同时运行多个实例,您需要选择您想要工作的上下文。
var_dump($bot->getCommandExecutor()->list()); // lists all active bots
$bot->getCommandExecutor()->use(0); // tells the API to use bot "0"
  1. 执行命令。
var_dump($bot->getCommandExecutor()->play("https://www.youtube.com/watch?v=xxxx"));

历史记录

$history = $bot->getCommandExecutor()->history();

将歌曲添加到队列中

$history->add(0);

清理历史文件以获得更好的启动性能。

$history->clean();

清理历史文件以获得更好的启动性能。同时检查所有无法再打开的历史链接。

$history->cleanRemovedefective();

从历史中删除条目。

$history->delete(0);

获取给定“.”的用户的上一个歌曲。

$history->historyFrom(10, <userid>);

显示有关歌曲的所有保存信息(也可以是上一个|下一个)

$history->historyID(0);

获取最后一个播放的歌曲。

$history->last(10);

再次播放最后一个歌曲

$history->playLast();

播放歌曲

$history->play(2);

将歌曲“.”的名称设置为“”

$history->rename(0, "new title");

获取直到“.”之前所有播放的歌曲。以下任一描述符:(小时|今天|昨天|周)

$history->till("today");

获取标题包含“”的所有歌曲

$history->filterTitle("filter");

目前所有函数的返回值都是TS3AB API的纯答案,将来可能会更改。