From be9f2513d1c3b5b0592bf2b404a170d526d3d32e Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 27 Apr 2005 18:53:30 +0000 Subject: [PATCH] Added user channel update info --- mbtask/taskchat.c | 10 +++++++--- mbtask/taskibc.c | 35 +++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/mbtask/taskchat.c b/mbtask/taskchat.c index 9cd559fb..abbfcd66 100644 --- a/mbtask/taskchat.c +++ b/mbtask/taskchat.c @@ -281,13 +281,13 @@ int join(pid_t pid, char *channel, int sysop) chat_users[j].chatting = TRUE; Syslog('-', "Added user %d to channel %s", j, channel); 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); /* * The sysop channel is private to the system, no broadcast */ - if (strcasecmp(channel, "sysop")) + if (strcasecmp(channel, "#sysop")) send_all("JOIN %s@%s %s\r\n", chat_users[j].nick, CFG.myfqdn, channel); return TRUE; } @@ -414,7 +414,7 @@ int part(pid_t pid, char *reason) */ if (reason != NULL) chat_msg(chat_users[i].channel, chat_users[i].nick, reason); - sprintf(buf, "%s has left channel #%s, %d users left", chat_users[i].nick, tmp->name, tmp->users); + sprintf(buf, "%s has left channel %s, %d users left", chat_users[i].nick, tmp->name, tmp->users); chat_msg(chat_users[i].channel, NULL, buf); if (strcmp(tmp->name, (char *)"sysop")) { if (reason && strlen(reason)) @@ -744,7 +744,11 @@ char *chat_put(char *data) system_msg(chat_users[i].pid, buf); } else { Syslog('-', "Trying to join channel %s", cmd); +#ifdef USE_EXPERIMENT + join(chat_users[i].pid, cmd, chat_users[i].sysop); +#else join(chat_users[i].pid, cmd+1, chat_users[i].sysop); +#endif } chat_dump(); goto ack; diff --git a/mbtask/taskibc.c b/mbtask/taskibc.c index bd3eebcd..008ab9ad 100644 --- a/mbtask/taskibc.c +++ b/mbtask/taskibc.c @@ -815,10 +815,6 @@ int command_pass(char *hostname, char *parameters) version = strtok(NULL, " \0"); lnk = strtok(NULL, " \0"); -// Syslog('r', "passwd \"%s\"", printable(passwd, 0)); -// Syslog('r', "version \"%s\"", printable(version, 0)); -// Syslog('r', "link \"%s\"", printable(lnk, 0)); - if (version == NULL) { send_msg(tnsl, "461 PASS: Not enough parameters\r\n"); return 461; @@ -844,6 +840,7 @@ int command_server(char *hostname, char *parameters) ncs_list *tnsl; srv_list *ta; usr_list *tmp; + chn_list *tmpc; char *name, *hops, *id, *prod, *vers, *fullname; unsigned long token; int ihops, found = FALSE; @@ -863,13 +860,6 @@ int command_server(char *hostname, char *parameters) } } -// Syslog('r', "name \"%s\"", printable(name, 0)); -// Syslog('r', "hops \"%s\"", printable(hops, 0)); -// Syslog('r', "id \"%s\"", printable(id, 0)); -// Syslog('r', "prod \"%s\"", printable(prod, 0)); -// Syslog('r', "vers \"%s\"", printable(vers, 0)); -// Syslog('r', "full \"%s\"", printable(fullname, 0)); - if (fullname == NULL) { send_msg(tnsl, "461 SERVER: Not enough parameters\r\n"); return 461; @@ -906,6 +896,16 @@ int command_server(char *hostname, char *parameters) send_msg(tnsl, "USER %s@%s %s\r\n", tmp->name, tmp->server, tmp->realname); if (strcmp(tmp->name, tmp->nick)) send_msg(tnsl, "NICK %s %s %s %s\r\n", tmp->nick, tmp->name, tmp->server, tmp->realname); + if (strlen(tmp->channel)) { + for (tmpc = channels; tmpc; tmpc = tmpc->next) { + if (strcasecmp(tmpc->name, tmp->channel) == 0) { + send_msg(tnsl, "JOIN %s@%s %s\r\n", tmpc->owner, tmpc->server, tmpc->name); + if (strlen(tmpc->topic) && (strcmp(tmpc->server, CFG.myfqdn) == 0)) { + send_msg(tnsl, "TOPIC %s %s\r\n", tmpc->name, tmpc->topic); + } + } + } + } } add_server(&servers, tnsl->server, ihops, prod, vers, fullname, hostname); return 0; @@ -938,12 +938,23 @@ int command_server(char *hostname, char *parameters) } } /* - * Send all known users + * Send all known users. If a user is in a channel, send a JOIN. + * If the user is one of our own and has set a channel topic, send it. */ for (tmp = users; tmp; tmp = tmp->next) { send_msg(tnsl, "USER %s@%s %s\r\n", tmp->name, tmp->server, tmp->realname); if (strcmp(tmp->name, tmp->nick)) send_msg(tnsl, "NICK %s %s %s %s\r\n", tmp->nick, tmp->name, tmp->server, tmp->realname); + if (strlen(tmp->channel)) { + for (tmpc = channels; tmpc; tmpc = tmpc->next) { + if (strcasecmp(tmpc->name, tmp->channel) == 0) { + send_msg(tnsl, "JOIN %s@%s %s\r\n", tmpc->owner, tmpc->server, tmpc->name); + if (strlen(tmpc->topic) && (strcmp(tmpc->server, CFG.myfqdn) == 0)) { + send_msg(tnsl, "TOPIC %s %s\r\n", tmpc->name, tmpc->topic); + } + } + } + } } add_server(&servers, tnsl->server, ihops, prod, vers, fullname, hostname); changed = TRUE;