Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Created March 7, 2016 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woodwardtw/a9e4fd0dd01b4e101419 to your computer and use it in GitHub Desktop.
Save woodwardtw/a9e4fd0dd01b4e101419 to your computer and use it in GitHub Desktop.
Slack integration to return the current blogs/users on rampages . . . could have done it directly but was playing with regex a bit
<?php
$user_agent = "WHATEVER/1.0 (http://bionicteaching.com; bionicteaching@gmail.com)";
$command = $_POST['command'];
//$domain = $_POST['text'];
$token = $_POST['token'];
if($token != 'YOURTOKENHERE'){
$msg = "The token for the slash command doesn't match. Check your script.";
die($msg);
echo $msg;
}
$raw = file_get_contents('http://rampages.us');
preg_match('/blogcount\"\>(([0-9]+),([0-9]+))/', $raw, $m);
preg_match('/usercount\"\>(([0-9]+),([0-9]+))/', $raw, $f);
$blogcount = $m[1];
$usercount = $f[1];
$responsearray = [$blogcount];
$responsearray = [$usercount];
$reply = "Rampages is now at *" . $blogcount . '* blogs and *' . $usercount . '* users. Is that not awesome? Go comment on some of their <http://rampages.us/activity/ | work>.';
echo $reply;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment