Skip to content

Commit

Permalink
Handle IRCv3 invite-notify, add invite bind
Browse files Browse the repository at this point in the history
Add invite bind. Fix invite handling to handle IRCv3 invite-notify, where an INVITE you see may not actually be for you. Proc takes 4 args- nick, uhost, channel, invitee
  • Loading branch information
vanosg committed Dec 30, 2019
1 parent 0113cf2 commit 14dcd6d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
8 changes: 8 additions & 0 deletions doc/sphinx_source/mainDocs/tcl-commands.rst
Expand Up @@ -3295,6 +3295,14 @@ The following is a list of bind types and how they work. Below each bind type is


Module: core Module: core


(51) INVT (stackable)

bind invt <flags> <mask> <proc>

procname <nick> <user@host> <channel> <invitee>

Description: triggered when eggdrop received an INVITE message. The mask for the bind is in the format "#channel nickname", where nickname (not a hostmask) is that of the invitee. For the proc, nick is the nickname of the person sending the invite request, user@host is the user@host of the person sending the invite, channel is the channel the invitee is being invited to, and invitee is the target (nickname only) of the invite. The invitee argument was added to support the IRCv3 invite-notify capability, where the eggdrop may be able to see invite messages for other people that are not the eggdrop.

^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Return Values Return Values
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Expand Down
15 changes: 12 additions & 3 deletions src/mod/irc.mod/chan.c
Expand Up @@ -1507,16 +1507,25 @@ static int got475(char *from, char *msg)
return 0; return 0;
} }


/* got invitation /* got invitation. Updated 2019 to handle IRCv3 invite-notify capability
* where invites seen may not be for you, so we have to check the target and
* and ignore if it is not for us.
*/ */
static int gotinvite(char *from, char *msg) static int gotinvite(char *from, char *msg)
{ {
char *nick, *key; char *nick, *key, *invitee;
struct chanset_t *chan; struct chanset_t *chan;


newsplit(&msg); invitee = newsplit(&msg);
fixcolon(msg); fixcolon(msg);
nick = splitnick(&from); nick = splitnick(&from);
check_tcl_invite(nick, from, msg, invitee);
/* Because who needs RFCs? Freakin IRCv3... */
if (!match_my_nick(invitee)) {
putlog(LOG_DEBUG, "*", "Received invite notifiation for %s to %s by %s.",
invitee, msg, nick);
return 1;
}
if (!rfc_casecmp(last_invchan, msg)) if (!rfc_casecmp(last_invchan, msg))
if (now - last_invtime < 30) if (now - last_invtime < 30)
return 0; /* Two invites to the same channel in 30 seconds? */ return 0; /* Two invites to the same channel in 30 seconds? */
Expand Down
32 changes: 30 additions & 2 deletions src/mod/irc.mod/irc.c
Expand Up @@ -32,7 +32,7 @@
#include <sys/utsname.h> #include <sys/utsname.h>


static p_tcl_bind_list H_topc, H_splt, H_sign, H_rejn, H_part, H_pub, H_pubm; static p_tcl_bind_list H_topc, H_splt, H_sign, H_rejn, H_part, H_pub, H_pubm;
static p_tcl_bind_list H_nick, H_mode, H_kick, H_join, H_need; static p_tcl_bind_list H_nick, H_mode, H_kick, H_join, H_need, H_invt;


static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL; static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL;


Expand Down Expand Up @@ -744,6 +744,18 @@ static int channels_2char STDVAR
return TCL_OK; return TCL_OK;
} }


static int invite_4char STDVAR
{
Function F = (Function) cd;

BADARGS(5, 5, " nick uhost channel invitee");

CHECKVALIDITY(invite_4char);
F(argv[1], argv[2], argv[3], argv[4]);
return TCL_OK;
}


static void check_tcl_joinspltrejn(char *nick, char *uhost, struct userrec *u, static void check_tcl_joinspltrejn(char *nick, char *uhost, struct userrec *u,
char *chname, p_tcl_bind_list table) char *chname, p_tcl_bind_list table)
{ {
Expand Down Expand Up @@ -838,6 +850,19 @@ static void check_tcl_kick(char *nick, char *uhost, struct userrec *u,
MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE); MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
} }


