Ejemplo n.º 1
0
 function isTriggered()
 {
     if (!isset($this->data['text'])) {
         $this->printUsage();
         return;
     }
     if (!libValidate::md5Hash($this->data['text'])) {
         $this->reply('This is not an MD5 hash.');
         return;
     }
     $this->addJob('md5Lookup', $this->data['text']);
 }
Ejemplo n.º 2
0
 public final function setConfig($name, $value)
 {
     if (!isset($this->config[$name])) {
         return false;
     }
     if ($this->Channel === false) {
         $Target = $this->User;
     } else {
         $Target = $this->Channel;
     }
     $identifier = 'config_' . $this->id . '_' . $name;
     $def = $this->config[$name];
     if (!isset($def['type'])) {
         $def['type'] = 'string';
     }
     switch ($def['type']) {
         case 'enum':
             if (array_search($value, $def['options']) === false) {
                 return false;
             }
             $Target->saveVar($identifier, $value);
             break;
         case 'int':
             if (!libValidate::integer($value)) {
                 return false;
             }
             $Target->saveVar($identifier, (int) $value);
             break;
         case 'range':
             if (!libValidate::integer($value)) {
                 return false;
             }
             if ($value < $def['min'] || $value > $def['max']) {
                 return false;
             }
             $Target->saveVar($identifier, (int) $value);
             break;
         case 'unsigned_int':
             if (!libValidate::integer($value, true)) {
                 return false;
             }
             $Target->saveVar($identifier, (int) $value);
             break;
         case 'string':
             $Target->saveVar($identifier, $value);
             break;
         default:
             return false;
             // invalid type
     }
     return true;
 }