if (0 >= ($seconds = GWF_TimeConvert::humanToSeconds($seconds))) { return $plug->rply('err_seconds'); } if (GWF_Time::ONE_DAY * 8 < $seconds) { return $plug->rply('err_too_long'); } // Try to parse back duration from parsed seconds if (false === ($delay = GWF_TimeConvert::humanDurationISO(Dog::getLangISO(), $seconds))) { return $plug->rply('err_seconds'); } $user = Dog::getUser(); if (!isset($DOG_PLUG_ALERT_TIMERS[$user->getID()])) { $DOG_PLUG_ALERT_TIMERS[$user->getID()] = 0; } if ($DOG_PLUG_ALERT_TIMERS[$user->getID()] >= 3) { return $plug->rply('err_too_much'); } if (!function_exists('dog_plugin_alert_func4')) { function dog_plugin_alert_func4(array $args) { global $DOG_PLUG_ALERT_TIMERS; $scope = $args[0]; $scope instanceof Dog_Scope; Dog::setScope($scope); Dog::reply($args[1]); $DOG_PLUG_ALERT_TIMERS[$scope->getUser()->getID()]--; } } Dog_Timer::addTimer('dog_plugin_alert_func4', array(Dog::getScope(), $plug->argvMsgFrom(1)), $seconds, false); $DOG_PLUG_ALERT_TIMERS[$user->getID()]++; $plug->rply('msg_remember', array($delay));
/** * Queue something for async. * @param string $type * @param mixed $message - Input for typefunc * @param mixed $callback * @param array $args - callback args */ public function async($type, $message, $callback = null, array $args = array(), array $includes = array()) { if (!GWF_Callback::isCallback($callback, true, true)) { echo "Dog_WorkerThread::async() - Invalid Callback!\n"; } elseif (!in_array($type, self::$TYPES, true)) { echo "Dog_WorkerThread::async() - Unknown Type: {$type}\n"; } elseif (!is_array($args)) { echo "Dog_WorkerThread::async() - Args is not an array\n"; } elseif (!$this->forked) { # Fallback to synchronous return $this->sync($type, $message, $callback, $args, $includes); } else { return $this->queue($type, Dog::getScope(), $message, $callback, $args, $includes); } return false; }