void parse_notice(char *from, char **Args) { int type; char *to, *high = empty_string, *target, *line; NickList *nick = NULL; ChannelList *tmpc = NULL; char *newline = NULL; PasteArgs(Args, 1); to = Args[0]; line = Args[1]; if (!to || !line) return; if (!*to) { put_it("*** obsolete notice recieved. [%s]", line+1); return; } if (!from || !*from || !strcmp(get_server_itsname(from_server), from)) { parse_server_notice(from, line); return; } if (is_channel(to)) { target = to; type = PUBLIC_NOTICE_LIST; if ((tmpc = lookup_channel(to, from_server, CHAN_NOUNLINK))) nick = find_nicklist_in_channellist(from, tmpc, 0); } else { target = from; type = NOTICE_LIST; } update_stats(NOTICELIST, to, nick, tmpc, 0); set_display_target(target, LOG_NOTICE); doing_notice = 1; if ((check_ignore_notice(from, to, IGNORE_NOTICES, line, &high) == IGNORED)) goto notice_cleanup; if (!check_flooding(from, NOTICE_FLOOD, line, NULL)) goto notice_cleanup; if (!strchr(from, '.')) { notify_mark(from, FromUserHost, 1, 0); line = do_notice_ctcp(from, to, line); if (!*line) goto notice_cleanup; } if (sed && !do_hook(ENCRYPTED_NOTICE_LIST, "%s %s %s", from, to, line)) { #if 0 put_it("%s", convert_output_format(fget_string_var(FORMAT_ENCRYPTED_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, line)); #endif sed = 0; goto notice_cleanup; } { char *free_me = NULL; char *s; free_me = newline = stripansi(line); if (wild_match("[*Wall*", line)) { char *channel = NULL, *p, *q; q = p = next_arg(newline, &newline); if ((p = strchr(p, '/'))) { p++; if (*p && *p == '\002') p++; channel = m_strdup(p); if ((p = strchr(channel, ']'))) *p++ = 0; q = channel; if (*q && q[strlen(q)-1] == '\002') q[strlen(q)-1] = 0; } if (channel && *channel) set_display_target(channel, LOG_WALL); else set_display_target(target, LOG_WALL); if (do_hook(type, "%s %s", from, line)) { s = convert_output_format(fget_string_var(FORMAT_BWALL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), q, from, FromUserHost, newline); if (tmpc) add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler); put_it("%s", s); } add_last_type(&last_wall[0], 1, from, FromUserHost, NULL, line); logmsg(LOG_WALL, from, 0, "%s", line); /* addtabkey(from, "wall", 0);*/ new_free(&channel); } else { if (type == PUBLIC_NOTICE_LIST) { s = convert_output_format(fget_string_var(check_auto_reply(line)?FORMAT_PUBLIC_NOTICE_AR_FSET:FORMAT_PUBLIC_NOTICE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, newline); if (do_hook(type, "%s %s %s", from, to, line)) put_it("%s", s); } else { s = convert_output_format(fget_string_var(FORMAT_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, newline); if (do_hook(type, "%s %s", from, line)) put_it("%s", s); } if (tmpc) add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler); logmsg(LOG_NOTICE, from, 0, "%s", line); add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line); } new_free(&free_me); } notice_cleanup: if (beep_on_level & LOG_NOTICE) beep_em(1); reset_display_target(); doing_notice = 0; }
/* * The main handler for those wacky NOTICE commands... * This is as much like p_privmsg as i can get away with. */ void p_notice (const char *from, const char *comm, const char **ArgList) { const char *target, *message; int level, hook_type; const char * flood_channel = NULL; char * high; PasteArgs(ArgList, 1); if (!(target = ArgList[0])) { rfc1459_odd(from, comm, ArgList); return; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); return; } set_server_doing_notice(from_server, 1); sed = 0; /* Do normal /CTCP reply handling */ /* XXX -- Casting "message" to (char *) is cheating. */ message = do_notice_ctcp(from, target, (char *) #ifdef HAVE_INTPTR_T (intptr_t) #endif message); if (!*message) { set_server_doing_notice(from_server, 0); return; } /* Check to see if it is a "Server Notice" */ if ((!from || !*from) || !strcmp(get_server_itsname(from_server), from)) { parse_local_server_notice(from, target, message); set_server_doing_notice(from_server, 0); return; } /* For pesky prefix-less NOTICEs substitute the server's name */ if (!from || !*from) from = get_server_name(from_server); /* * Note that NOTICEs from servers are not "server notices" unless * the target is not a channel (ie, it is sent to us). Any notice * that is sent to a channel is a normal NOTICE, notwithstanding * _who_ sent it. */ if (is_channel(target) && im_on_channel(target, from_server)) { flood_channel = target; hook_type = PUBLIC_NOTICE_LIST; } else if (!is_me(from_server, target)) { flood_channel = NULL; hook_type = NOTICE_LIST; } else { flood_channel = NULL; hook_type = NOTICE_LIST; target = from; } /* Check for /ignore's */ switch (check_ignore_channel(from, FromUserHost, target, IGNORE_NOTICES)) { case IGNORED: set_server_doing_notice(from_server, 0); return; case HIGHLIGHTED: high = highlight_char; break; /* oops! */ default: high = empty_string; } /* Let the user know if it is an encrypted notice */ /* Note that this is always hooked, even during a flood */ if (sed) { int do_return = 1; sed = 0; level = set_lastlog_msg_level(LOG_NOTICE); message_from(target, LOG_NOTICE); if (do_hook(ENCRYPTED_NOTICE_LIST, "%s %s %s", from, target, message)) do_return = 0; set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); if (do_return) { set_server_doing_notice(from_server, 0); return; } } if (new_check_flooding(from, FromUserHost, flood_channel, message, NOTICE_FLOOD)) { set_server_doing_notice(from_server, 0); return; } /* Beep the user if they asked us to */ if (beep_on_level & LOG_NOTICE) beep_em(1); /* Go ahead and throw it to the user */ level = set_lastlog_msg_level(LOG_NOTICE); message_from(target, LOG_NOTICE); if (do_hook(GENERAL_NOTICE_LIST, "%s %s %s", from, target, message)) { if (hook_type == NOTICE_LIST) { if (do_hook(hook_type, "%s %s", from, message)) put_it("%s-%s-%s %s", high, from, high, message); } else { if (do_hook(hook_type, "%s %s %s", from, target, message)) put_it("%s-%s:%s-%s %s", high, from, target, high, message); } } /* Clean up and go home. */ set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); set_server_doing_notice(from_server, 0); /* Alas, this is not protected by protocol enforcement. :( */ notify_mark(from_server, from, 1, 0); }