/* * 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_invite(char *from, char **ArgList) { char *high; switch (check_ignore(from, FromUserHost, ArgList[1] ? ArgList[1] : NULL, IGNORE_INVITES, NULL)) { case IGNORED: if (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)); return; case HIGHLIGHTED: high = highlight_char; break; default: high = empty_str; break; } if (ArgList[0] && ArgList[1]) { struct channel *chan = NULL; struct whowas_chan_list *w_chan = NULL; message_from(from, LOG_CRAP); malloc_strcpy(&invite_channel, ArgList[1]); if (check_flooding(from, INVITE_FLOOD, ArgList[1], NULL) && do_hook(INVITE_LIST, "%s %s", from, ArgList[1])) { put_it("%s", convert_output_format(get_format(FORMAT_INVITE_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[1])); } if (!(chan = lookup_channel(invite_channel, from_server, 0))) if ((w_chan = check_whowas_chan_buffer(invite_channel, 0))) chan = w_chan->channellist; if (chan && get_int_var(AUTO_REJOIN_VAR) && invite_channel) { if (!in_join_list(invite_channel, from_server)) send_to_server(SERVER(from_server), "JOIN %s %s", invite_channel, ArgList[2] ? ArgList[2] : ""); } malloc_strcpy(&recv_nick, from); } }
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; }