modcmd added (with debug output only)
authorpk910 <philipp@zoelle1.de>
Fri, 12 Aug 2011 20:38:57 +0000 (22:38 +0200)
committerpk910 <philipp@zoelle1.de>
Fri, 12 Aug 2011 20:38:57 +0000 (22:38 +0200)
ChanNode.h
Makefile
main.c
modcmd.c [new file with mode: 0644]
modcmd.h [new file with mode: 0644]

index dce8c384171c22e025026e33aa10db77232f8a31..dbb70c8bdbe5a13e8f6324207f0d39543c93a315 100644 (file)
@@ -15,7 +15,7 @@ struct ChanNode {
     char **mode_str_args;
     int *mode_int_args;
     struct UserNode *chanbot;
-
+       
     struct ChanNode *next;
 };
 
index 0ca52ba02d91487ffe4f3cfaf96c15672c921ccb..8f1464f761ec5f1394b8df650f7f47a2eae49719 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ all:
        gcc -g -O2 -I. -c UserNode.c -o UserNode.o ${CFLAGS}
        gcc -g -O2 -I. -c ChanUser.c -o ChanUser.o ${CFLAGS}
        gcc -g -O2 -I. -c WHOHandler.c -o WHOHandler.o ${CFLAGS}
+       gcc -g -O2 -I. -c modcmd.c -o modcmd.o ${CFLAGS}
 
 install:
        gcc -g -O0 -I. -o neonserv *.o ${CFLAGS}
diff --git a/main.c b/main.c
index 9302ee90895c1c40bb572b173ac7246bd4b086ee..1b0ba1c42a92e0c34f380e65e1f4aba0ba2b1db6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,6 +5,7 @@
 #include "ChanNode.h"
 #include "IRCEvents.h"
 #include "IRCParser.h"
+#include "modcmd.h"
 
 void just_test_it() {
     struct UserNode *user;
@@ -31,6 +32,7 @@ int main(void)
     init_UserNode();
     init_ChanNode();
     init_bind();
+       init_modcmd();
     just_test_it();
     
     time_t socket_wait;
diff --git a/modcmd.c b/modcmd.c
new file mode 100644 (file)
index 0000000..412682d
--- /dev/null
+++ b/modcmd.c
@@ -0,0 +1,29 @@
+
+#include "modcmd.h"
+#include "IRCEvents.h"
+
+static void got_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) {
+       struct ClientSocket *client = getBots(SOCKET_FLAG_READY, NULL);
+    if(!strcmp(message, "users")) {
+        struct ChanUser *chanuser;
+        putsock(client, "PRIVMSG %s :[BOT JOIN] Users on this Channel:", chan->name);
+        for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
+            putsock(client, "PRIVMSG %s :  %s!%s@%s [%s]  rights: %d", chan->name, chanuser->user->nick, chanuser->user->ident, chanuser->user->host, ((chanuser->user->flags & USERFLAG_ISAUTHED) ? chanuser->user->auth : "*"), chanuser->flags);
+        }
+    }
+    if(!strcmp(message, "modes")) {
+        char modeBuf[MAXLEN];
+        getModeString(chan, modeBuf);
+        putsock(client, "PRIVMSG %s :Modes: %s", chan->name, modeBuf);
+    }
+}
+
+static void got_privmsg(struct UserNode *user, struct UserNode *target, char *message) {
+       
+}
+
+void init_modcmd() {
+       bind_chanmsg(got_chanmsg);
+       bind_privmsg(got_privmsg);
+}
+
diff --git a/modcmd.h b/modcmd.h
new file mode 100644 (file)
index 0000000..8195145
--- /dev/null
+++ b/modcmd.h
@@ -0,0 +1,7 @@
+#ifndef _modcmd_h
+#define _modcmd_h
+#include "main.h"
+
+void init_modcmd();
+
+#endif
\ No newline at end of file