/* * The client apparantly never was adapted to handle the new NOTE syntax. * So i had to kludge this up to work with it. Currently, NOTEs are sent * something like this: * * NOTICE yournick :Note from nick!user@host /xxxd:xxh:xxm/ [N] message * * and parse() calls parse_notice(), who notices that there is no pefix * and passes it off to parse_local_server_notice(), who checks to see * if it is a note (it is), blows away the "Note from" part, and re-sets * the "from" and "FromUserHost" parts with the nick!user@host part and * passes us the buck with 'line' pointing at the time description * (the /.../ part) */ static void parse_note (char *from, char *line) { char *date, *flags, *high; time_t when; int level; switch (check_ignore(from, FromUserHost, IGNORE_NOTES)) { case IGNORED: return; case HIGHLIGHTED: high = highlight_char; break; default: high = empty_string; } if (check_flooding(from, FromUserHost, NOTE_FLOOD, line)) return; /* at this point, line looks like: "/xxxd:xxh:xxm/ [FLAGS] message goes here" */ date = next_arg(line, &line); flags = next_arg(line, &line); when = convert_note_time_to_real_time(date); level = set_lastlog_msg_level(LOG_NOTES); if (do_hook(NOTE_LIST, "%s %lu %s", from, when, line)) { if (time(NULL) - when > 60) /* not just sent */ put_it("%s[%s]%s %s (%s)", high, from, high, line, my_ctime(when)); else put_it("%s[%s]%s %s", high, from, high, line); } if (beep_on_level & LOG_NOTES) beep_em(1); set_lastlog_msg_level(level); }
static void p_wallops(char *from, char **ArgList) { char *line; int from_server = strchr(from, '.') ? 1 : 0; if (!(line = PasteArgs(ArgList, 0))) { fake(); return; } if (from_server || check_flooding(from, WALLOP_FLOOD, line, NULL)) { /* The old server check, don't use the whois stuff for servers */ int level; char *high; switch (check_ignore(from, FromUserHost, NULL, IGNORE_WALLOPS, NULL)) { case (IGNORED): return; case (HIGHLIGHTED): high = highlight_char; break; default: high = empty_str; break; } message_from(from, LOG_WALLOP); level = set_lastlog_msg_level(LOG_WALLOP); if (do_hook(WALLOP_LIST, "%s %c %s", from, from_server ? 'S' : '*', line)) put_it("%s", convert_output_format(get_format(from_server ? FORMAT_WALLOP_FSET : FORMAT_WALL_FSET), "%s %s %s %s", update_clock(GET_TIME), from, from_server ? "!" : "*", line)); if (beep_on_level & LOG_WALLOP) beep_em(1); set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); } }
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; }
static void p_privmsg(char *from, char **Args) { int level, list_type, flood_type, log_type, no_flood = 1, do_beep = 1; unsigned char ignore_type; char *ptr = NULL, *to; char *high; struct channel *channel = NULL; struct nick_list *tmpnick = NULL; if (!from) return; PasteArgs(Args, 1); to = Args[0]; ptr = Args[1]; if (!to || !ptr) { fake(); return; } doing_privmsg = 1; if (is_channel(to) && im_on_channel(to)) { message_from(to, LOG_MSG); malloc_strcpy(&public_nick, from); log_type = LOG_PUBLIC; ignore_type = IGNORE_PUBLIC; flood_type = PUBLIC_FLOOD; if (!is_on_channel(to, from_server, from)) list_type = PUBLIC_MSG_LIST; else { if (is_current_channel(to, from_server, 0)) list_type = PUBLIC_LIST; else list_type = PUBLIC_OTHER_LIST; channel = lookup_channel(to, from_server, CHAN_NOUNLINK); if (channel) tmpnick = find_nicklist_in_channellist(from, channel, 0); } } else { message_from(from, LOG_MSG); flood_type = MSG_FLOOD; if (my_stricmp(to, get_server_nickname(from_server))) { log_type = LOG_WALL; ignore_type = IGNORE_WALLS; list_type = MSG_GROUP_LIST; } else { log_type = LOG_MSG; ignore_type = IGNORE_MSGS; list_type = MSG_LIST; } } switch (check_ignore(from, FromUserHost, to, ignore_type, ptr)) { case IGNORED: if ((list_type == MSG_LIST) && get_int_var(SEND_IGNORE_MSG_VAR)) send_to_server(SERVER(from_server), "NOTICE %s :%s is ignoring you", from, get_server_nickname(from_server)); doing_privmsg = 0; return; case HIGHLIGHTED: high = highlight_char; break; case CHANNEL_GREP: high = highlight_char; break; default: high = empty_str; break; } ptr = do_ctcp(from, to, ptr); if (!ptr || !*ptr) { doing_privmsg = 0; return; } level = set_lastlog_msg_level(log_type); if (flood_type == PUBLIC_FLOOD) { int blah = 0; if (is_other_flood(channel, tmpnick, PUBLIC_FLOOD, &blah)) { no_flood = 0; flood_prot(tmpnick->nick, FromUserHost, "PUBLIC", flood_type, get_int_var(PUBFLOOD_TIME_VAR), channel->channel); } } else no_flood = check_flooding(from, flood_type, ptr, NULL); { switch (list_type) { case PUBLIC_MSG_LIST: logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_MSG_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; case MSG_GROUP_LIST: logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_MSG_GROUP_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; case MSG_LIST: { if (!no_flood) break; malloc_strcpy(&recv_nick, from); if (away_set) { do_beep = 0; beep_em(get_int_var(BEEP_WHEN_AWAY_VAR)); set_int_var(MSGCOUNT_VAR, get_int_var(MSGCOUNT_VAR) + 1); } logmsg(LOG_MSG, from, ptr, 0); addtabkey(from, "msg"); if (do_hook(list_type, "%s %s", from, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_MSG_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); if (from_server > -1 && get_server_away(from_server) && get_int_var(SEND_AWAY_MSG_VAR)) { send_to_server(SERVER(from_server), "NOTICE %s :%s", from, stripansicodes(convert_output_format (get_format(FORMAT_SEND_AWAY_FSET), "%l %l %s", time(NULL), server_list[from_server].awaytime, get_int_var(MSGLOG_VAR) ? "On" : "Off"))); } break; } case PUBLIC_LIST:{ logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; } case PUBLIC_OTHER_LIST:{ logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; } /* case */ } /* switch */ } if (beep_on_level & log_type && do_beep) beep_em(1); set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); doing_privmsg = 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); }