@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @return bool |
| 56 | 56 | * @throws \Exception |
| 57 | 57 | */ |
| 58 | - public static function debug($message, array $context = []) |
|
| 58 | + public static function debug($message, array $context = [ ]) |
|
| 59 | 59 | { |
| 60 | 60 | return self::logger()->addDebug($message, $context); |
| 61 | 61 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @return bool |
| 68 | 68 | * @throws \Exception |
| 69 | 69 | */ |
| 70 | - public static function info($message, array $context = []) |
|
| 70 | + public static function info($message, array $context = [ ]) |
|
| 71 | 71 | { |
| 72 | 72 | return self::logger()->addInfo($message, $context); |
| 73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @return bool |
| 80 | 80 | * @throws \Exception |
| 81 | 81 | */ |
| 82 | - public static function notice($message, array $context = []) |
|
| 82 | + public static function notice($message, array $context = [ ]) |
|
| 83 | 83 | { |
| 84 | 84 | return self::logger()->addNotice($message, $context); |
| 85 | 85 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return bool |
| 92 | 92 | * @throws \Exception |
| 93 | 93 | */ |
| 94 | - public static function warning($message, array $context = []) |
|
| 94 | + public static function warning($message, array $context = [ ]) |
|
| 95 | 95 | { |
| 96 | 96 | return self::logger()->addWarning($message, $context); |
| 97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @return bool |
| 104 | 104 | * @throws \Exception |
| 105 | 105 | */ |
| 106 | - public static function error($message, array $context = []) |
|
| 106 | + public static function error($message, array $context = [ ]) |
|
| 107 | 107 | { |
| 108 | 108 | return self::logger()->addError($message, $context); |
| 109 | 109 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @return bool |
| 116 | 116 | * @throws \Exception |
| 117 | 117 | */ |
| 118 | - public static function alert($message, array $context = []) |
|
| 118 | + public static function alert($message, array $context = [ ]) |
|
| 119 | 119 | { |
| 120 | 120 | return self::logger()->addAlert($message, $context); |
| 121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return bool |
| 128 | 128 | * @throws \Exception |
| 129 | 129 | */ |
| 130 | - public static function emergency($message, array $context = []) |
|
| 130 | + public static function emergency($message, array $context = [ ]) |
|
| 131 | 131 | { |
| 132 | 132 | return self::logger()->addEmergency($message, $context); |
| 133 | 133 | } |
@@ -40,17 +40,17 @@ |
||
| 40 | 40 | $keys = explode('.', $key); |
| 41 | 41 | $val = $lang; |
| 42 | 42 | foreach ($keys as $k) { |
| 43 | - if (!isset($val[$k])) { |
|
| 43 | + if (!isset($val[ $k ])) { |
|
| 44 | 44 | return null; // 任一下标不存在就返回null |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $val = $val[$k]; |
|
| 47 | + $val = $val[ $k ]; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $val; |
| 51 | 51 | } else { |
| 52 | - if (isset($lang[$key])) { |
|
| 53 | - return $lang[$key]; |
|
| 52 | + if (isset($lang[ $key ])) { |
|
| 53 | + return $lang[ $key ]; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return null; |
@@ -43,17 +43,17 @@ |
||
| 43 | 43 | $keys = explode('.', $key); |
| 44 | 44 | $val = $allConfig; |
| 45 | 45 | foreach ($keys as $k) { |
| 46 | - if (!isset($val[$k])) { |
|
| 46 | + if (!isset($val[ $k ])) { |
|
| 47 | 47 | return $default; // 任一下标不存在就返回默认值 |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $val = $val[$k]; |
|
| 50 | + $val = $val[ $k ]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | return $val; |
| 54 | 54 | } else { |
| 55 | - if (isset($allConfig[$key])) { |
|
| 56 | - return $allConfig[$key]; |
|
| 55 | + if (isset($allConfig[ $key ])) { |
|
| 56 | + return $allConfig[ $key ]; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $default; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * 'bg_green', 'bg_yellow', 'bg_blue', 'bg_magenta', 'bg_cyan', 'bg_light_gray', 'bg_dark_gray', 'bg_light_red', |
| 59 | 59 | * 'bg_light_green','bg_light_yellow', 'bg_light_blue', 'bg_light_magenta', 'bg_light_cyan', 'bg_white' |
| 60 | 60 | */ |
| 61 | - function system_log($content, array $response = [], $fileName = '') |
|
| 61 | + function system_log($content, array $response = [ ], $fileName = '') |
|
| 62 | 62 | { |
| 63 | 63 | try { |
| 64 | 64 | $path = sprintf('%s/logs/%s/', ROOT_PATH, date('Y-m')); |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // 在 Github Actions 上运行,过滤敏感信息 |
| 85 | 85 | if (env('ON_GITHUB_ACTIONS')) { |
| 86 | - $msg = preg_replace_callback('/(?P<secret>[\w-.]{1,4}?)(?=@[\w-.]+)/i', function ($m) { |
|
| 87 | - return str_ireplace($m['secret'], str_repeat('*', strlen($m['secret'])), $m['secret']); |
|
| 86 | + $msg = preg_replace_callback('/(?P<secret>[\w-.]{1,4}?)(?=@[\w-.]+)/i', function($m) { |
|
| 87 | + return str_ireplace($m[ 'secret' ], str_repeat('*', strlen($m[ 'secret' ])), $m[ 'secret' ]); |
|
| 88 | 88 | }, $msg); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'recipient_name' => '主人', // 收件人名字 |
| 22 | 22 | 'username' => env('MAIL_USERNAME'), // 机器人邮箱账户
|
| 23 | 23 | 'password' => env('MAIL_PASSWORD'), // 机器人邮箱密码或授权码
|
| 24 | - 'enable' => (int)env('MAIL_ENABLE'), // 是否启用,默认启用
|
|
| 24 | + 'enable' => (int) env('MAIL_ENABLE'), // 是否启用,默认启用
|
|
| 25 | 25 | |
| 26 | 26 | 'not_enabled_tips' => env('MAIL_USERNAME') && env('MAIL_PASSWORD'), // 提醒未启用
|
| 27 | 27 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'telegram' => [ |
| 43 | 43 | 'chat_id' => env('TELEGRAM_CHAT_ID'), // 你的chat_id,通过发送“/start”给@userinfobot可以获取自己的id
|
| 44 | 44 | 'token' => env('TELEGRAM_BOT_TOKEN'), // Telegram Bot 的 token
|
| 45 | - 'enable' => (int)env('TELEGRAM_BOT_ENABLE'), // 是否启用,默认不启用
|
|
| 45 | + 'enable' => (int) env('TELEGRAM_BOT_ENABLE'), // 是否启用,默认不启用
|
|
| 46 | 46 | |
| 47 | 47 | 'not_enabled_tips' => env('TELEGRAM_CHAT_ID') && env('TELEGRAM_BOT_TOKEN'), // 提醒未启用
|
| 48 | 48 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | 'wechat' => [ |
| 59 | 59 | 'corp_id' => env('WECHAT_CORP_ID'), // 企业 ID
|
| 60 | 60 | 'corp_secret' => env('WECHAT_CORP_SECRET'), // 企业微信应用的凭证密钥
|
| 61 | - 'agent_id' => (int)env('WECHAT_AGENT_ID'), // 企业微信应用 ID
|
|
| 62 | - 'enable' => (int)env('WECHAT_ENABLE'), // 是否启用,默认不启用
|
|
| 61 | + 'agent_id' => (int) env('WECHAT_AGENT_ID'), // 企业微信应用 ID
|
|
| 62 | + 'enable' => (int) env('WECHAT_ENABLE'), // 是否启用,默认不启用
|
|
| 63 | 63 | |
| 64 | 64 | 'not_enabled_tips' => env('WECHAT_CORP_ID') && env('WECHAT_CORP_SECRET') && env('WECHAT_AGENT_ID'), // 提醒未启用
|
| 65 | 65 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | 'sct' => [ |
| 74 | 74 | 'sct_send_key' => env('SCT_SEND_KEY'), // SendKey
|
| 75 | - 'enable' => (int)env('SCT_ENABLE'), // 是否启用,默认不启用
|
|
| 75 | + 'enable' => (int) env('SCT_ENABLE'), // 是否启用,默认不启用
|
|
| 76 | 76 | |
| 77 | - 'not_enabled_tips' => (bool)env('SCT_SEND_KEY'), // 提醒未启用
|
|
| 77 | + 'not_enabled_tips' => (bool) env('SCT_SEND_KEY'), // 提醒未启用
|
|
| 78 | 78 | |
| 79 | 79 | 'class' => \Luolongfei\Libs\MessageServices\ServerChan::class, |
| 80 | 80 | 'name' => 'Server 酱', |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | 'bark' => [ |
| 87 | 87 | 'bark_key' => env('BARK_KEY'), // 打开 Bark App,注册设备后看到的 Key
|
| 88 | - 'bark_url' => (string)env('BARK_URL'), // Bark 域名
|
|
| 89 | - 'bark_is_archive' => env('BARK_IS_ARCHIVE') === '' ? null : (int)env('BARK_IS_ARCHIVE'),
|
|
| 88 | + 'bark_url' => (string) env('BARK_URL'), // Bark 域名
|
|
| 89 | + 'bark_is_archive' => env('BARK_IS_ARCHIVE') === '' ? null : (int) env('BARK_IS_ARCHIVE'),
|
|
| 90 | 90 | 'bark_group' => env('BARK_GROUP') === '' ? null : env('BARK_GROUP'),
|
| 91 | 91 | 'bark_level' => env('BARK_LEVEL'),
|
| 92 | 92 | 'bark_icon' => env('BARK_ICON') === '' ? null : env('BARK_ICON'),
|
| 93 | 93 | 'bark_jump_url' => env('BARK_JUMP_URL') === '' ? null : env('BARK_JUMP_URL'),
|
| 94 | 94 | 'bark_sound' => env('BARK_SOUND') === '' ? null : env('BARK_SOUND'),
|
| 95 | - 'enable' => (int)env('BARK_ENABLE'), // 是否启用,默认不启用
|
|
| 95 | + 'enable' => (int) env('BARK_ENABLE'), // 是否启用,默认不启用
|
|
| 96 | 96 | |
| 97 | 97 | 'not_enabled_tips' => env('BARK_KEY') && env('BARK_URL'), // 提醒未启用
|
| 98 | 98 | |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | ], |
| 103 | 103 | |
| 104 | 104 | 'locale' => 'zh', // 指定语言包,位于resources/lang/目录下 |
| 105 | - 'notice_freq' => (int)env('NOTICE_FREQ', 1), // 通知频率 0:仅当有续期操作的时候 1:每次执行
|
|
| 106 | - 'verify_ssl' => (bool)env('VERIFY_SSL', 0), // 请求时验证 SSL 证书行为,默认不验证,防止服务器证书过期或证书颁布者信息不全导致无法发出请求
|
|
| 107 | - 'debug' => (bool)env('DEBUG'),
|
|
| 105 | + 'notice_freq' => (int) env('NOTICE_FREQ', 1), // 通知频率 0:仅当有续期操作的时候 1:每次执行
|
|
| 106 | + 'verify_ssl' => (bool) env('VERIFY_SSL', 0), // 请求时验证 SSL 证书行为,默认不验证,防止服务器证书过期或证书颁布者信息不全导致无法发出请求
|
|
| 107 | + 'debug' => (bool) env('DEBUG'),
|
|
| 108 | 108 | 'freenom_proxy' => env('FREENOM_PROXY') ?: null, // FreeNom 代理,针对国内网络情况,可选择代理访问
|
| 109 | - 'new_version_detection' => (bool)env('NEW_VERSION_DETECTION', 1),
|
|
| 109 | + 'new_version_detection' => (bool) env('NEW_VERSION_DETECTION', 1),
|
|
| 110 | 110 | ]; |
| 111 | 111 | \ No newline at end of file |
@@ -33,18 +33,18 @@ |
||
| 33 | 33 | $result = false; |
| 34 | 34 | |
| 35 | 35 | foreach (config('message') as $conf) { |
| 36 | - if ($conf['enable'] !== 1) { |
|
| 37 | - if ($conf['not_enabled_tips'] && self::$notEnabledTips) { // 仅在存在配置的送信项未启用的情况下提醒 |
|
| 38 | - system_log(sprintf('由于没有启用「%s」功能,故本次不通过「%s」送信,尽管检测到相关配置。', $conf['name'], $conf['name'])); |
|
| 36 | + if ($conf[ 'enable' ] !== 1) { |
|
| 37 | + if ($conf[ 'not_enabled_tips' ] && self::$notEnabledTips) { // 仅在存在配置的送信项未启用的情况下提醒 |
|
| 38 | + system_log(sprintf('由于没有启用「%s」功能,故本次不通过「%s」送信,尽管检测到相关配置。', $conf[ 'name' ], $conf[ 'name' ])); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | continue; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $serviceInstance = self::getInstance($conf['class'], 'IS_MESSAGE_SERVICE'); |
|
| 44 | + $serviceInstance = self::getInstance($conf[ 'class' ], 'IS_MESSAGE_SERVICE'); |
|
| 45 | 45 | |
| 46 | 46 | if (!$serviceInstance instanceof MessageServiceInterface) { |
| 47 | - throw new \Exception(sprintf('消息服务类 %s 必须继承并实现 MessageServiceInterface 接口', $conf['class'])); |
|
| 47 | + throw new \Exception(sprintf('消息服务类 %s 必须继承并实现 MessageServiceInterface 接口', $conf[ 'class' ])); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if ($serviceInstance->$method(...$params) && !$result) { // 任一方式送信成功即为成功 |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | } else { |
| 91 | 91 | $host = config('message.mail.host'); |
| 92 | 92 | $secure = config('message.mail.encryption'); |
| 93 | - $port = (int)config('message.mail.port'); |
|
| 93 | + $port = (int) config('message.mail.port'); |
|
| 94 | 94 | if (!($host && $secure && $port)) { |
| 95 | 95 | throw new MailException('目前支持Gmail、QQ邮箱、163邮箱以及Outlook邮箱自动识别配置,其它类型的邮箱或者自建邮箱,' |
| 96 | 96 | . '请在 .env 文件中追加“自定义邮箱配置”的所有相关项,否则无法使用邮件服务。'); |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - return [$host, $secure, $port]; |
|
| 100 | + return [ $host, $secure, $port ]; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @throws LlfException |
| 157 | 157 | * @throws MailException |
| 158 | 158 | */ |
| 159 | - public function send(string $content, string $subject = '', int $type = 1, array $data = [], ?string $recipient = null, ...$params) |
|
| 159 | + public function send(string $content, string $subject = '', int $type = 1, array $data = [ ], ?string $recipient = null, ...$params) |
|
| 160 | 160 | { |
| 161 | 161 | $recipient = $recipient ?: config('message.mail.to'); |
| 162 | 162 | |
@@ -200,17 +200,17 @@ discard block |
||
| 200 | 200 | } else if ($type === 2) { |
| 201 | 201 | $template = file_get_contents(RESOURCES_PATH . '/mail/successful_renewal.html'); |
| 202 | 202 | $realData = [ |
| 203 | - $data['username'], |
|
| 204 | - $data['renewalSuccessArr'] ? sprintf('续期成功:%s<br>', $this->genDomainsHtml($data['renewalSuccessArr'])) : '', |
|
| 205 | - $data['renewalFailuresArr'] ? sprintf('续期出错:%s<br>', $this->genDomainsHtml($data['renewalFailuresArr'])) : '', |
|
| 206 | - $this->genDomainStatusHtml($data['domainStatusArr']) |
|
| 203 | + $data[ 'username' ], |
|
| 204 | + $data[ 'renewalSuccessArr' ] ? sprintf('续期成功:%s<br>', $this->genDomainsHtml($data[ 'renewalSuccessArr' ])) : '', |
|
| 205 | + $data[ 'renewalFailuresArr' ] ? sprintf('续期出错:%s<br>', $this->genDomainsHtml($data[ 'renewalFailuresArr' ])) : '', |
|
| 206 | + $this->genDomainStatusHtml($data[ 'domainStatusArr' ]) |
|
| 207 | 207 | ]; |
| 208 | 208 | $message = $this->genMessageContent($realData, $template); |
| 209 | 209 | } else if ($type === 3) { |
| 210 | 210 | $template = file_get_contents(RESOURCES_PATH . '/mail/no_renewal_required.html'); |
| 211 | 211 | $realData = [ |
| 212 | - $data['username'], |
|
| 213 | - $this->genDomainStatusHtml($data['domainStatusArr']) |
|
| 212 | + $data[ 'username' ], |
|
| 213 | + $this->genDomainStatusHtml($data[ 'domainStatusArr' ]) |
|
| 214 | 214 | ]; |
| 215 | 215 | $message = $this->genMessageContent($realData, $template); |
| 216 | 216 | } else if ($type === 4) { |
@@ -168,18 +168,18 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function getMarkDownRawArr(string $markDownTable) |
| 170 | 170 | { |
| 171 | - $rawArr = []; |
|
| 171 | + $rawArr = [ ]; |
|
| 172 | 172 | $markDownTableArr = preg_split("/(?:\n|\r\n)+/", $markDownTable); |
| 173 | 173 | |
| 174 | 174 | foreach ($markDownTableArr as $row) { |
| 175 | - $row = (string)preg_replace('/^\s+|\s+$|\s+|(?<=\|)\s+|\s+(?=\|)/', '', $row); |
|
| 175 | + $row = (string) preg_replace('/^\s+|\s+$|\s+|(?<=\|)\s+|\s+(?=\|)/', '', $row); |
|
| 176 | 176 | |
| 177 | 177 | if ($row === '') { |
| 178 | 178 | continue; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $rowArr = explode('|', trim($row, '|')); |
| 182 | - $rawArr[] = $rowArr; |
|
| 182 | + $rawArr[ ] = $rowArr; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return $rawArr; |
@@ -227,16 +227,16 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @return bool |
| 229 | 229 | */ |
| 230 | - public function send(string $content, string $subject = '', int $type = 1, array $data = [], ?string $recipient = null, ...$params) |
|
| 230 | + public function send(string $content, string $subject = '', int $type = 1, array $data = [ ], ?string $recipient = null, ...$params) |
|
| 231 | 231 | { |
| 232 | 232 | $this->check($content, $data); |
| 233 | 233 | |
| 234 | 234 | if ($type === 1 || $type === 4) { |
| 235 | 235 | // Do nothing |
| 236 | 236 | } else if ($type === 2) { |
| 237 | - $content = $this->genDomainRenewalResultsMarkDownText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']); |
|
| 237 | + $content = $this->genDomainRenewalResultsMarkDownText($data[ 'username' ], $data[ 'renewalSuccessArr' ], $data[ 'renewalFailuresArr' ], $data[ 'domainStatusArr' ]); |
|
| 238 | 238 | } else if ($type === 3) { |
| 239 | - $content = $this->genDomainStatusFullMarkDownText($data['username'], $data['domainStatusArr']); |
|
| 239 | + $content = $this->genDomainStatusFullMarkDownText($data[ 'username' ], $data[ 'domainStatusArr' ]); |
|
| 240 | 240 | } else { |
| 241 | 241 | throw new \Exception(lang('error_msg.100003')); |
| 242 | 242 | } |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | $isMarkdown = true; |
| 245 | 245 | |
| 246 | 246 | // 使用可变参数控制 telegram 送信类型,一般不会用到 |
| 247 | - if ($params && isset($params[1]) && $params[0] === 'TG') { |
|
| 248 | - $isMarkdown = $params[1]; |
|
| 247 | + if ($params && isset($params[ 1 ]) && $params[ 0 ] === 'TG') { |
|
| 248 | + $isMarkdown = $params[ 1 ]; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | if ($subject !== '') { |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | // 转义非链接格式的 [] 以及 () |
| 260 | 260 | $content = preg_replace_callback_array( |
| 261 | 261 | [ |
| 262 | - '/(?<!\\\\)\[(?P<brackets>.*?)(?!\]\()(?<!\\\\)\]/' => function ($match) { |
|
| 263 | - return '\\[' . $match['brackets'] . '\\]'; |
|
| 262 | + '/(?<!\\\\)\[(?P<brackets>.*?)(?!\]\()(?<!\\\\)\]/' => function($match) { |
|
| 263 | + return '\\[' . $match[ 'brackets' ] . '\\]'; |
|
| 264 | 264 | }, |
| 265 | - '/(?<!\\\\)(?<!\])\((?P<parentheses>.*?)(?<!\\\\)\)/' => function ($match) { |
|
| 266 | - return '\\(' . $match['parentheses'] . '\\)'; |
|
| 265 | + '/(?<!\\\\)(?<!\])\((?P<parentheses>.*?)(?<!\\\\)\)/' => function($match) { |
|
| 266 | + return '\\(' . $match[ 'parentheses' ] . '\\)'; |
|
| 267 | 267 | } |
| 268 | 268 | ], |
| 269 | 269 | $content |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | ] |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - $resp = json_decode((string)$resp->getBody(), true); |
|
| 287 | + $resp = json_decode((string) $resp->getBody(), true); |
|
| 288 | 288 | |
| 289 | - return $resp['ok'] ?? false; |
|
| 289 | + return $resp[ 'ok' ] ?? false; |
|
| 290 | 290 | } catch (\Exception $e) { |
| 291 | 291 | system_log('Telegram 消息发送失败:<red>' . $e->getMessage() . '</red>'); |
| 292 | 292 | |
@@ -221,16 +221,16 @@ discard block |
||
| 221 | 221 | * @return bool|mixed |
| 222 | 222 | * @throws \Exception |
| 223 | 223 | */ |
| 224 | - public function send(string $content, string $subject = '', int $type = 1, array $data = [], ?string $recipient = null, ...$params) |
|
| 224 | + public function send(string $content, string $subject = '', int $type = 1, array $data = [ ], ?string $recipient = null, ...$params) |
|
| 225 | 225 | { |
| 226 | 226 | $this->check($content, $data); |
| 227 | 227 | |
| 228 | 228 | if ($type === 1 || $type === 4) { |
| 229 | 229 | // Do nothing |
| 230 | 230 | } else if ($type === 2) { |
| 231 | - $content = $this->genDomainRenewalResultsText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']); |
|
| 231 | + $content = $this->genDomainRenewalResultsText($data[ 'username' ], $data[ 'renewalSuccessArr' ], $data[ 'renewalFailuresArr' ], $data[ 'domainStatusArr' ]); |
|
| 232 | 232 | } else if ($type === 3) { |
| 233 | - $content = $this->genDomainStatusFullText($data['username'], $data['domainStatusArr']); |
|
| 233 | + $content = $this->genDomainStatusFullText($data[ 'username' ], $data[ 'domainStatusArr' ]); |
|
| 234 | 234 | } else { |
| 235 | 235 | throw new \Exception(lang('error_msg.100003')); |
| 236 | 236 | } |
@@ -238,26 +238,26 @@ discard block |
||
| 238 | 238 | $query = [ |
| 239 | 239 | 'level' => $this->level, |
| 240 | 240 | 'automaticallyCopy' => $this->automaticallyCopy, // 携带参数 automaticallyCopy=1, 收到推送时,推送内容会自动复制到粘贴板(如发现不能自动复制,可尝试重启一下手机) |
| 241 | - 'copy' => isset($data['html_url']) ? $data['html_url'] : $this->copy, // 携带 copy 参数,则上面的复制操作,将只复制 copy 参数的值 |
|
| 241 | + 'copy' => isset($data[ 'html_url' ]) ? $data[ 'html_url' ] : $this->copy, // 携带 copy 参数,则上面的复制操作,将只复制 copy 参数的值 |
|
| 242 | 242 | ]; |
| 243 | 243 | |
| 244 | 244 | if ($this->isArchive !== null) { |
| 245 | - $query['isArchive'] = $this->isArchive; |
|
| 245 | + $query[ 'isArchive' ] = $this->isArchive; |
|
| 246 | 246 | } |
| 247 | 247 | if ($this->group !== null) { |
| 248 | - $query['group'] = $this->group; |
|
| 248 | + $query[ 'group' ] = $this->group; |
|
| 249 | 249 | } |
| 250 | 250 | if ($this->icon !== null) { |
| 251 | - $query['icon'] = $this->icon; |
|
| 251 | + $query[ 'icon' ] = $this->icon; |
|
| 252 | 252 | } |
| 253 | 253 | if ($this->jumpUrl !== null) { |
| 254 | - $query['url'] = $this->jumpUrl; |
|
| 254 | + $query[ 'url' ] = $this->jumpUrl; |
|
| 255 | 255 | } |
| 256 | 256 | if ($this->sound !== null) { |
| 257 | - $query['sound'] = $this->sound; |
|
| 257 | + $query[ 'sound' ] = $this->sound; |
|
| 258 | 258 | } |
| 259 | - if (isset($data['badge'])) { // 设置角标 |
|
| 260 | - $query['badge'] = $data['badge']; |
|
| 259 | + if (isset($data[ 'badge' ])) { // 设置角标 |
|
| 260 | + $query[ 'badge' ] = $data[ 'badge' ]; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $formParams = [ |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | ]; |
| 266 | 266 | |
| 267 | 267 | if ($subject !== '') { |
| 268 | - $formParams['title'] = $subject; // 推送标题 比 body 字号粗一点 |
|
| 268 | + $formParams[ 'title' ] = $subject; // 推送标题 比 body 字号粗一点 |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | try { |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | $resp = json_decode($resp->getBody()->getContents(), true); |
| 281 | 281 | |
| 282 | - if (isset($resp['code']) && $resp['code'] === 200) { |
|
| 282 | + if (isset($resp[ 'code' ]) && $resp[ 'code' ] === 200) { |
|
| 283 | 283 | return true; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - throw new \Exception($resp['message'] ?? '未知原因'); |
|
| 286 | + throw new \Exception($resp[ 'message' ] ?? '未知原因'); |
|
| 287 | 287 | } catch (\Exception $e) { |
| 288 | 288 | system_log('Bark 送信失败:<red>' . $e->getMessage() . '</red>'); |
| 289 | 289 | |