@load tcp @load irc module IrcQuite; export { # Define a NOTICE type for our alert. redef enum Notice += { QuietUser }; } # Maps nick names to channels which the user has joined *and* not said # anything on yet. global users: table[string] of set[string]; event irc_join_message(c: connection, info_list: irc_join_list) { for ( info in info_list ) { local nick = info$nick; # Double-check that there is a nick. if ( nick == "" ) return; # Add new to the nick's table entry. if ( nick !in users ) users[nick] = set(info$channel); else add users[nick][info$channel]; } } event irc_privmsg_message(c: connection, source: string, target: string, message: string) { # Source have the form "nick!...". So split off the nick first. local parts = split1(source, /!/); local nick = parts[1]; if ( nick !in users ) # Not a known nick so nothing to do. return; # Nick said something so delete the channel. delete users[nick][target]; } function report_quiet_user(nick: string, channels: string_set) { if ( nick !in users ) # Don't know this one. return; for ( channel in users[nick] ) # One notice per channel. NOTICE([$note=QuietUser, $msg=fmt("quiet user %s on channel %s", nick, channel)]); } event irc_part_message(c: connection, nick: string, chans: string_set, message: string) { report_quiet_user(nick, chans); } event irc_quit_message(c: connection, nick: string, message: string) { if ( nick !in users ) # Don't know this one. return; report_quiet_user(nick, users[nick]); }