twiki.c

dw_fluffos_v1/lib/cmds/creator/twiki.c · 1003 B

From the archive dw_fluffos_v1.tar.gz

Download the archive   « Back to the archive contents

inherit "/cmds/base";

#include <cmds/twiki.h>

#define DAY (24 * 60 * 60)

int cmd(int days) {
   string str;

   if (days <= 0) {
      add_failed_mess("The number of days must be higher than 0.\n");
      return 0;
   }
   if (days > 10) {
      add_failed_mess("You are limited to a maximum of ten days of "
        "twiki changes.  Consult the automated commonroom twiki post "
        "for further historical information.\n");
      return 0;
   }
   
   str = TWIKI_HANDLER->find_changes(time() - days * DAY);
   write(str);
   return 1;
} /* cmd() */

int cmd_file(string fname) {
   string str;

   str = TWIKI_HANDLER->query_file(fname);
   if (!str) {
      add_failed_mess("The twiki file " + fname + " does not exist.\n");
      return 0;
   }

   write("$P$" + fname + "$P$" + str);
   return 1;
} /* cmd() */

mixed *query_patterns() {
   return ({ "changes [since] <number'days'>", (: cmd($4[0]) :),
             "view <string'file'>", (: cmd_file($4[0]) :) });
} /* query_patterns() */

Site Stats

Snippets: 1791
Codebases: 571