😘 重构完成!!!!!!

This commit is contained in:
jerry
2018-11-28 13:26:18 +08:00
parent 54b0fd41f0
commit d629cf9b96
41 changed files with 1103 additions and 997 deletions

View File

@@ -10,15 +10,30 @@ class GroupManager
{
/**
* 更新群组列表
* @param null $qq
*/
public static function updateGroupList($qq = null) {
Buffer::set("group_list", []);
foreach (CQUtil::getConnections("api") as $k => $v) {
$fd = $v->fd;
$robot_id = $v->getQQ();
Console::put("正在获取机器人 " . $robot_id . " 的群组列表...");
CQUtil::sendAPI($fd, "get_group_list", ["get_group_list", "step1"]);
public static function updateGroupList() {
Cache::set("group_list", []);
foreach (ConnectionManager::getAll("robot") as $k => $v) {
if ($v->getSubType() != "event") {
$robot_id = $v->getQQ();
Console::put("正在获取机器人 " . $robot_id . " 的群组列表...");
$v->sendAPI("get_group_list", [], function ($response) use ($robot_id) {
$list = Cache::get("group_list");
foreach ($response["data"] as $k => $v) {
if (!isset($list[$v["group_id"]])) {
$list[$v["group_id"]] = [
"group_id" => $v["group_id"],
"group_name" => $v["group_name"],
"fetch_members" => false,
"joiner" => [$robot_id]
];
} elseif (!in_array($robot_id, $list[$v["group_id"]]["joiner"])) {
$list[$v["group_id"]]["joiner"][] = $robot_id;
}
}
Cache::set("group_list", $list);
});
}
}
}
}