static void check_tcl_invite(char *nick, char *from, char *chan, char *invitee)
{
char args[512];

Tcl_SetVar(interp, "_invite1", nick, 0);
Tcl_SetVar(interp, "_invite2", from, 0);
Tcl_SetVar(interp, "_invite3", chan, 0);
Tcl_SetVar(interp, "_invite4", invitee, 0);
simple_sprintf(args, "%s %s", chan, invitee);
check_tcl_bind(H_invt, args, 0, " $_invite1 $_invite2 $_invite3 $_invite4",
MATCH_MASK | BIND_STACKABLE);
}

static int check_tcl_pub(char *nick, char *from, char *chname, char *msg) static int check_tcl_pub(char *nick, char *from, char *chname, char *msg)
{ {
struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 }; struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
Expand Down Expand Up @@ -1148,6 +1173,7 @@ static char *irc_close()
del_bind_table(H_nick); del_bind_table(H_nick);
del_bind_table(H_mode); del_bind_table(H_mode);
del_bind_table(H_kick); del_bind_table(H_kick);
del_bind_table(H_invt);
del_bind_table(H_join); del_bind_table(H_join);
del_bind_table(H_pubm); del_bind_table(H_pubm);
del_bind_table(H_pub); del_bind_table(H_pub);
Expand Down Expand Up @@ -1208,7 +1234,8 @@ static Function irc_table[] = {
(Function) me_voice, (Function) me_voice,
/* 24 - 27 */ /* 24 - 27 */
(Function) getchanmode, (Function) getchanmode,
(Function) reset_chan_info (Function) reset_chan_info,
(Function) & H_invt /* p_tcl_bind_list */
}; };


char *irc_start(Function *global_funcs) char *irc_start(Function *global_funcs)
Expand Down Expand Up @@ -1268,6 +1295,7 @@ char *irc_start(Function *global_funcs)
H_nick = add_bind_table("nick", HT_STACKABLE, channels_5char); H_nick = add_bind_table("nick", HT_STACKABLE, channels_5char);
H_mode = add_bind_table("mode", HT_STACKABLE, channels_6char); H_mode = add_bind_table("mode", HT_STACKABLE, channels_6char);
H_kick = add_bind_table("kick", HT_STACKABLE, channels_6char); H_kick = add_bind_table("kick", HT_STACKABLE, channels_6char);
H_invt = add_bind_table("invt", HT_STACKABLE, invite_4char);
H_join = add_bind_table("join", HT_STACKABLE, channels_4char); H_join = add_bind_table("join", HT_STACKABLE, channels_4char);
H_pubm = add_bind_table("pubm", HT_STACKABLE, channels_5char); H_pubm = add_bind_table("pubm", HT_STACKABLE, channels_5char);
H_pub = add_bind_table("pub", 0, channels_5char); H_pub = add_bind_table("pub", 0, channels_5char);
Expand Down
1 change: 1 addition & 0 deletions src/mod/irc.mod/irc.h
Expand Up @@ -36,6 +36,7 @@
#ifdef MAKING_IRC #ifdef MAKING_IRC
static void check_tcl_need(char *, char *); static void check_tcl_need(char *, char *);
static void check_tcl_kick(char *, char *, struct userrec *, char *, char *, char *); static void check_tcl_kick(char *, char *, struct userrec *, char *, char *, char *);
static void check_tcl_invite(char *, char *, char *, char *);
static void check_tcl_mode(char *, char *, struct userrec *, char *, char *, char *); static void check_tcl_mode(char *, char *, struct userrec *, char *, char *, char *);
static void check_tcl_joinspltrejn(char *, char *, struct userrec *, char *, static void check_tcl_joinspltrejn(char *, char *, struct userrec *, char *,
p_tcl_bind_list); p_tcl_bind_list);
Expand Down

0 comments on commit 14dcd6d

Please sign in to comment.