void
irc_notice(struct userNode *from, const char *to, const char *message)
{
- if (to[0] != '#' && to[0] != '$'
- && !deliver_to_dummy(from, GetUserN(to), message, 0))
+ if (to[0] == '#' || to[0] == '$'
+ || !deliver_to_dummy(from, GetUserN(to), message, 0))
putsock("%s " P10_NOTICE " %s :%s", from->numeric, to, message);
}
void
irc_privmsg(struct userNode *from, const char *to, const char *message)
{
- if (to[0] != '#' && to[0] != '$'
- && !deliver_to_dummy(from, GetUserN(to), message, 1))
+ if (to[0] == '#' || to[0] == '$'
+ || !deliver_to_dummy(from, GetUserN(to), message, 1))
putsock("%s " P10_PRIVMSG " %s :%s", from->numeric, to, message);
}
struct modeNode *mn;
struct banNode *bn;
long last_mode=-1;
+ unsigned int first_ban;
unsigned int n;
base_len = sprintf(burst_line, "%s " P10_BURST " %s " FMT_TIME_T " ",
self->numeric, chan->name, chan->timestamp);
len = irc_make_chanmode(chan, burst_line+base_len);
pos = base_len + len;
- if (len)
+ if (len > 0 && chan->members.used > 0)
burst_line[pos++] = ' ';
/* dump the users */
if ((n+1)<chan->members.used)
burst_line[pos++] = ',';
}
+
+ /* dump the bans */
if (chan->banlist.used) {
- /* dump the bans */
- if (pos+2+strlen(chan->banlist.list[0]->ban) > 505) {
- burst_line[pos-1] = 0;
- putsock("%s", burst_line);
- pos = base_len;
- } else {
+ first_ban = 1;
+
+ if (chan->members.used > 0)
burst_line[pos++] = ' ';
- }
- burst_line[pos++] = ':';
- burst_line[pos++] = '%';
- base_len = pos;
- for (n=0; n<chan->banlist.used; n++) {
+ for (n=0; n<chan->banlist.used; ) {
+ if (first_ban && (pos < 500)) {
+ burst_line[pos++] = ':';
+ burst_line[pos++] = '%';
+ }
bn = chan->banlist.list[n];
len = strlen(bn->ban);
- if (pos+len+1 > 510) {
- burst_line[pos-1] = 0; /* -1 to back up over the space or comma */
+ if (pos + 2 + len < 505) {
+ memcpy(burst_line + pos, bn->ban, len);
+ pos += len;
+ burst_line[pos++] = ' ';
+ first_ban = 0;
+ n++;
+ } else {
+ burst_line[pos-1] = 0;
putsock("%s", burst_line);
pos = base_len;
+ first_ban = 1;
}
- memcpy(burst_line+pos, bn->ban, len);
- pos += len;
- burst_line[pos++] = ' ';
}
}
+
/* print the last line */
burst_line[pos] = 0;
putsock("%s", burst_line);
unsigned int nn;
free(of_list);
free(privmsg_funcs);
+ num_privmsg_funcs = 0;
free(notice_funcs);
+ num_notice_funcs = 0;
free(mcf_list);
dict_delete(irc_func_dict);
for (nn=0; nn<dead_users.used; nn++)