Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
luolongfei committed Nov 6, 2021
2 parents 1bd2bc8 + d6f716a commit 82ee188
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ BARK_URL='https://api.day.app'
BARK_IS_ARCHIVE=''
BARK_GROUP='FreeNom'
BARK_LEVEL='active'
BARK_ICON=''
BARK_ICON='https://q2.qlogo.cn/headimg_dl?dst_uin=593198779&spec=100'
BARK_JUMP_URL=''
BARK_SOUND='gotosleep'

# 是否启用 Bark 推送消息 1:启用 0:不启用 Whether to enable Bark push messaging 1: Enable 0: Do not enable
BARK_ENABLE=0
Expand Down
4 changes: 2 additions & 2 deletions app/Console/FreeNom.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class FreeNom extends Base
{
const VERSION = 'v0.4.2';
const VERSION = 'v0.4.3';

const TIMEOUT = 33;

Expand Down Expand Up @@ -409,7 +409,7 @@ public function handle()
{
$accounts = $this->getAccounts();

system_log(sprintf('共发现 <green>%d</green> 个账户,处理中', count($accounts)));
system_log(sprintf('共发现 <green>%d</green> 个 freenom 账户,处理中', count($accounts)));

foreach ($accounts as $account) {
try {
Expand Down
3 changes: 2 additions & 1 deletion app/Console/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ public function handle()
$result = Message::send(
$this->genMsgContent(),
sprintf('主人,FreeNom 续期工具有新的版本(v%s)可用,新版相关情况已给到你', $this->latestVer),
4
4,
$this->releaseInfo
);

if ($result) {
Expand Down
1 change: 1 addition & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'bark_level' => env('BARK_LEVEL'),
'bark_icon' => env('BARK_ICON') === '' ? null : env('BARK_ICON'),
'bark_jump_url' => env('BARK_JUMP_URL') === '' ? null : env('BARK_JUMP_URL'),
'bark_sound' => env('BARK_SOUND') === '' ? null : env('BARK_SOUND'),
'enable' => (int)env('BARK_ENABLE'), // 是否启用,默认不启用

'not_enabled_tips' => env('BARK_KEY') && env('BARK_URL'), // 提醒未启用
Expand Down
4 changes: 0 additions & 4 deletions libs/Connector/MessageGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ public function check(string $content, array $data)
if ($content === '' && empty($data)) {
throw new \Exception(lang('error_msg.100002'));
}

if ($content !== '' && $data) {
throw new \Exception(lang('error_msg.100004'));
}
}

/**
Expand Down
16 changes: 15 additions & 1 deletion libs/MessageServices/Bark.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Bark extends MessageGateway
protected $jumpUrl;

/**
* IOS14.5 之后长按或下拉推送即可触发自动复制,IOS14.5 之前无需任何操作即可自动复制
*
* @var integer 携带参数 automaticallyCopy=1, 收到推送时,推送内容会自动复制到粘贴板(如发现不能自动复制,可尝试重启一下手机)
*/
protected $automaticallyCopy = 1;
Expand All @@ -66,6 +68,11 @@ class Bark extends MessageGateway
*/
protected $copy = 'https://my.freenom.com/domains.php?a=renewals';

/**
* @var string 通知铃声
*/
protected $sound;

/**
* @var Client
*/
Expand All @@ -81,6 +88,7 @@ public function __construct()
$this->level = config('message.bark.bark_level');
$this->icon = config('message.bark.bark_icon');
$this->jumpUrl = config('message.bark.bark_jump_url');
$this->sound = config('message.bark.bark_sound');

$this->client = new Client([
'cookies' => false,
Expand Down Expand Up @@ -230,7 +238,7 @@ public function send(string $content, string $subject = '', int $type = 1, array
$query = [
'level' => $this->level,
'automaticallyCopy' => $this->automaticallyCopy, // 携带参数 automaticallyCopy=1, 收到推送时,推送内容会自动复制到粘贴板(如发现不能自动复制,可尝试重启一下手机)
'copy' => $this->copy, // 携带 copy 参数,则上面的复制操作,将只复制 copy 参数的值
'copy' => isset($data['html_url']) ? $data['html_url'] : $this->copy, // 携带 copy 参数,则上面的复制操作,将只复制 copy 参数的值
];

if ($this->isArchive !== null) {
Expand All @@ -245,6 +253,12 @@ public function send(string $content, string $subject = '', int $type = 1, array
if ($this->jumpUrl !== null) {
$query['url'] = $this->jumpUrl;
}
if ($this->sound !== null) {
$query['sound'] = $this->sound;
}
if (isset($data['badge'])) { // 设置角标
$query['badge'] = $data['badge'];
}

$formParams = [
'body' => $content, // 推送内容 换行请使用换行符 \n
Expand Down
1 change: 0 additions & 1 deletion resources/lang/zh.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@
'100001' => '未能取得名为 WHMCSZH5eHTGhfvzP 的 cookie 值,故本次登录无效,请检查你的账户或密码是否正确。',
'100002' => '不允许发送空内容邮件',
'100003' => '非法消息类型',
'100004' => '不允许传入的 $content 与 $data 参数同时非空',
],
];

0 comments on commit 82ee188

Please sign in to comment.