Explorar o código

* Added by and time in cmd_chaninfo for channels.

svn: 487
Bryan Drewery %!s(int64=22) %!d(string=hai) anos
pai
achega
62acf32861

+ 2 - 0
src/chan.h

@@ -169,6 +169,8 @@ struct chanset_t {
 /* Chanchar template
  *char temp[121];
  */
+  char added_by[NICKLEN];	/* who added the channel? */
+  time_t added_ts;		/* ..and when? */
   /* queued mode changes: */
   char pls[21];			/* positive mode changes		*/
   char mns[21];			/* negative mode changes		*/

+ 28 - 1
src/mod/channels.mod/cmdschan.c

@@ -1426,6 +1426,17 @@ static void cmd_pls_chan(struct userrec *u, int idx, char *par)
   if (tcl_channel_add(0, chname, par) == TCL_ERROR) /* drummer */
     dprintf(idx, "Invalid channel or channel options.\n");
   else {
+    if ((chan = findchan_by_dname(chname))) {
+      char *tmp = NULL;
+      tmp = nmalloc(7 + 1 + strlen(dcc[idx].nick) + 1);
+      sprintf(tmp, "addedby %s", dcc[idx].nick);
+      do_chanset(chan, tmp, 1);
+      nfree(tmp);
+      tmp = nmalloc(7 + 1 + 10 + 1);
+      sprintf(tmp, "addedts %lu", now);
+      do_chanset(chan, tmp, 1);
+      nfree(tmp);
+    }
 #ifdef HUB
     write_userfile(-1);
 #endif /* HUB */
@@ -1521,7 +1532,23 @@ static void cmd_chaninfo(struct userrec *u, int idx, char *par)
   if (!(chan = findchan_by_dname(chname)))
     dprintf(idx, "No such channel defined.\n");
   else {
-    dprintf(idx, "Settings for dynamic channel %s:\n", chan->dname);
+    char nick[NICKLEN], date[81];
+    if (chan->added_ts) {
+#ifndef S_UTCTIME
+      egg_strftime(date, sizeof date, "%c %Z", localtime(&(chan->added_ts)));
+#else /* !S_UTCTIME */
+      egg_strftime(date, sizeof date, "%c %Z", gmtime(&(chan->added_ts)));
+#endif /* S_UTCTIME */
+    } else
+      date[0] = 0;
+    if (chan->added_by && chan->added_by[0])
+      egg_snprintf(nick, sizeof nick, "%s", chan->added_by);
+    else
+      nick[0] = 0;
+    if (nick[0] && date[0])
+      dprintf(idx, "Settings for channel %s (Added %s by %s%s%s):\n", chan->dname, date, colorI(idx, BOLD_OPEN, 0), nick, colorI(idx, BOLD_CLOSE, 0));
+    else
+      dprintf(idx, "Settings for channel %s:\n", chan->dname);
     get_mode_protect(chan, work);
     dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None");
 /* Chanchar template

+ 19 - 1
src/mod/channels.mod/tclchan.c

@@ -183,7 +183,9 @@ static int tcl_channel_get(Tcl_Interp * irp, struct chanset_t *chan, char *setti
                             else simple_sprintf(s, "%d", 1); }
 
   if      (CHECK("chanmode"))      get_mode_protect(chan, s);
-
+  
+  else if (CHECK("addedby"))	   simple_sprintf(s, "%s", chan->added_by);
+  else if (CHECK("addedts"))       simple_sprintf(s, "%lu", chan->added_ts);
   else if (CHECK("idle-kick"))     simple_sprintf(s, "%d", chan->idle_kick);
   else if (CHECK("limit"))         simple_sprintf(s, "%d", chan->limitraise);
   else if (CHECK("stop-net-hack")) simple_sprintf(s, "%d", chan->stopnethack_mode);
@@ -346,6 +348,22 @@ Context;
       strncpy(s, item[i], 120);
       s[120] = 0;
       set_mode_protect(chan, s);
+    } else if (!strcmp(item[i], "addedby")) {
+      i++;
+      if (i >= items) {
+	if (irp)
+	  Tcl_AppendResult(irp, "addedby chanmode needs argument", NULL);
+	return TCL_ERROR;
+      }
+      strncpyz(chan->added_by, item[i], NICKLEN);
+    } else if (!strcmp(item[i], "addedts")) {
+      i++;
+      if (i >= items) {
+	if (irp)
+	  Tcl_AppendResult(irp, "addedby chanmode needs argument", NULL);
+	return TCL_ERROR;
+      }
+      chan->added_ts = atoi(item[i]);
     } else if (!strcmp(item[i], "idle-kick")) {
       i++;
       if (i >= items) {

+ 3 - 1
src/mod/channels.mod/userchan.c

@@ -1321,7 +1321,7 @@ static int write_chans(FILE *f, int idx)
    //insert the ending character into a string
      sprintf(sadd, "}\n");
 
-     if (lfprintf(f, "+ channel %s %s%schanmode %s idle-kick %d limit %d stopnethack-mode %d \
+     if (lfprintf(f, "+ channel %s %s%schanmode %s addedby %s addedts %lu idle-kick %d limit %d stopnethack-mode %d \
 revenge-mode %d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d \
@@ -1337,6 +1337,8 @@ ban-time %d exempt-time %d invite-time %d \
 	name,
 	" { ",
 	w2,
+        chan->added_by,
+        chan->added_ts,
 /* Chanchar template
  *      temp,
  * also include temp %s in dprintf.