Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #87 from kj415j45/patch-2.6
Browse files Browse the repository at this point in the history
Patch 2.6
  • Loading branch information
kj415j45 authored Jul 28, 2018
2 parents c1c54dd + 19de9a3 commit afbba71
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ php build.php
如果你需要试用 kjBot 的全部功能,请继续运行 `php composer.phar install`

仅作为框架使用时,在确保 module 与 middleWare 文件夹下没有你的文件后:`composer run-script framework-only`
然后重建 module 文件夹与 middleWare/Chain.php 文件。

### 入门

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"optimize-autoloader": true
},
"require-dev": {
"ext-json": "^1.6",
"intervention/image": "^2.4",
"knplabs/github-api": "^2.9",
"lcobucci/jwt": "^3.2",
Expand Down
6 changes: 4 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions framework-only.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
function delDir($directory){if(file_exists($directory)){if($dir_handle=@opendir($directory)){while($filename=readdir($dir_handle)){if($filename!='.'&&$filename!='..'){$subFile=$directory."/".$filename;if(is_dir($subFile)){delDir($subFile);}if(is_file($subFile)){unlink($subFile);}}}closedir($dir_handle);rmdir($directory);}}}
delDir('module');
delDir('middleWare');
mkdir('module');
mkdir('middleWare');
file_put_contents('middleWare/Chain.php', "<?php\n");
?>
Binary file added module/osu/avatar-guest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions module/osu/bind.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

global $Queue, $Event, $Command;
global $Queue, $Event, $Command, $osu_api_key;
use kjBot\SDK\CQCode;
loadModule('osu.tools');

$length = strpos($Event['message'], "\r");
if(false===$length)$length=strlen($Event['message']);
$username = substr($Event['message'], strpos($Event['message'], nextArg()), $length-strlen($Command[0]));

setOsuID($Event['user_id'], $username);
$userRealname = json_decode(get_user($osu_api_key, $username))[0]->username;

$Queue[]= sendBack(CQCode::At($Event['user_id']).' 成功绑定 '.$username);
setOsuID($Event['user_id'], $userRealname);

$Queue[]= sendBack(CQCode::At($Event['user_id']).' 成功绑定 '.$userRealname);

?>
9 changes: 8 additions & 1 deletion module/osu/me.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
$target = '<script id="json-user" type="application/json">';

$start = strpos($web, $target);
if($start === false)leave('指定的用户不存在');

$end = strpos(substr($web, $start), '</script>');

Expand All @@ -70,6 +71,11 @@
$flag = file_exists($here."flags/{$user->country->code}.png")?($here."flags/{$user->country->code}.png"):($here.'flags/__.png');
$stats_key = imageFont($yahei, 12, $white);
$statics = $user->statistics;
try{
$avatar = Image::make('https://a.ppy.sh/'.$user->id);
}catch(\Exception $e){
$avatar = Image::make($here.'avatar-guest.png');
}
$playtime = [
'hours' => sprintf('%d', $statics->play_time/3600),
'minutes' => sprintf('%d', ($statics->play_time%3600)/60),
Expand All @@ -95,8 +101,9 @@
$img = Image::make($user->cover_url);
$img->resize(1000, 350)
->insert(Image::canvas(1000, 350)->fill([0, 0, 0, 0.5])) //背景暗化50%
->insert(Image::make('https://a.ppy.sh/'.$user->id)->resize(110, 110), 'top-left', 40, 220) //插入头像
->insert($avatar->resize(110, 110), 'top-left', 40, 220) //插入头像
->text($user->username, 170, 256, imageFont($exo2_italic, 24, $white, 'left', 'top')) //插入用户名
->text($user->title, 170, 285, imageFont($exo2_italic, 15, $white, 'left', 'top')) //插入title
;
if($badge!=NULL)$img->insert(Image::make($badge->image_url), 'top-left', 40, 168); //插入狗牌
if($user->is_supporter){
Expand Down
2 changes: 1 addition & 1 deletion module/osu/tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function ACCof($m){

function getBG($map){
try{
$bg = Image::make('https://bloodcat.com/osu/i/'.$map)->resize(1280, 720);
$bg = Image::make('https://bloodcat.com/osu/i/'.$map)->fit(1280, 720);
}catch(\Exception $e){
return Image::make(__DIR__.'/bg.jpg')->resize(1280, 720); //Fallback 背景
}
Expand Down

0 comments on commit afbba71

Please sign in to comment.