BiliHelper-personal/src/plugin/ManGa.php
2022-04-05 14:41:33 +08:00

96 lines
2.5 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| |
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* & l、
* (゚、 。
*  \、゙ ~ヽ *
*  じしf_, )
*
*/
namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
class ManGa
{
use TimeLock;
/**
* @use run
*/
public static function run()
{
if (self::getLock() > time() || !getEnable('manga')) {
return;
}
if (self::sign() && self::share()) {
self::setLock(self::timing(10));
return;
}
self::setLock(3600);
}
/**
* @use 漫画签到
* @return bool
*/
private static function sign(): bool
{
sleep(1);
$url = 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn';
$payload = [
'access_key' => getAccessToken(),
'ts' => time()
];
$raw = Curl::post('app', $url, Sign::common($payload));
$de_raw = json_decode($raw, true);
# {"code":0,"msg":"","data":{}}
# {"code":"invalid_argument","msg":"clockin clockin is duplicate","meta":{"argument":"clockin"}}
if (!$de_raw['code']) {
Log::notice('漫画签到: 成功');
} else {
Log::warning('漫画签到: 失败或者重复操作');
}
return true;
}
/**
* @use 漫画分享
* @return bool
*/
private static function share(): bool
{
sleep(1);
$payload = [];
$url = "https://manga.bilibili.com/twirp/activity.v1.Activity/ShareComic";
$raw = Curl::post('app', $url, Sign::common($payload));
$de_raw = json_decode($raw, true);
# {"code":0,"msg":"","data":{"point":5}}
# {"code":1,"msg":"","data":{"point":0}}
if (!$de_raw['code']) {
Log::notice('漫画分享: 成功');
} else {
Log::warning('漫画分享: 失败或者重复操作');
}
return true;
}
}