From 04518bb4a6f4aa6b3001d4d7f3539a66fee40c9f Mon Sep 17 00:00:00 2001 From: jerry Date: Wed, 28 Nov 2018 15:43:04 +0800 Subject: [PATCH] :bug: try not to die. --- src/cqbot/utils/CQUtil.php | 10 ++++++---- src/cqbot/utils/DataProvider.php | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cqbot/utils/CQUtil.php b/src/cqbot/utils/CQUtil.php index 756c07cc..ba23e752 100755 --- a/src/cqbot/utils/CQUtil.php +++ b/src/cqbot/utils/CQUtil.php @@ -24,7 +24,7 @@ class CQUtil public static function loadAllFiles() { Cache::set("info_level", settings()["info_level"]); - Console::debug("loading configs..."); + Console::info("loading configs..."); self::initEmptyCaches(); Cache::set("mods", self::getMods());//加载的模块列表 Cache::set("group_list", DP::getJsonData("group_list.json"));//获取群组列表 @@ -235,7 +235,7 @@ class CQUtil Console::info("Reloading server"); self::saveAllFiles(); Cache::$data = []; - foreach(ConnectionManager::getAll() as $v){ + foreach (ConnectionManager::getAll() as $v) { $v->close(); } Cache::$server->reload(); @@ -344,8 +344,10 @@ class CQUtil if (!in_array($v->getQQ(), $robots)) $robots[] = $v->getQQ(); } - foreach (Cache::get("bots") as $v) { - $robots[] = $v; + if ((Cache::get("bots") ?? []) != []) { + foreach (Cache::get("bots") as $v) { + $robots[] = $v; + } } return in_array($user_id, $robots); } diff --git a/src/cqbot/utils/DataProvider.php b/src/cqbot/utils/DataProvider.php index bc14655a..2376db8a 100755 --- a/src/cqbot/utils/DataProvider.php +++ b/src/cqbot/utils/DataProvider.php @@ -16,7 +16,7 @@ class DataProvider * 获取config文件夹 * @return string */ - public static function getDataFolder(){ + public static function getDataFolder() { return CONFIG_DIR; } @@ -24,7 +24,7 @@ class DataProvider * 获取用户数据的文件夹 * @return string */ - public static function getUserFolder(){ + public static function getUserFolder() { return USER_DIR; } @@ -33,7 +33,7 @@ class DataProvider * @param $filename * @return array|mixed */ - static function getJsonData($filename){ + static function getJsonData($filename) { if (!file_exists(self::getDataFolder() . $filename)) return array(); return json_decode(file_get_contents(self::getDataFolder() . $filename), true); } @@ -44,7 +44,7 @@ class DataProvider * @param $filename * @param array $args */ - static function setJsonData($filename, array $args){ + static function setJsonData($filename, array $args) { file_put_contents(self::getDataFolder() . $filename, json_encode($args, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING)); }