示例#1
0
文件: handler.php 项目: Alambos/bot
 private function getHelp()
 {
     if (is_file(BOT_TOPDIR . self::BOT_HELP_FILE)) {
         return unserialize(file_get_contents(BOT_TOPDIR . self::BOT_HELP_FILE));
     }
     $st = $this->PDO->prepare('SELECT DISTINCT dir, init FROM functions ORDER BY dir ASC');
     $st->execute();
     $data = $st->fetchAll();
     $help = new BotMsg();
     foreach ($data as $element) {
         $dir = $element['dir'];
         if (!is_file(BOT_TOPDIR . $dir . '/init.php')) {
             continue;
         }
         $class = (include_once BOT_TOPDIR . $dir . '/init.php');
         if ($class === TRUE) {
             $class = $element['init'];
         }
         if (!$class || !class_exists($class, FALSE)) {
             continue;
         }
         $init = new $class();
         if (!$init instanceof BotModuleInit) {
             continue;
         }
         $row = $init->help();
         if (!$row instanceof BotMsg) {
             continue;
         }
         $help->append($row);
     }
     $help->append('Objaśnienie:<br />' . "\n" . '   <i>argument</i> jest wymagany<br />' . "\n" . '   <i>[argument]</i> jest opcjonalny');
     file_put_contents(BOT_TOPDIR . self::BOT_HELP_FILE, serialize($help));
     return $help;
 }
示例#2
0
 function testAppend()
 {
     $text = '';
     $substring = 'abc';
     $msg = new BotMsg($substring);
     $text .= $substring;
     $substring = 'cba';
     $msg->a($substring);
     $text .= $substring;
     $substring = 'cba';
     $msg->append($substring);
     $text .= $substring;
     $this->assertEquals($text, $msg->getRaw());
 }