public function init() { Admin::registerGroup(self::CHATGROUP); $this->questionsCount = \Util::getLinesCount(self::QUIZ_DB_PATH); $this->quizDb = Factory::create(\Util::getLocalPath() . DS . 'quiz.json'); if (!isset($this->quizDb['scores'])) { $this->quizDb['scores'] = []; } $this->ev->on(CoreInterface::MESSAGE, [$this, 'processMessage']); $this->ev->on('tick', [$this, 'processRunningQuiz']); \Util::console('Quiz: Questions count: ' . $this->questionsCount); $this->ev->on('restart', function () { $running = \Util::store('quiz') ?: []; if (count($running)) { foreach ($running as $chatName => $run) { $msg = '(devil) Игра окончена, т.к. ведущий перезагружается.'; $msg .= $this->scoresMessage($chatName); $this->core->send($chatName, $msg); unset($running[$chatName]); \Util::store('quiz', $running); } } return true; }); }
public function init() { parent::init(); Admin::registerGroup(self::CHATGROUP); }
public function init($reactionMethod = 'processJoin') { $this->ev->on(CoreInterface::ADDED, [$this, $reactionMethod]); $this->ev->on(CoreInterface::KICKED, [$this, 'unJoin']); Admin::registerGroup(self::CHATGROUP); }
public function init() { Admin::registerGroup(self::CHATGROUP); $this->ev->on('tick', [$this, 'processJobs']); }