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 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from kj415j45/patch-2.6
Patch 2.6
- Loading branch information
Showing
26 changed files
with
576 additions
and
166 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
$msg=<<<EOT | ||
展示你的 osu! 个人资料 | ||
用法: | ||
!osu.me [...] | ||
!osu.profile [...] | ||
参数列表: | ||
-user "用 户 名" 查看别人的资料 | ||
|
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 @@ | |
$msg=<<<EOT | ||
搜索 | ||
用法: | ||
!search{.pixiv|.baidu|.google} | ||
!search.{pixiv|baidu|google} | ||
返回指定的搜索引擎链接 | ||
|
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
Binary file not shown.
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 |
---|---|---|
@@ -1,147 +1,2 @@ | ||
<?php | ||
|
||
global $Event, $Queue; | ||
loadModule('osu.tools'); | ||
use Intervention\Image\ImageManagerStatic as Image; | ||
|
||
Image::configure(array('driver' => 'imagick')); | ||
|
||
$withMeText = false; | ||
|
||
do{ | ||
$arg = nextArg(); | ||
switch($arg){ | ||
case '-withMe': | ||
$withMeText = true; | ||
break; | ||
case '-osu': | ||
case '-std': | ||
$mode = 'osu'; | ||
break; | ||
case '-taiko': | ||
$mode = 'taiko'; | ||
break; | ||
case '-ctb': | ||
case '-fruit': | ||
case '-fruits': | ||
$mode = 'fruits'; | ||
break; | ||
case '-mania': | ||
$mode = 'mania'; | ||
break; | ||
case '-user': | ||
$osuid = nextArg(); | ||
break; | ||
default: | ||
|
||
} | ||
}while($arg !== NULL); | ||
|
||
$osuid = $osuid??getOsuID($Event['user_id']); | ||
|
||
if($osuid == ''){ | ||
throw new \Exception('未绑定 osu!'); | ||
} | ||
|
||
$osuid = OsuUsernameEscape($osuid); | ||
|
||
$web = file_get_contents('https://osu.ppy.sh/users/'.$osuid.'/'.$mode); | ||
|
||
$target = '<script id="json-user" type="application/json">'; | ||
|
||
$start = strpos($web, $target); | ||
if($start === false)leave('指定的用户不存在'); | ||
|
||
$end = strpos(substr($web, $start), '</script>'); | ||
|
||
$userJson = substr($web, $start+strlen($target), $end-strlen($target)); | ||
|
||
$user = json_decode($userJson); | ||
|
||
//初始化绘图环境 | ||
$here = __DIR__.'/'; | ||
$exo2 = $here.'Exo2-Regular.ttf'; | ||
$exo2_italic = $here.'Exo2-Italic.ttf'; | ||
$exo2_bold = $here.'Exo2-Bold.ttf'; | ||
$yahei = $here.'Yahei.ttf'; | ||
$white = '#ffffff'; | ||
$mode = $mode??$user->playmode; | ||
$badges = $user->badges; | ||
$badge = $badges[rand(0, count($badges)-1)]; | ||
$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), | ||
'seconds' => sprintf('%d', $statics->play_time%60), | ||
]; | ||
$stat = [ | ||
'Ranked 谱面总分' => number_format($statics->ranked_score), | ||
'准确率' => sprintf('%.2f%%', $statics->hit_accuracy), | ||
'游戏次数' => number_format($statics->play_count), | ||
'总分' => number_format($statics->total_score), | ||
'总命中次数' => number_format($statics->total_hits), | ||
'最大连击' => number_format($statics->maximum_combo), | ||
'回放被观看次数' => number_format($statics->replays_watched_by_others), | ||
]; | ||
$grade = [ | ||
'XH' => $statics->grade_counts->ssh, | ||
'X' => $statics->grade_counts->ss, | ||
'SH' => $statics->grade_counts->sh, | ||
'S' => $statics->grade_counts->s, | ||
'A' => $statics->grade_counts->a, | ||
]; | ||
//开始绘图 | ||
$img = Image::make($user->cover_url); | ||
$img->resize(1000, 350) | ||
->insert(Image::canvas(1000, 350)->fill([0, 0, 0, 0.5])) //背景暗化50% | ||
->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){ | ||
$img->insert(Image::make($here.'heart.png')->resize(28, 28), 'top-left', 170, 223) //插入支持者标志 | ||
->insert(Image::make($here."modes/{$mode}.png")->resize(28, 28), 'top-left', 210, 223) //插入模式标志 | ||
; | ||
}else{ | ||
$img->insert(Image::make($here."modes/{$mode}.png")->resize(28, 28), 'top-left', 170, 223); //插入模式标志 | ||
} | ||
$img->insert(Image::make($flag)->resize(30, 20), 'top-left', 170, 310) //插入国旗 | ||
->insert(Image::canvas(280, 323)->fill([0, 0, 0, 0.3]), 'top-left', 670, 27) //绘制右侧暗化 | ||
->text('游戏时间', 690, 50, $stats_key) | ||
->text("{$playtime['hours']}小时 {$playtime['minutes']}分钟 {$playtime['seconds']}秒", 690, 72, imageFont($yahei, 18, '#ffcc22')) | ||
->insert(Image::make($here.'levelbadge.png')->resize(50, 50), 'top-left', 880, 30) | ||
->text($statics->level->current, 905, 45, imageFont($exo2_bold, 18, $white, 'center', 'middle')) | ||
; | ||
$yIndex = 120; | ||
foreach($stat as $key => $value){ | ||
$img->text($key, 690, $yIndex, $stats_key); | ||
$img->text($value, 930, $yIndex, imageFont($exo2_bold, 16, $white, 'right')); | ||
$yIndex+=20; | ||
} | ||
$img->text(sprintf('%.2f', $statics->pp), 690, 280, imageFont($exo2_bold, 40, $white)); | ||
$img->text('PP', 740, 300, imageFont($exo2_bold, 20, $white)); | ||
$img->text('#'.number_format($statics->rank->global), 930, 280, imageFont($exo2_bold, 20, $white, 'right')); | ||
$img->text($user->country->code.' '.'#'.number_format($statics->rank->country), 930, 300, imageFont($exo2_bold, 20, $white, 'right')); | ||
$xIndex = 675; | ||
foreach($grade as $key => $value){ | ||
$img->insert(Image::make($here."{$key}.png")->resize(50, 50), 'top-left', $xIndex, 300); | ||
$img->text($value, $xIndex+20, 350, imageFont($exo2_bold, 16, $white, 'center', 'buttom')); | ||
$xIndex+=55; | ||
} | ||
$img->save('../storage/cache/'.$Event['message_id']); | ||
|
||
$msg = sendImg(getCache($Event['message_id'])); | ||
if($withMeText)$msg.="\n".preg_replace('/\n+/', "\n", str_replace('<br />', "\n", htmlspecialchars_decode(strip_tags($user->page->html, '<br>')))); | ||
|
||
$Queue[]= sendBack($msg); | ||
|
||
|
||
?> | ||
loadModule('osu.profile'); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 @@ | ||
<?php | ||
|
||
loadModule('credit.tools'); | ||
loadModule('osu.tools'); | ||
loadModule('osu.mp.tools'); | ||
global $Queue, $User_id; | ||
|
||
$limit = nextArg()??5; | ||
$data = getData("osu/mp/{$User_id}"); | ||
if($data === false)leave('没有正在监听的mp'); | ||
sscanf(trim(getData("osu/mp/{$User_id}")), '%d %d', $matchID, $lastEventID); | ||
|
||
$latestEventID = json_decode(file_get_contents("https://osu.ppy.sh/community/matches/{$matchID}/history?limit=1"))->latest_event_id; | ||
|
||
$historyJson = file_get_contents("https://osu.ppy.sh/community/matches/{$matchID}/history?before={$latestEventID}&limit={$limit}"); | ||
$history = json_decode($historyJson); | ||
$events = $history->events; | ||
$users = getEventUsers($history->users); | ||
|
||
decCredit($User_id, count($events)); | ||
|
||
$count = 0; | ||
foreach($events as $event){ | ||
$Queue[]= sendBack(parseEvent($event, $users)); | ||
$count++; | ||
if($event->detail->type == 'other' && $event->game->end_time == NULL){addCredit($User_id, count($events)-$count+1);break;} | ||
setData("osu/mp/{$User_id}", "{$matchID} {$event->id}"); | ||
if($event->detail->type == 'match-disbanded'){ | ||
unlink("../storage/data/osu/mp/{$User_id}"); | ||
} | ||
} | ||
|
||
$Queue[]= sendBack('你的余额为 '.getCredit($User_id)); | ||
|
||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.