diff options
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | bee.c | 1 | ||||
-rw-r--r-- | chanlist.c | 18 | ||||
-rw-r--r-- | chanlist.h | 13 | ||||
-rw-r--r-- | conf.h | 2 | ||||
-rw-r--r-- | irc.c | 18 | ||||
-rw-r--r-- | irc.h | 6 |
7 files changed, 46 insertions, 19 deletions
@@ -5,7 +5,7 @@ CC=cc debug=-g -DDEBUG -DLOCAL CFLAGS=$(MORE_CFLAGS) -Wall -Wpedantic -OBJS=bee.o irc.o util.o unix.o +OBJS=bee.o irc.o util.o unix.o chanlist.o all: apiobot apiobot: $(OBJS) @@ -19,11 +19,12 @@ local: .c.o: $(CC) $(CFLAGS) -c $< -o $@ -bee.o: bee.c irc.h unix.h conf.h debug.h -irc.o: irc.c irc.h debug.h conf.h util.h +bee.o: bee.c irc.h unix.h conf.h debug.h chanlist.h +irc.o: irc.c irc.h debug.h conf.h util.h chanlist.h thing.o: thing.c conf.h unix.o: unix.c unix.h conf.h irc.h util.o: util.c util.h debug.h conf.h +chanlist.o: chanlist.c run: all @@ -1,4 +1,5 @@ #include "irc.h" +#include "chanlist.h" #include "unix.h" #include "conf.h" #include "debug.h" diff --git a/chanlist.c b/chanlist.c new file mode 100644 index 0000000..3ccd291 --- /dev/null +++ b/chanlist.c @@ -0,0 +1,18 @@ +#include "chanlist.h" + +#include <stddef.h> +char *g_chanlist[] = { + "a", + "b", + "g", + "the", +}; +const int g_nchannels = sizeof(g_chanlist)/sizeof(g_chanlist[0]); +char *g_chanpwlist[] = { + NULL, + NULL, + NULL, + "password", +}; + + diff --git a/chanlist.h b/chanlist.h new file mode 100644 index 0000000..95d428e --- /dev/null +++ b/chanlist.h @@ -0,0 +1,13 @@ +#ifndef chanlist_h_INCLUDED +#define chanlist_h_INCLUDED + +// list of channels to join +extern char *g_chanlist[]; +// length of the above +extern const int g_nchannels; +// list of passwords for channels, or NULL if no password +// parallel to g_chanlist +extern char *g_chanpwlist[]; + +#endif // chanlist_h_INCLUDED + @@ -15,7 +15,7 @@ #define HOST "ubq323.website" #define PORT "6667" // directory to put the unix sockets into - #define SOCKETDIR "/srv/apiobot" + #define SOCKETDIR "/srv/apiobot/ch" // group to assign as the owner of all the unix sockets #define SOCKETGROUP "apionet" #endif @@ -1,20 +1,12 @@ #include "irc.h" #include "debug.h" +#include "chanlist.h" #include "conf.h" #include "util.h" int g_ircsock = -1; -char *g_chanlist[] = { - "a", - "b", - "g", - "cg", - "secret-channel", -}; -const int g_nchannels = sizeof(g_chanlist)/sizeof(g_chanlist[0]); - int irc_connect() @@ -70,6 +62,14 @@ irc_handshake() } E(irc_sendall("JOIN #",6)); E(irc_sendall(g_chanlist[i],strlen(g_chanlist[i]))); + if (g_chanpwlist[i] != NULL) { + if (strlen(g_chanpwlist[i]) > 32) { + fprintf(stderr,"channel password too long for #(%s)\n",g_chanlist[i]); + return -1; + } + E(irc_sendall(" ",1)); + E(irc_sendall(g_chanpwlist[i],strlen(g_chanpwlist[i]))); + } E(irc_sendall("\r\n",2)); } #undef E @@ -13,12 +13,6 @@ // fd of the irc connection socket extern int g_ircsock; -// list of channels to join -extern char *g_chanlist[]; -// length of the above -extern const int g_nchannels; - - // connects to the irc server, as defined in config.h // returns -1 on failure. int irc_connect(); |