Merge branch 'master' of github.com:Dishesdog/BiliHelper-personal

This commit is contained in:
Dishesdog 2021-08-23 17:52:47 +08:00
commit 71b80e6001
8 changed files with 35 additions and 24 deletions

6
.gitignore vendored
View File

@ -29,10 +29,14 @@ conf/user1.ini
/src/backup/
script.php
# ignore all files in lib/
task/*
cache/*
log/*
# ignore all files in lib/
#task/*
#cache/*
#log/*
# except for .gitkeep
!.gitkeep
# ignore TODO file in root directory,not subdir/TODO

3
cache/.gitkeep vendored
View File

@ -1,3 +0,0 @@
# Ignore everything in this directory
*
# Except this file !.gitkeep

View File

@ -1,3 +1,5 @@
version = 0.0.1
#######################
# 账户设置 #
#######################
@ -265,10 +267,9 @@ proxy = "http://127.0.0.1:8888"
[debug]
enable = false
; 记录日志|日志路径|日志回调地址
; 记录日志|日志回调地址
[log]
enable = false
path = log
callback = "http://www.example.com/api.send?text={account}[{level}]: {message}"
# 错误回调级别
#

View File

@ -1,3 +0,0 @@
# Ignore everything in this directory
*
# Except this file !.gitkeep

View File

@ -27,11 +27,29 @@ class App
*/
public function __construct(string $app_path)
{
define('APP_CONF_PATH', $app_path . "/conf/");
define('APP_DATA_PATH', $app_path . "/data/");
define('APP_LOG_PATH', $app_path . "/log/");
define('APP_TASK_PATH', $app_path . "/task/");
define('APP_CACHE_PATH', $app_path . "/cache/");
define('APP_CONF_PATH', $app_path . '/conf/');
define('APP_DATA_PATH', $app_path . '/data/');
define('APP_LOG_PATH', $app_path . '/log/');
define('APP_TASK_PATH', $app_path . '/task/');
define('APP_CACHE_PATH', $app_path . '/cache/');
}
/**
* @use 初始化数据文件夹
* @param int $permissions
* @return $this
*/
private function initDataFolder(int $permissions = 0777): App
{
// log task cache
$data_folder = [APP_LOG_PATH, APP_TASK_PATH, APP_CACHE_PATH];
foreach ($data_folder as $path) {
if (!file_exists($path)) {
mkdir($path);
chmod($path, $permissions);
}
}
return $this;
}
/**
@ -51,6 +69,7 @@ class App
*/
public function load($argv): App
{
$this->initDataFolder();
$args = (new BCommand($argv))->run();
$filename = $args->args()[0] ?? 'user.ini';
// 加载配置

View File

@ -65,12 +65,8 @@ class Log
if ($type == 'DEBUG' && !getConf('enable', 'debug')) {
return;
}
$path = './' . getConf('path', 'log') . '/';
if (!file_exists($path)) {
mkdir($path);
chmod($path, 0777);
}
$filename = $path . getConf('username', 'login.account') . ".log";
$filename = APP_LOG_PATH . getConf('username', 'login.account') . ".log";
$date = date('[Y-m-d H:i:s] ');
$data = $date . ' Log.' . $type . ' ' . $message . PHP_EOL;
file_put_contents($filename, $data, FILE_APPEND);

View File

@ -191,7 +191,7 @@ class User
* @param bool $un_follow
* @return bool
*/
public static function setUserFollow(int $follow_uid, bool $un_follow): bool
public static function setUserFollow(int $follow_uid, bool $un_follow = false): bool
{
$url = 'https://api.live.bilibili.com/relation/v1/Feed/SetUserFollow';
$payload = [

View File

@ -1,3 +0,0 @@
# Ignore everything in this directory
*
# Except this file !.gitkeep