From f5f5a04d2ba42db754bf61c53ec8792bd074e567 Mon Sep 17 00:00:00 2001 From: Denny Dai Date: Thu, 2 Jul 2015 14:15:47 +0800 Subject: [PATCH] add github plugin --- config.php | 7 +++++-- plugins/github.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 plugins/github.php diff --git a/config.php b/config.php index 2de63ce..bf33f7e 100644 --- a/config.php +++ b/config.php @@ -9,5 +9,8 @@ $TAGs = array('#','/','!'); //For Telegram-Bot -define('TB_TOKEN', '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11'); -define('TB_API_URL', 'https://api.telegram.org/bot'.TB_TOKEN.'/'); \ No newline at end of file +define('TB_TOKEN', 'YOU_TELEGRAM_BOT_TOKEN_HERE'); +define('TB_API_URL', 'https://api.telegram.org/bot'.TB_TOKEN.'/'); + +//For plugins +define('PLUGIN_GITHUB_TOKEN', 'YOU_GITHUB_TOKEN_HERE'); \ No newline at end of file diff --git a/plugins/github.php b/plugins/github.php new file mode 100644 index 0000000..8639b63 --- /dev/null +++ b/plugins/github.php @@ -0,0 +1,28 @@ + array ('header' => "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",)); +$user = file_get_contents("https://api.github.com/users/".urlencode($plugin_text).'?access_token='.PLUGIN_GITHUB_TOKEN, false, stream_context_create($opts)); +$starred = file_get_contents("https://api.github.com/users/".urlencode($plugin_text)."/starred".'?access_token='.PLUGIN_GITHUB_TOKEN, false, stream_context_create($opts)); +$user = json_decode($user,true); +$msg = "ID: @".$user['login']; +plugin_github_check("Type", $user['type']); +plugin_github_check("Name", $user['name']); +plugin_github_check("Email", $user['email']); +plugin_github_check("Company", $user['company']); +plugin_github_check("Starred", count(json_decode($starred,true))); +plugin_github_check("Repos", $user['public_repos']); +plugin_github_check("Followers", $user['followers']); +plugin_github_check("Following", $user['following']); +@$msg .= "\nUrl: https://github.com/".$user['login']; + +function plugin_github_check($title, $check) +{ + global $msg; + if (!empty($check)) { + return @$msg .= "\n".$title.": ".$check; + } +} + + +$BOT->msg($plugin_sendto, $msg); \ No newline at end of file