All pastes #415707 Raw Edit

CyaNox

public php v1 · immutable
#415707 ·published 2007-03-29 20:22 UTC
rendered paste body
<?phpclass plugCoffeeTest{  protected static $helpers = array();  protected static $counter = 0;    public static function load(){    eventhandler::addHandler('coffee', EVENT_TYPE_COMMAND, 'coffee');  }    public static function coffee(event $event){    $dh = $event->getDataHelper();    $dh->replyAction("grinds some beans");    $dh->replyAction("starts the coffee drip");    $dh->reply("This will be a little while.");    self::$helpers[self::$counter] = $dh;    eventhandler::addHandler('coffeeTimer', EVENT_TYPE_TIMER, 'coffee_callback'.self::$counter);    timer::create('coffee_callback'.self::$counter, rand(40, 110));    $event->delete();    unset($dh);  }    public static function coffeeTimer(event $event){    $counter = substr($event->getName(), 15);    $dh = self::$helpers[$counter];    unset(self::$helpers[$counter]);    if($dh->getCommandTrailing()){      $dh->replyAction("hands ".$dh->getCommandTrailing()." a cup of coffee");    }else{      $dh->replyAction("hands ".$dh->getFromNickString()." a cup of coffee");    }    $event->delete();    unset($dh);  }}?>