🐛 try not to die.

This commit is contained in:
jerry 2018-11-28 15:43:04 +08:00
parent a8c856d816
commit 04518bb4a6
2 changed files with 10 additions and 8 deletions

View File

@ -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);
}

View File

@ -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));
}