]> jfr.im git - irc/quakenet/newserv.git/commitdiff
commit uncommited code from march ;/
authorPaul <redacted>
Fri, 16 May 2008 17:20:38 +0000 (18:20 +0100)
committerPaul <redacted>
Fri, 16 May 2008 17:20:38 +0000 (18:20 +0100)
noperserv/Makefile.in
noperserv/noperserv_raw.c [new file with mode: 0644]

index 844e1c9643798357c02889cedf1e5476188dd2a4..ae6b7f6d7c27d231beb44928346292c44a5396e2 100644 (file)
@@ -4,10 +4,12 @@ CFLAGS+=$(INCDBAPI)
 LDFLAGS+=$(LIBDBAPI)
 
 .PHONY: all
-all: noperserv.so noperserv_commands.so noperserv_fakeuser.so
+all: noperserv.so noperserv_commands.so noperserv_raw.so noperserv_fakeuser.so
 
 noperserv.so: noperserv.o noperserv_db.o noperserv_hooks.o noperserv_policy.o
 
 noperserv_commands.so: noperserv_commands.o
 
+noperserv_raw.so: noperserv_raw.o
+
 noperserv_fakeuser.so: noperserv_fakeuser.o
diff --git a/noperserv/noperserv_raw.c b/noperserv/noperserv_raw.c
new file mode 100644 (file)
index 0000000..5ebdb6e
--- /dev/null
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <strings.h>
+#include <time.h>
+
+#include "../control/control.h"
+#include "../nick/nick.h"
+#include "../lib/irc_string.h"
+#include "../lib/strlfunc.h"
+#include "../localuser/localuserchannel.h"
+#include "../lib/version.h"
+#include "../core/modules.h"
+
+MODULE_VERSION("");
+
+int controlraw(void *sender, int cargc, char **cargv);
+
+void _init() {
+  registercontrolhelpcmd("raw", NO_OPER, 2, &controlraw, "Usage: raw <type> <text>\ntype is one of client,server,raw\nUSE THIS COMMAND WITH CAUTION, YOU WILL MOST LIKELY CORRUPT NEWSERV STATE.");
+}
+
+void _fini() {
+  deregistercontrolcmd("raw", controlraw);
+}
+
+int controlraw(void *sender, int cargc, char **cargv) {
+  nick *np=(nick *)sender;
+  if (cargc<2)
+    return CMD_USAGE;
+
+  controlreply(sender, "Sending Raw.. %s", cargv[1]);
+  if (strcmp(cargv[0], "server") == 0) {
+    irc_send("%s %s",mynumeric->content,cargv[1]);
+    controlwall(NO_DEVELOPER, NL_OPERATIONS, "%s/%s sent SERVER RAW for %s", np->nick, np->authname, cargv[1]); 
+  } else if (strcmp( cargv[0], "client") == 0) {
+    controlwall(NO_DEVELOPER, NL_OPERATIONS, "%s/%s sent CLIENT RAW for %s", np->nick, np->authname, cargv[1]);
+    irc_send("%s %s",longtonumeric(mynick->numeric,5),cargv[1]);
+  } else if (strcmp( cargv[0], "raw") == 0) {
+    controlwall(NO_DEVELOPER, NL_OPERATIONS, "%s/%s sent RAW for %s", np->nick, np->authname, cargv[1]);
+    irc_send("%s", cargv[1]);
+  } else {
+    controlreply(sender, "Invalid Mode - server or client");
+    return CMD_ERROR;
+  }
+
+  controlreply(sender, "RAW sent.");
+
+  return CMD_OK;
+}