Skip to content

Commit

Permalink
Add IRCv3 standard replies capability
Browse files Browse the repository at this point in the history
  • Loading branch information
vanosg committed May 5, 2024
1 parent 5464ce2 commit 1155fb3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/mod/server.mod/servmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,53 @@ static int got730or1(char *from, char *msg, int code)
return 0;
}

/* Got IRCv3 standard-reply
* <FAIL/NOTE/WARN> <command> <code> [<context>...] <description>
*
* stdtype is 0 for FAIL, 1 for NOTE, 2 for WARN
*/
static int gotstdreply(char *from, char * msgtype, char *msg)
{
char *cmd, *code, *text;
char context[MSGMAX] = "";
int len;

cmd = newsplit(&msg);
code = newsplit(&msg);
text = strchr(msg, ':');
if (text != msg) {
len = text - msg;
strncpy(context, msg, len);
}
fixcolon(text);
putlog(LOG_SERV, "*", "%s%s%s: Received a %s message from %s: %s", cmd, cmd ? ": " : "", code, msgtype, from, text);
return 0;
}

/* Got IRCv3 FAIL standard-reply */
static int gotstdfail(char *from, char *msg)
{
char msgtype[] = "FAIL";
gotstdreply(from, msgtype, msg);
return 0;
}

/* Got IRCv3 NOTE standard-reply */
static int gotstdnote(char *from, char *msg)
{
char msgtype[] = "NOTE";
gotstdreply(from, msgtype, msg);
return 0;
}

/* Got IRCv3 WARN standard-reply */
static int gotstdwarn(char *from, char *msg)
{
char msgtype[] = "WARN";
gotstdreply(from, msgtype, msg);
return 0;
}

/* Got 730/RPL_MONONLINE
* :<server> 730 <nick> :target[!user@host][,target[!user@host]]*
*/
Expand Down Expand Up @@ -2097,6 +2144,9 @@ static cmd_t my_raw_binds[] = {
{"PING", "", (IntFunc) gotping, NULL},
{"PONG", "", (IntFunc) gotpong, NULL},
{"WALLOPS", "", (IntFunc) gotwall, NULL},
{"FAIL", "", (IntFunc) gotstdfail, NULL},
{"NOTE", "", (IntFunc) gotstdnote, NULL},
{"WARN", "", (IntFunc) gotstdwarn, NULL},
{"001", "", (IntFunc) got001, NULL},
{"005", "", (IntFunc) got005, NULL},
{"303", "", (IntFunc) got303, NULL},
Expand Down

0 comments on commit 1155fb3

Please sign in to comment.