mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 07:35:34 +08:00
😘 重构完成!!!!!!
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user