This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Patch 2.7 #149
Open
kj415j45
wants to merge
15
commits into
master
Choose a base branch
from
patch-2.7
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Patch 2.7 #149
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b2f93cb
:memo: Add illustComment
kj415j45 9b0081e
:bug: Better text
kj415j45 61b6b7b
:sparkles: Improve pixiv
kj415j45 fa572b1
:art: Avoid original image being eaten
kj415j45 3313695
:memo: Add about info
kj415j45 4051ae2
:memo: Update help
kj415j45 afce497
:bug: F*cking noob logic
kj415j45 6af13b0
:sparkles: Add vndb
kj415j45 1354faf
:sparkles: Add whatanime
kj415j45 8bf944d
Merge branch 'master' of github.com:kj415j45/kjBot into patch-2.7
kj415j45 e78b7bd
:lipstick: Apply upstream change
kj415j45 6a4c7e6
:twisted_rightwards_arrows: Apply upstream change
kj415j45 1336e50
:memo: Fix bugs in log
kj415j45 ae0e019
:fire: Clean test code
kj415j45 1a46e1e
:fire: Github Issues died
kj415j45 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
<?php | ||
global $Queue; | ||
$Queue[]= sendBack(getData('about.txt')); |
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,2 @@ | ||
<?php | ||
loadModule('about'); |
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 |
---|---|---|
@@ -1,16 +1,4 @@ | ||
<?php | ||
|
||
global $Queue; | ||
$msg=<<<EOT | ||
报告一个问题 | ||
用法: | ||
!issue | ||
{标题} | ||
[细节内容] | ||
|
||
该命令有24小时冷却时间 | ||
EOT; | ||
|
||
$Queue[]= sendBack($msg); | ||
loadModule('issue'); | ||
|
||
?> |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
leave(<<<EOT | ||
使用谷歌翻译 | ||
用法: | ||
!voice {源语言} {目标语言} | ||
!trans {源语言} {目标语言} | ||
{ | ||
文本 | ||
} | ||
|
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 |
---|---|---|
@@ -1,42 +1,12 @@ | ||
<?php | ||
|
||
global $Queue, $Text, $Event; | ||
use Http\Adapter\Guzzle6\Client as GuzzleClient; | ||
use Lcobucci\JWT\Builder; | ||
use Lcobucci\JWT\Signer\Key; | ||
use Lcobucci\JWT\Signer\Rsa\Sha256; | ||
|
||
$builder = new Github\HttpClient\Builder(new GuzzleClient()); | ||
|
||
$length = strpos($Text, "\r"); | ||
if(false===$length)$length=strlen($Text); | ||
$title = substr($Text, 0, $length); | ||
$body = substr($Text, $length+2); | ||
|
||
if($title == '')leave('请提供 issue 标题'); | ||
|
||
if(coolDown("issue/{$Event['user_id']}")<0)leave('冷却中'); | ||
coolDown("issue/{$Event['user_id']}", 60*60*24); | ||
|
||
$github = new Github\Client($builder, 'machine-man-preview'); | ||
$jwt = (new Builder) | ||
->setIssuer(config('Github_Integration_ID')) | ||
->setIssuedAt(time()) | ||
->setExpiration(time() + 60) | ||
->sign(new Sha256(), new Key(getData('kjBot-Github.pem'))) | ||
->getToken(); | ||
|
||
$github->authenticate($jwt, null, Github\Client::AUTH_JWT); | ||
$token = $github->api('apps')->createInstallationToken(config('Github_Installation_ID')); | ||
$github->authenticate($token['token'], null, Github\Client::AUTH_HTTP_TOKEN); | ||
|
||
$result = $github->api('issue')->create('kj415j45', 'kjBot', [ | ||
'title' => $title, | ||
'body' => '>创建者:'.$Event['user_id']."\n\n".$body, | ||
'assignees' => ['kj415j45'], | ||
]); | ||
|
||
$Queue[]= sendBack('Issue 创建成功!'.$result['html_url']); | ||
$Queue[]= sendMaster($Event['user_id'].' 创建了新 issue '.$result['html_url']."\n".var_export($Event, true)); | ||
global $Queue; | ||
|
||
$Queue[]= sendBack(<<<EOT | ||
请前往 https://support.qq.com/products/47576 进行反馈。 | ||
最快回复时间为一天,最慢不会超过一周。 | ||
如果您的问题长时间无答复,请联系 [email protected] | ||
EOT | ||
); | ||
|
||
?> |
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,2 @@ | ||
<?php | ||
loadModule('whatanime'); |
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,12 @@ | ||
<?php | ||
|
||
global $Queue; | ||
$query=''; | ||
$mode = nextArg(); | ||
do{ | ||
$arg = nextArg(); | ||
$query.=urlencode($arg).'+'; | ||
}while($arg!==NULL); | ||
$Queue[]= sendBack('https://vndb.org/'.$mode.'/all?q='.rtrim($query, '+')); | ||
|
||
?> |
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,43 @@ | ||
<?php | ||
|
||
loadModule('credit.tools'); | ||
global $Text, $Queue, $User_id; | ||
|
||
$whatanimeBase = 'https://trace.moe/api'; | ||
$token = config('whatanime_token'); | ||
if(!preg_match('/url=(\S*)[,\]]/', $Text, $match))leave('解析图片失败'); | ||
$image = file_get_contents($match[1]); | ||
$b64Image = base64_encode($image); | ||
|
||
$opt = [ | ||
'http' => [ | ||
'method' => 'POST', | ||
'header' => <<<EOT | ||
Content-Type: application/json | ||
EOT | ||
, | ||
'content' => "{\"image\": \"${b64Image}\"}", | ||
] | ||
]; | ||
|
||
decCredit($User_id, 5); | ||
$resultJson = file_get_contents($whatanimeBase.'/search?token='.$token, false, stream_context_create($opt)); | ||
|
||
if(false === $resultJson){addCredit($User_id, 5);leave('过热中,请稍后重试');} | ||
$anime = json_decode($resultJson)->docs[0]; | ||
$minute = floor($anime->at/60); | ||
$second = $anime->at%60; | ||
$episode = is_numeric($anime->episode)?"第 {$anime->episode} 集":$anime->episode; | ||
$R18 = $anime->is_adult?"R18 警告\n\n":''; | ||
$similarity = sprintf('%.2f%%', $anime->similarity*100); | ||
|
||
$credit = getCredit($User_id); | ||
$msg = <<<EOT | ||
{$R18}你搜索的图片来自 {$anime->title_native}({$anime->title_chinese}){$episode} | ||
位于 {$minute}分{$second}秒 | ||
可信度 {$similarity}(低于85%表明搜索结果很可能不准确) | ||
|
||
你的余额为 {$credit} | ||
EOT; | ||
|
||
$Queue[]= sendBack($msg); |
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
$Queue[]= sendBack(CQCode::At($Event['user_id']).' 欢迎加入本群,请阅读群公告!'); | ||
}else{ | ||
$Queue[]= sendBack('kjBot 已入驻本群,发送 '.config('prefix', '!').'help 查看帮助'."\nkjBot 用户协议:https://github.com/kjBot-Dev/TOS/blob/master/README.md"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here, ref to the comment above :) |
||
$Queue[]= sendMaster('Join group '.$Event['group_id'].' by '.$Event['operator_id']); | ||
} | ||
break; | ||
case 'group_decrease': | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
机器人被拉进群之后也可以提示一下
使用 !about 了解什么是 kjBot 。