From 5a6712593c7a5df6cdb20dd3430358bf2acdebab Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 9 Apr 2004 01:57:12 +0000 Subject: [PATCH] changes to !uset autoinvite behavior, introduction of allchanmsg_func hooks * changes to !uset autoinvite behavior: the autoinvite flag now works whether or not the channel it is set in is +i/+k. * introduction of allchanmsg_func hooks: there is now a set of hooks (available via reg_allchanmsg_func()) in place to catch all public channel messages the services server sees. git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-46 --- ChangeLog | 17 +++++++++++++++++ src/chanserv.c | 1 - src/chanserv.help | 2 +- src/proto-common.c | 28 ++++++++++++++++++++++++++++ src/proto.h | 2 ++ 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6fae87..6d1c85d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,23 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3 # +2004-04-09 01:57:12 GMT adam patch-46 + + Summary: + changes to !uset autoinvite behavior, introduction of allchanmsg_func hooks + Revision: + srvx--devo--1.3--patch-46 + + * changes to !uset autoinvite behavior: the autoinvite flag now works whether or not the channel it is set in is +i/+k. + + * introduction of allchanmsg_func hooks: there is now a set of hooks (available via reg_allchanmsg_func()) in place to catch all public channel messages the services server sees. + + + modified files: + ChangeLog src/chanserv.c src/chanserv.help src/proto-common.c + src/proto.h + + 2004-04-08 03:42:49 GMT Michael Poole patch-45 Summary: diff --git a/src/chanserv.c b/src/chanserv.c index 5b5f247..db3ac7f 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -5876,7 +5876,6 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) if(!IsUserSuspended(channel) && IsUserAutoInvite(channel) && (channel->access >= channel->channel->lvlOpts[lvlInviteMe]) - && (cn->modes & (MODE_KEY | MODE_INVITEONLY)) && !self->burst) irc_invite(chanserv, user, cn); continue; diff --git a/src/chanserv.help b/src/chanserv.help index 2703154..df5bc01 100644 --- a/src/chanserv.help +++ b/src/chanserv.help @@ -439,7 +439,7 @@ "$bOptions:$b", "INFO: Sets the infoline that $C sends when you join the channel.", "NOAUTOOP: Enable or disable $C automatically opping you upon joining or authenticating.", - "AUTOINVITE: $C will invite you to +i/+k channels which you have access to and are not in when you authenticate if this setting is on.", + "AUTOINVITE: $C will invite you to this channel if you have access to and are not in when you authenticate if this setting is on.", "NOTE: The NoAutoOp setting is equivalent to the !togop command in previous versions of srvx.", "$uSee Also:$u set"); "USET INFO" ("/msg $C USET <#channel> INFO ", diff --git a/src/proto-common.c b/src/proto-common.c index 6a042ed..2be1929 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -442,6 +442,11 @@ static struct chanmsg_func { struct userNode *service; } chanmsg_funcs[256]; /* indexed by trigger character */ +static struct allchanmsg_func { + chanmsg_func_t func; + struct userNode *service; +} allchanmsg_funcs[ALLCHANMSG_FUNCS_MAX]; + struct privmsg_desc { struct userNode *user; char *text; @@ -455,6 +460,7 @@ privmsg_chan_helper(struct chanNode *cn, void *data) struct privmsg_desc *pd = data; struct modeNode *mn; struct chanmsg_func *cf = &chanmsg_funcs[(unsigned char)pd->text[0]]; + int x; /* Don't complain if it can't find the modeNode because the channel might * be -n */ @@ -464,6 +470,15 @@ privmsg_chan_helper(struct chanNode *cn, void *data) /* Never send a NOTICE to a channel to one of the services */ if (!pd->is_notice && cf->func && GetUserMode(cn, cf->service)) cf->func(pd->user, cn, pd->text+1, cf->service); + + /* This catches *all* text sent to the channel that the services server sees */ + for (x = 0; x < ALLCHANMSG_FUNCS_MAX; x++) { + cf = (struct chanmsg_func *)&allchanmsg_funcs[x]; + if (!cf->func) + break; /* end of list */ + else + cf->func(pd->user, cn, pd->text, cf->service); + } } static void @@ -491,6 +506,19 @@ reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t chanmsg_funcs[prefix].service = service; } +void +reg_allchanmsg_func(struct userNode *service, chanmsg_func_t handler) +{ + int x; + for (x = 0; x < ALLCHANMSG_FUNCS_MAX; x++) { + if (allchanmsg_funcs[x].func) + continue; + allchanmsg_funcs[x].func = handler; + allchanmsg_funcs[x].service = service; + break; + } +} + struct userNode * get_chanmsg_bot(unsigned char prefix) { diff --git a/src/proto.h b/src/proto.h index 3ed37d5..3b1fb13 100644 --- a/src/proto.h +++ b/src/proto.h @@ -30,6 +30,7 @@ #define COMBO_NUMERIC_LEN 5 /* 1/2, 1/3 or 2/3 digits for server/client parts */ #define MAXLEN 512 /* Maximum IRC line length */ #define MAXNUMPARAMS 200 +#define ALLCHANMSG_FUNCS_MAX 4 /* +1 == 5 potential 'allchanmsg' funcs */ #ifdef HAVE_NETINET_IN_H #include @@ -95,6 +96,7 @@ int parse_line(char *line, int recursive); /* Callback notifications for protocol support. */ typedef void (*chanmsg_func_t) (struct userNode *user, struct chanNode *chan, char *text, struct userNode *bot); void reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t handler); +void reg_allchanmsg_func(struct userNode *service, chanmsg_func_t handler); struct userNode *get_chanmsg_bot(unsigned char prefix); typedef void (*privmsg_func_t) (struct userNode *user, struct userNode *target, char *text, int server_qualified); -- 2.20.1