Fixed local user channel registration

This commit is contained in:
Michiel Broek 2005-04-30 12:14:42 +00:00
parent c14b5b448a
commit 3fc78445d9

View File

@ -128,6 +128,7 @@ extern usr_list *users; /* Connected users */
extern chn_list *channels; /* Connected channels */ extern chn_list *channels; /* Connected channels */
extern int usrchg; extern int usrchg;
extern int chnchg; extern int chnchg;
extern pthread_mutex_t b_mutex;
#endif #endif
@ -259,6 +260,7 @@ int join(pid_t pid, char *channel, int sysop)
char buf[81]; char buf[81];
#ifdef USE_EXPERIMENT #ifdef USE_EXPERIMENT
chn_list *tmp; chn_list *tmp;
usr_list *tmpu;
#else #else
int i; int i;
#endif #endif
@ -274,11 +276,22 @@ int join(pid_t pid, char *channel, int sysop)
if (chat_users[j].pid == pid) { if (chat_users[j].pid == pid) {
strncpy(chat_users[j].channel, channel, 20); strncpy(chat_users[j].channel, channel, 20);
chat_users[j].chatting = TRUE; chat_users[j].chatting = TRUE;
Syslog('-', "Added user %d to channel %s", j, channel); Syslog('r', "Added user %d to channel %s", j, channel);
chat_dump(); chat_dump();
sprintf(buf, "%s has joined channel %s, now %d users", chat_users[j].nick, channel, tmp->users); sprintf(buf, "%s has joined channel %s, now %d users", chat_users[j].nick, channel, tmp->users);
chat_msg(channel, NULL, buf); chat_msg(channel, NULL, buf);
for (tmpu = users; tmpu; tmpu = tmpu->next) {
if ((strcmp(tmpu->server, CFG.myfqdn) == 0) &&
((strcmp(tmpu->nick, chat_users[j].nick) == 0) || (strcmp(tmpu->name, chat_users[j].nick) == 0))) {
pthread_mutex_lock(&b_mutex);
strncpy(tmpu->channel, channel, 20);
pthread_mutex_unlock(&b_mutex);
Syslog('+', "IBC: user %s has joined channel %s", chat_users[j].nick, channel);
usrchg = TRUE;
}
}
/* /*
* The sysop channel is private to the system, no broadcast * The sysop channel is private to the system, no broadcast
*/ */
@ -334,11 +347,23 @@ int join(pid_t pid, char *channel, int sysop)
if (add_channel(&channels, channel, chat_users[j].nick, CFG.myfqdn) == 0) { if (add_channel(&channels, channel, chat_users[j].nick, CFG.myfqdn) == 0) {
strncpy(chat_users[j].channel, channel, 20); strncpy(chat_users[j].channel, channel, 20);
chat_users[j].chatting = TRUE; chat_users[j].chatting = TRUE;
Syslog('-', "Added user %d to channel %s", j, channel); Syslog('r', "Added user %d to channel %s", j, channel);
sprintf(buf, "Created channel %s", channel); sprintf(buf, "* Created channel %s", channel);
chat_msg(channel, NULL, buf); chat_msg(channel, NULL, buf);
chat_dump(); chat_dump();
send_all("JOIN %s@%s %s\r\n", chat_users[j].nick, CFG.myfqdn, channel); send_all("JOIN %s@%s %s\r\n", chat_users[j].nick, CFG.myfqdn, channel);
for (tmpu = users; tmpu; tmpu = tmpu->next) {
if ((strcmp(tmpu->server, CFG.myfqdn) == 0) &&
((strcmp(tmpu->nick, chat_users[j].nick) == 0) || (strcmp(tmpu->name, chat_users[j].nick) == 0))) {
pthread_mutex_lock(&b_mutex);
strncpy(tmpu->channel, channel, 20);
pthread_mutex_unlock(&b_mutex);
Syslog('+', "IBC: user %s created and joined channel %s", chat_users[j].nick, channel);
usrchg = TRUE;
}
}
return TRUE; return TRUE;
} }
} }
@ -393,6 +418,7 @@ int part(pid_t pid, char *reason)
char buf[81]; char buf[81];
#ifdef USE_EXPERIMENT #ifdef USE_EXPERIMENT
chn_list *tmp; chn_list *tmp;
usr_list *tmpu;
#endif #endif
if (strlen(reason) > 54) if (strlen(reason) > 54)
@ -433,6 +459,18 @@ int part(pid_t pid, char *reason)
Syslog('-', "Remove channel %s, no more users left", tmp->name); Syslog('-', "Remove channel %s, no more users left", tmp->name);
del_channel(&channels, tmp->name); del_channel(&channels, tmp->name);
} }
for (tmpu = users; tmpu; tmpu = tmpu->next) {
if ((strcmp(tmpu->server, CFG.myfqdn) == 0) &&
((strcmp(tmpu->nick, chat_users[i].nick) == 0) || (strcmp(tmpu->name, chat_users[i].nick) == 0))) {
pthread_mutex_lock(&b_mutex);
tmpu->channel[0] = '\0';
pthread_mutex_unlock(&b_mutex);
Syslog('+', "IBC: user %s created and joined channel %s", chat_users[i].nick, chat_users[i].channel);
usrchg = TRUE;
}
}
chat_users[i].channel[0] = '\0'; chat_users[i].channel[0] = '\0';
chat_users[i].chatting = FALSE; chat_users[i].chatting = FALSE;
chat_dump(); chat_dump();
@ -793,6 +831,7 @@ char *chat_put(char *data)
count = 0; count = 0;
#ifdef USE_EXPERIMENT #ifdef USE_EXPERIMENT
for (tmp = users; tmp; tmp = tmp->next) { for (tmp = users; tmp; tmp = tmp->next) {
Syslog('r', "/names list %s %s", tmp->name, tmp->channel);
if (strcmp(tmp->channel, chat_users[i].channel) == 0) { if (strcmp(tmp->channel, chat_users[i].channel) == 0) {
sprintf(buf, "%s@%s (%s)%s", tmp->nick, tmp->server, tmp->realname, sprintf(buf, "%s@%s (%s)%s", tmp->nick, tmp->server, tmp->realname,
tmp->chanop ? (char *)" (chanop)" : (char *)""); tmp->chanop ? (char *)" (chanop)" : (char *)"");