From f365bfd53da3f437b6eeb8ac78ae1125aca8a52c Mon Sep 17 00:00:00 2001 From: pk910 Date: Fri, 12 Aug 2011 22:38:57 +0200 Subject: [PATCH] modcmd added (with debug output only) --- ChanNode.h | 2 +- Makefile | 1 + main.c | 2 ++ modcmd.c | 29 +++++++++++++++++++++++++++++ modcmd.h | 7 +++++++ 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 modcmd.c create mode 100644 modcmd.h diff --git a/ChanNode.h b/ChanNode.h index dce8c38..dbb70c8 100644 --- a/ChanNode.h +++ b/ChanNode.h @@ -15,7 +15,7 @@ struct ChanNode { char **mode_str_args; int *mode_int_args; struct UserNode *chanbot; - + struct ChanNode *next; }; diff --git a/Makefile b/Makefile index 0ca52ba..8f1464f 100644 --- 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 9302ee9..1b0ba1c 100644 --- 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 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 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 -- 2.20.1