Delete users from channel when a server disconnects
This commit is contained in:
parent
edbf310113
commit
13ac2a332f
@ -283,6 +283,27 @@ int add_user(char *server, char *name, char *realname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete user from channel
|
||||||
|
*/
|
||||||
|
void del_userchannel(char *channel)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAXIBC_CHN; i++) {
|
||||||
|
if (strcmp(chn_list[i].name, channel) == 0) {
|
||||||
|
chnchg = TRUE;
|
||||||
|
chn_list[i].users--;
|
||||||
|
if (chn_list[i].users == 0) {
|
||||||
|
Syslog('+', "IBC: deleted empty channel %s", channel);
|
||||||
|
del_channel(channel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete one user. If name == NULL then delete all users of a server.
|
* Delete one user. If name == NULL then delete all users of a server.
|
||||||
@ -293,11 +314,15 @@ void del_user(char *server, char *name)
|
|||||||
|
|
||||||
for (i = 0; i < MAXIBC_USR; i++) {
|
for (i = 0; i < MAXIBC_USR; i++) {
|
||||||
if (name && (strcmp(usr_list[i].server, server) == 0) && (strcmp(usr_list[i].name, name) == 0)) {
|
if (name && (strcmp(usr_list[i].server, server) == 0) && (strcmp(usr_list[i].name, name) == 0)) {
|
||||||
|
if (strlen(usr_list[i].channel))
|
||||||
|
del_userchannel(usr_list[i].channel);
|
||||||
Syslog('r', "IBC: del_user(%s, %s) from slot %d", server, printable(name, 0), i);
|
Syslog('r', "IBC: del_user(%s, %s) from slot %d", server, printable(name, 0), i);
|
||||||
memset(&usr_list[i], 0, sizeof(_usr_list));
|
memset(&usr_list[i], 0, sizeof(_usr_list));
|
||||||
usrchg = TRUE;
|
usrchg = TRUE;
|
||||||
count++;
|
count++;
|
||||||
} else if ((name == NULL) && (strcmp(usr_list[i].server, server) == 0)) {
|
} else if ((name == NULL) && (strcmp(usr_list[i].server, server) == 0)) {
|
||||||
|
if (strlen(usr_list[i].channel))
|
||||||
|
del_userchannel(usr_list[i].channel);
|
||||||
Syslog('r', "IBC: del_user(%s, %s) user %s from slot %d", server, printable(name, 0), usr_list[i].name, i);
|
Syslog('r', "IBC: del_user(%s, %s) user %s from slot %d", server, printable(name, 0), usr_list[i].name, i);
|
||||||
memset(&usr_list[i], 0, sizeof(_usr_list));
|
memset(&usr_list[i], 0, sizeof(_usr_list));
|
||||||
usrchg = TRUE;
|
usrchg = TRUE;
|
||||||
@ -1442,17 +1467,7 @@ int command_part(int slot, char *hostname, char *parameters)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAXIBC_CHN; i++) {
|
del_userchannel(channel);
|
||||||
if (strcmp(chn_list[i].name, channel) == 0) {
|
|
||||||
chnchg = TRUE;
|
|
||||||
chn_list[i].users--;
|
|
||||||
if (chn_list[i].users == 0) {
|
|
||||||
Syslog('+', "IBC: deleted empty channel %s", channel);
|
|
||||||
del_channel(channel);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MAXIBC_USR; i++) {
|
for (i = 0; i < MAXIBC_USR; i++) {
|
||||||
if ((strcmp(usr_list[i].server, server) == 0) &&
|
if ((strcmp(usr_list[i].server, server) == 0) &&
|
||||||
|
Reference in New Issue
Block a user