Ejemplo n.º 1
0
 public function __construct($token, $bot_id)
 {
     parent::__construct($token, $bot_id);
     $this->registerCommand("broadcast", array($this, "broadcast"), "Broadcast a message");
     $this->registerCommand("config", array($this, "config"), "Shows or sets bot configuration");
     $this->registerCommand("checkpoint", array($this, "next_checkpoint"), "Show next checkpoint");
     $this->registerCommand("cycle", array($this, "next_cycle"), "Show next cycle");
     $this->registerCommand("lessons", array($this, "smurfling_lessons"), "Smurfling Lessons link");
     // button should only be registered if configured
     if (isset($this->config->button)) {
         $this->registerCommand("button", array($this, "smash_button"), "Button link");
     }
     // rules should only be registered if configured
     if (isset($this->config->rules)) {
         $this->registerCommand("rules", array($this, "rules"), "Show chat rules");
     }
     // alertme should only be registered if configured
     if (isset($this->config->alert)) {
         $this->registerCommand("alertme", array($this, "alertme"), "Send name change alerts via PM");
         $this->registerHandler(self::GROUP_CHANGED, function ($data) {
             if ($data['change'] == "name" && is_object($this->config->alert)) {
                 if (preg_match($this->config->alert->regex, $data['what'])) {
                     foreach ($this->config->alert->users as $user) {
                         $this->sendDirectMessage($user, $data['what']);
                     }
                     $this->sendMessage(sprintf("%d people have been alerted to the group name change.", sizeof($this->config->alert->users)));
                 }
             }
         });
     }
 }
Ejemplo n.º 2
0
 public function __construct($token, $bot_id)
 {
     parent::__construct($token, $bot_id);
     $this->registerHandler(EventBot::MEMBER_ADDED, array($this, "checkForAutoKick"));
     $this->registerHandler(EventBot::MEMBER_JOINED, array($this, "checkForAutoKick"));
     $this->registerHandler(EventBot::MEMBER_REJOINED, array($this, "checkForAutoKick"));
     if ($this->config->modAddOnly) {
         $this->registerHandler(EventBot::MEMBER_ADDED, array($this, "checkThatModeratorAddedMember"));
     }
     $this->registerCommand("config", array($this, "config"), "Shows or sets bot configuration");
     $this->registerCommand("checkpoint", array($this, "next_checkpoint"), "Show next checkpoint");
     $this->registerCommand("cycle", array($this, "next_cycle"), "Show next cycle");
     $this->registerCommand("lessons", array($this, "smurfling_lessons"), "Smurfling Lessons link");
     $this->registerCommand("mods", array($this, "mods"), "Chat mods");
     // button should only be registered if configured
     if (isset($this->config->button)) {
         $this->registerCommand("button", array($this, "smash_button"), "Button link");
     }
     if (isset($this->config->chores)) {
         $this->registerCommand("chores", array($this, "chores"), "Link to Chore wheel");
     }
     // rules should only be registered if configured
     if (isset($this->config->rules)) {
         $this->registerCommand("rules", array($this, "rules"), "Show chat rules");
     }
     // alertme should only be registered if configured
     if (isset($this->config->alert)) {
         $this->registerCommand("alertme", array($this, "alertme"), "Send name change alerts via PM");
         $this->registerHandler(self::GROUP_CHANGED, function ($data) {
             if ($data['change'] == "name" && is_object($this->config->alert)) {
                 if (preg_match($this->config->alert->regex, $data['what'])) {
                     foreach ($this->config->alert->users as $user) {
                         $this->sendDirectMessage($user, $data['what']);
                     }
                     $this->sendMessage(sprintf("%d people have been alerted to the group name change.", sizeof($this->config->alert->users)));
                 }
             }
         });
     }
 }