Example #1
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require "functions.php";
require "exchange.php";
$excDataArray = "";
// contains high, low, bid, ask, volume, currency, exchange (no last price - thanks Bitstamp!
setSlackToken("put your slack token here");
setSlackMessage($_POST);
setExchangeConfig();
// commands: troll, price
// parameters: btx, polo
$findspace = ' ';
$cmd = substr(getSlackMessageText(), 0, 5);
// the command is 5 characters long and always at the beginning of the line.
$cmd = strtolower($cmd);
if ($cmd == 'price') {
    $botname = "RBY Price Bot";
    $pos = strpos(getSlackMessageText(), $findspace);
    $exc = trim(substr(getSlackMessageText(), $pos));
    $exc = strtolower($exc);
    if ($exc == 'gox' || $exc == 'mtgox') {
        $botname = "MtGox Price Bot";
        $text = "Seriously? You're seriously going to try and check the price on an exchange that went bankrupt? How do I even quote that... ? Try 'troll' instead";
        // technically, last price at gox was 135.69
        $arr = array('text' => $text, 'username' => $botname);
        // clearly the user is trolling us, so we end the script
        echo json_encode($arr);
        exit(0);
    } else {
Example #2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require "functions.php";
require "exchange.php";
$excDataArray = "";
// contains high, low, bid, ask, volume, currency, exchange (no last price - thanks Bitstamp!
setSlackToken("");
setSlackMessage($_POST);
setExchangeConfig();
date_default_timezone_set('UTC');
// commands: !troll, !price, convert
// parameters: bfx, bs, btce
$findspace = ' ';
$cmd = substr(getSlackMessageText(), 0, 6);
// the command is 5 characters long and always at the beginning of the line.
$everythingElse = substr(getSlackMessageText(), 8);
$cmd = strtolower($cmd);
if ($cmd == '!price') {
    $botname = "BTC Price Bot";
    $pos = strpos(getSlackMessageText(), $findspace);
    $exc = trim(substr(getSlackMessageText(), $pos));
    $exc = strtolower($exc);
    if ($exc == 'gox' || $exc == 'mtgox') {
        $botname = "MtGox Price Bot";
        $text = "Seriously? You're seriously going to try and check the price on an exchange that went bankrupt? How do I even quote that... ? Try 'troll' instead";
        // technically, last price at gox was 135.69
        $arr = array('text' => $text, 'username' => $botname);
        // clearly the user is trolling us, so we end the script
        echo json_encode($arr);