コード例 #1
0
ファイル: Factoid.java プロジェクト: kenborge/grouphugs
 public Factoid(ModuleHandler moduleHandler) {
   // Load up all existing factoids from sql
   try {
     sqlHandler = SQLHandler.getSQLHandler();
     List<Object[]> rows =
         sqlHandler.select(
             "SELECT `type`, `trigger`, `reply`, `author`, `channel`  FROM "
                 + FACTOID_TABLE
                 + ";");
     for (Object[] row : rows) {
       boolean message = row[0].equals("message");
       factoids.add(
           new FactoidItem(
               message, (String) row[1], (String) row[2], (String) row[3], (String) row[4]));
     }
     moduleHandler.addTriggerListener(TRIGGER_MAIN, this);
     moduleHandler.addTriggerListener(TRIGGER_ADD, this);
     moduleHandler.addTriggerListener(TRIGGER_DEL, this);
     moduleHandler.addTriggerListener(TRIGGER_RANDOM, this);
     moduleHandler.addTriggerListener(TRIGGER_FOR, this);
     moduleHandler.addMessageListener(this);
     moduleHandler.registerHelp(
         TRIGGER_HELP,
         "Factoid: Make me say or do \"reply\" when someone says \"trigger\".\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER_ADD
             + " trigger <say> reply\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER_ADD
             + " trigger <do> something\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER_DEL
             + " trigger\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER_MAIN
             + " trigger      - show information about a factoid\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER_RANDOM
             + "        - trigger a random factoid\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER_FOR
             + " <expression> - show what factoid, if any, that is "
             + "triggered by that expression\n"
             + " - The string \"$sender\" will be replaced with the nick of the one triggering the factoid.\n"
             + " - A star (*) can be any string of characters.\n"
             + " - Regex can be used, but remember that * is replaced with .*");
     bot = Grouphug.getInstance();
   } catch (SQLUnavailableException ex) {
     System.err.println("Factoid startup: SQL is unavailable!");
   } catch (SQLException e) {
     System.err.println("Factoid startup: SQL Exception: " + e);
   }
 }
コード例 #2
0
ファイル: Tell.java プロジェクト: kvikshaug/grouphugs
 public Tell(ModuleHandler moduleHandler) {
   if (SQL.isAvailable()) {
     bot = Grouphug.getInstance();
     moduleHandler.addTriggerListener(TRIGGER, this);
     moduleHandler.addJoinListener(this);
     moduleHandler.addNickChangeListener(this);
     moduleHandler.addMessageListener(this);
     moduleHandler.registerHelp(
         TRIGGER_HELP,
         "Tell: Tell something to someone who's not here when they eventually join\n"
             + "  "
             + Grouphug.MAIN_TRIGGER
             + TRIGGER
             + "<nick> <message>\n");
   } else {
     System.err.println("Tell module disabled: SQL is unavailable.");
   }
 }