-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
252 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: php | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
include: | ||
- php: '5.6' | ||
- php: '7.0' | ||
- php: '7.1' | ||
- php: '7.2' | ||
- php: 'nightly' | ||
|
||
allow_failures: | ||
- php: 'nightly' | ||
|
||
sudo: false | ||
|
||
script: | ||
- find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/*! | ||
* metowolf BilibiliHelper | ||
* https://i-meto.com/ | ||
* | ||
* Copyright 2018, metowolf | ||
* Released under the MIT license | ||
*/ | ||
|
||
namespace BilibiliHelper\Plugin; | ||
|
||
use BilibiliHelper\Lib\Log; | ||
use BilibiliHelper\Lib\Curl; | ||
|
||
class Capsule extends Base | ||
{ | ||
const PLUGIN_NAME = 'capsule'; | ||
|
||
protected static function init() | ||
{ | ||
if (!static::data('lock')) { | ||
static::data('lock', time()); | ||
} | ||
} | ||
|
||
protected static function work() | ||
{ | ||
if (static::data('lock') > time()) { | ||
return; | ||
} | ||
|
||
$count = static::info(); | ||
$step = 100; | ||
while ($count && $step) { | ||
while ($count >= $step) { | ||
$count = static::open($step); | ||
sleep(mt_rand(0, 5)); | ||
} | ||
$step = intval($step / 10); | ||
} | ||
|
||
static::data('lock', time() + 86400); | ||
} | ||
|
||
public static function info() | ||
{ | ||
$payload = []; | ||
$data = Curl::post('https://api.live.bilibili.com/AppUser/capsuleInfo', static::sign($payload)); | ||
$data = json_decode($data, true); | ||
|
||
if (isset($data['code']) && $data['code']) { | ||
Log::warning("扭蛋币余额查询异常"); | ||
return 0; | ||
} | ||
Log::info("当前还有 {$data['data']['normal']['coin']} 枚扭蛋币"); | ||
|
||
return $data['data']['normal']['coin']; | ||
} | ||
|
||
public static function open($num) | ||
{ | ||
$payload = [ | ||
'count' => $num, | ||
'type' => 'normal', | ||
]; | ||
$data = Curl::get('https://api.live.bilibili.com/AppUser/capsuleInfoOpen', static::sign($payload)); | ||
$data = json_decode($data, true); | ||
|
||
if (isset($data['code']) && $data['code']) { | ||
Log::warning("扭蛋失败,稍后重试"); | ||
return 0; | ||
} | ||
|
||
if (isset($data['data']['text'])) { | ||
foreach ($data['data']['text'] as $vo) { | ||
Log::notice("扭蛋成功,获得 {$vo['num']} 个{$vo['name']}"); | ||
} | ||
} | ||
|
||
return isset($data['data']['coin']) ? $data['data']['coin'] : 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/*! | ||
* metowolf BilibiliHelper | ||
* https://i-meto.com/ | ||
* | ||
* Copyright 2018, metowolf | ||
* Released under the MIT license | ||
*/ | ||
|
||
namespace BilibiliHelper\Plugin; | ||
|
||
use BilibiliHelper\Lib\Log; | ||
use BilibiliHelper\Lib\Curl; | ||
|
||
class Group extends Base | ||
{ | ||
const PLUGIN_NAME = 'group'; | ||
|
||
protected static function init() | ||
{ | ||
if (!static::data('lock')) { | ||
static::data('lock', time()); | ||
} | ||
} | ||
|
||
protected static function work() | ||
{ | ||
if (static::data('lock') > time()) { | ||
return; | ||
} | ||
|
||
$groups = static::list(); | ||
$count = count($groups); | ||
foreach ($groups as $group) { | ||
$count -= static::signIn($group); | ||
} | ||
|
||
if ($count == 0) { | ||
static::data('lock', strtotime(date('Y-m-d 23:59:59')) + 600); | ||
} else { | ||
static::data('lock', time() + 3600); | ||
} | ||
} | ||
|
||
public static function list() | ||
{ | ||
$payload = []; | ||
$data = Curl::post('https://api.vc.bilibili.com/link_group/v1/member/my_groups', static::sign($payload)); | ||
$data = json_decode($data, true); | ||
|
||
if (isset($data['code']) && $data['code']) { | ||
Log::warning("查询应援团名单异常"); | ||
return []; | ||
} | ||
|
||
if (empty($data['data']['list'])) { | ||
Log::notice('没有需要签到的应援团'); | ||
return []; | ||
} | ||
|
||
return $data['data']['list']; | ||
} | ||
|
||
public static function signIn($value) | ||
{ | ||
$payload = [ | ||
'group_id' => $value['group_id'], | ||
'owner_id' => $value['owner_uid'], | ||
]; | ||
$data = Curl::post('https://api.vc.bilibili.com/link_setting/v1/link_setting/sign_in', static::sign($payload)); | ||
$data = json_decode($data, true); | ||
|
||
if (isset($data['code']) && $data['code']) { | ||
Log::warning("应援团 {$value['group_name']} 签到异常"); | ||
return false; | ||
} | ||
|
||
if ($data['data']['status']) { | ||
Log::notice("应援团 {$value['group_name']} 已经签到过了"); | ||
} else { | ||
Log::notice("应援团 {$value['group_name']} 签到成功,增加 {$de_raw['data']['add_num']} 点亲密度"); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters