, "); return; } $host="api.github.com"; $port=443; if ($alias=="~rehash-issue") { $username="SoylentNews"; $repo="rehash"; } else { $username="crutchy-"; $repo="exec-irc-bot"; } $uri="/repos/$username/$repo/issues"; $tok=trim(file_get_contents("../pwd/gh_tok")); $headers=array(); $headers["Authorization"]="token $tok"; $headers["Content-Type"]="application/json"; $headers["Accept"]="application/vnd.github.v3+json"; $params=array(); $params["title"]=$title; $params["body"]=$body."\n\nsubmitted by exec on behalf of $nick from $dest @ irc.sylnt.us"; $json=json_encode($params,JSON_PRETTY_PRINT); $response=wpost($host,$uri,$port,ICEWEASEL_UA,$json,$headers,60,True,False); $content=strip_headers($response); $data=json_decode($content,True); if (isset($data["html_url"])==True) { privmsg($data["html_url"]); } else { privmsg("there was an error submitting the issue"); } return; } $list=exec_file_read("github_feed_repos"); sort($list,SORT_STRING); if ($alias=="~epoch-feed") { $list=array("Subsentient/epoch"); define("FEED_CHAN","#epoch"); } else { define("FEED_CHAN","#github"); } sort($list,SORT_STRING+SORT_FLAG_CASE); define("CREATE_TIME_FORMAT","Y-m-d H:i:s "); if ($alias=="~github-list") { $gh_users=array(); for ($i=0;$i $gh_repos) { sort($gh_repos,SORT_STRING+SORT_FLAG_CASE); privmsg(chr(3)."03".$gh_username." => ".implode(", ",$gh_repos)); } return; } for ($i=0;$i=0;$i--) { if (isset($data[$i]["created_at"])==False) { continue; } if ($data[$i]["type"]<>"PushEvent") { continue; } $timestamp=$data[$i]["created_at"]; $t=convert_timestamp($timestamp,CREATE_TIME_FORMAT); $dt=microtime(True)-$t; if ($dt>TIME_LIMIT_SEC) { continue; } github_msg($repo,chr(3)."13"."push to https://github.com/$repo @ ".date("H:i:s",$t)." by ".$data[$i]["actor"]["login"]); github_msg($repo," ".chr(3)."03".$data[$i]["payload"]["ref"]); for ($j=0;$j4) { $rem=$n1-$k; github_msg($repo," ".chr(3)."08"."└─".chr(3)."($rem files skipped)"); break; } $commit_filename=str_replace(" ","%20",$commit_data["files"][$k]["filename"]); $commit_status=$commit_data["files"][$k]["status"]; $tree_symbol="├─"; if ($k==($n1-1)) { $tree_symbol="└─"; } if ($commit_status=="removed") { github_msg($repo," ".chr(3)."08".$tree_symbol."removed:".chr(3)." /$repo/blob/$branch/$commit_filename"); } else { $commit_changes=""; if ((isset($commit_data["files"][$k]["additions"])==True) and (isset($commit_data["files"][$k]["deletions"])==True)) { $additions=$commit_data["files"][$k]["additions"]; $deletions=$commit_data["files"][$k]["deletions"]; $commit_changes=" [+$additions,-$deletions]"; } github_msg($repo," ".chr(3)."08".$tree_symbol.$commit_status.$commit_changes.":".chr(3)." https://github.com/$repo/blob/$branch/$commit_filename"); } } } } } } } ##################################################################################################### function check_pull_events($repo) { $data=get_api_data("/repos/$repo/pulls"); $n=count($data)-1; for ($i=$n;$i>=0;$i--) { if (isset($data[$i]["created_at"])==False) { continue; } $timestamp=$data[$i]["created_at"]; $t=convert_timestamp($timestamp,CREATE_TIME_FORMAT); $dt=microtime(True)-$t; if ($dt<=TIME_LIMIT_SEC) { github_msg($repo,chr(3)."13"."pull request by ".$data[$i]["user"]["login"]." @ ".date("H:i:s",$t)." - ".$data[$i]["_links"]["html"]["href"]); github_msg($repo,chr(3)."08"."└─".chr(3).$data[$i]["body"]); } } } ##################################################################################################### function check_issue_events($repo) { $data=get_api_data("/repos/$repo/issues/events"); $n=count($data)-1; for ($i=$n;$i>=0;$i--) { if (isset($data[$i]["created_at"])==False) { continue; } $timestamp=$data[$i]["created_at"]; $t=convert_timestamp($timestamp,CREATE_TIME_FORMAT); $dt=microtime(True)-$t; if ($dt<=TIME_LIMIT_SEC) { github_msg($repo,chr(3)."13"."issue ".$data[$i]["event"]." by ".$data[$i]["actor"]["login"]." @ ".date("H:i:s",$t)." - ".$data[$i]["issue"]["html_url"]); } } } ##################################################################################################### function get_api_data($uri) { $host="api.github.com"; $port=443; $tok=trim(file_get_contents("../pwd/gh_tok")); $headers=array(); $headers["Authorization"]="token $tok"; $headers["Accept"]="application/vnd.github.v3+json"; $response=wget($host,$uri,$port,ICEWEASEL_UA,$headers,60,"",1024,False,"*.github.com"); $content=strip_headers($response); return json_decode($content,True); } ##################################################################################################### function github_msg($repo,$msg) { pm(FEED_CHAN,$msg); } ##################################################################################################### ?>