Prevent wrapper.c from flooding the IRC server.
[iii.git] / patches / ii-1.4-joinuser.diff
bloba11549574b2ecdaa6ce23045a8e01aac6a87c09d
1 diff -r d93eaacde742 ii.c
2 --- a/ii.c Fri Jun 25 10:55:05 2010 +0200
3 +++ b/ii.c Tue Jul 13 09:29:23 2010 -0700
4 @@ -105,6 +105,7 @@
5 return open(infile, O_RDONLY | O_NONBLOCK, 0);
8 +static void print_out(char *channel, char *buf); // needs to be declared
9 static void add_channel(char *name) {
10 Channel *c;
11 int fd;
12 @@ -130,6 +131,12 @@
14 c->fd = fd;
15 c->name = strdup(name);
17 + if(name[0] && !((name[0]=='#')||(name[0]=='&')||(name[0]=='+')||(name[0]=='!'))) {
18 + char msg[128];
19 + snprintf(msg, sizeof(msg), "-!- %s has joined %s", nick, name);
20 + print_out(name, msg);
21 + }
24 static void rm_channel(Channel *c) {
25 @@ -210,6 +217,7 @@
26 if(channel) snprintf(server, sizeof(server), "-!- %s", channel);
27 if(strstr(buf, server)) channel="";
28 create_filepath(outfile, sizeof(outfile), channel, "out");
29 + if(channel && channel[0]) add_channel(channel);
30 if(!(out = fopen(outfile, "a"))) return;
32 strftime(buft, sizeof(buft), "%F %R", localtime(&t));
33 @@ -237,17 +245,14 @@
34 case 'j':
35 p = strchr(&buf[3], ' ');
36 if(p) *p = 0;
37 + add_channel(&buf[3]);
38 if((buf[3]=='#')||(buf[3]=='&')||(buf[3]=='+')||(buf[3]=='!')){
39 if(p) snprintf(message, PIPE_BUF, "JOIN %s %s\r\n", &buf[3], p + 1); /* password protected channel */
40 else snprintf(message, PIPE_BUF, "JOIN %s\r\n", &buf[3]);
41 - add_channel(&buf[3]);
43 - else {
44 - if(p){
45 - add_channel(&buf[3]);
46 - proc_channels_privmsg(&buf[3], p + 1);
47 - return;
48 - }
49 + else if(p) {
50 + proc_channels_privmsg(&buf[3], p + 1);
51 + return;
53 break;
54 case 't':
55 @@ -357,6 +362,8 @@
56 argv[TOK_CHAN] = argv[TOK_TEXT];
57 snprintf(message, PIPE_BUF, "-!- %s(%s) has joined %s", argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_TEXT]);
58 } else if(!strncmp("PART", argv[TOK_CMD], 5)) {
59 + if (!strcmp(nick, argv[TOK_NICKSRV]))
60 + return;
61 snprintf(message, PIPE_BUF, "-!- %s(%s) has left %s", argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_CHAN]);
62 } else if(!strncmp("MODE", argv[TOK_CMD], 5))
63 snprintf(message, PIPE_BUF, "-!- %s changed mode/%s -> %s %s", argv[TOK_NICKSRV], argv[TOK_CMD + 1] ? argv[TOK_CMD + 1] : "" , argv[TOK_CMD + 2]? argv[TOK_CMD + 2] : "", argv[TOK_CMD + 3] ? argv[TOK_CMD + 3] : "");