echo %%% Loading anotify.irc... # Advanced notify (faster with many nicks, advanced display) ### User config section ######################### # Use these as examples, and modify the output to your liking. # What to show when signon/signoff/return/going away detected on ^hook "notify signon % % % % %" ne $Z $isaway($4): $2$isircop($3) <$5@$6> on ^hook "notify signoff %" ne $Z Gone: $2 on ^hook "notify return % % % % %" ne $Z Back: $2$isircop($3) <$5@$6> on ^hook "notify away % % % % %" ne $Z Away: $2$isircop($3) <$5@$6> # Alternatives # Don't show anything when someone sets themselves no longer away: #on ^hook "notify return % % % % %" # do nothing # Don't show anything when someone sets themselves away: #on ^hook "notify away % % % % %" # do nothing # Script serial number assign ANOTIFY_SNO 3346 # How long to wait before terminating a notify batch assign ANOTIFY_BATCH 120 # Uncomment these if they aren't defined elsewhere # (i.e. WizIrc) #alias ne xecho -level crap ### #alias err xecho -level crap ### ### End of user config section. ################# alias isaway { if ( [$0] == [-] ) { @ function_return = [Here] } { @ function_return = [Away] } } alias isircop { if ( [$0] == [-] ) { @ function_return = [] } { @ function_return = [*] } } # First some list handling functions # Sdel: string del, delete a word from string # Usage: $sdel($what $from_what) alias sdel { ^assign sdel_offs $match($0 $1-) if ([$sdel_offs]) { @ sdel_end = sdel_offs - 1 @ sdel_cont = sdel_offs + 1 eval @ sdel_front = [\$1-$sdel_end] eval @ sdel_tail = [\$${sdel_cont}-] if ([$sdel_tail]) { if ([$sdel_front]) { @ sdel_result = [$sdel_front $sdel_tail] } { @ sdel_result = [$sdel_tail] } } { @ sdel_result = [$sdel_front] } @ function_return = [$sdel($0 $sdel_result)] ^assign -sdel_result ^assign -sdel_tail ^assign -sdel_front ^assign -sdel_cont ^assign -sdel_end } { @ function_return = [$1-] } ^assign -sdel_offs } # Concat, add something to end of (possibly empty) string # Usage: $concat($what $to_what) alias concat { if ([$1]) { @ function_return = [$1- $0] } { @ function_return = [$0] } } # clear the notify list alias notify_clear { ne Notify list cleared. ^assign -notify_list ^assign -notify_present ^assign -notify_online ^assign -notify_absent foreach notify_masks currnick { ^assign -notify_masks[$currnick] } ^assign -currnick } # remove nick $0 (format: -nick) from notify list # if form Nick!user@host, remove user@host to notify_masks[Nick] alias notify_remove if ([$0]!=[]) { #echo ??? notify_remove $0 ^assign nick $mid(1 99 $0) if (index(! $nick)>[0]) { ^assign nickmask $right(${length($nick) - index(! $nick) + 1} $nick) ^assign nick $left($index(! $nick) $nick) if (match($^*nickmask $notify_masks[$nick])) { # mask is present for nick ^assign newmasks $sdel($nickmask $notify_masks[$nick]) if ([$newmasks]) { ^assign notify_masks[$nick] $newmasks @ notify_removed = [$concat(${nick}[${nicknmask}] $notify_removed)] #ne Mask $nickmask removed from masks for $nick in notify list. } { ^assign -notify_masks[$nick] # remove nick from list @ notify_list = [$sdel($nick $notify_list)] if (match($nick $notify_absent)) { @ notify_absent = [$sdel($nick $notify_absent)] } if (match($nick $notify_online)) { @ notify_online = [$sdel($nick $notify_online)] notify_remove_present $nick } @ notify_removed = [$concat($nick $notify_removed)] #ne Nick $nick removed from notify list. } ^assign -newmasks } { # mask not in list err Mask $nickmask not in masks for $nick in notify list. } ^assign -nickmask } { if (match($nick $notify_list)) { # remove nick from list @ notify_list = [$sdel($nick $notify_list)] ^assign -notify_masks[$nick] if (match($nick $notify_absent)) { @ notify_absent = [$sdel($nick $notify_absent)] } if (match($nick $notify_online)) { @ notify_online = [$sdel($nick $notify_online)] notify_remove_present $nick } @ notify_removed = [$concat($nick $notify_removed)] #ne Nick $nick removed from notify list. } { err Nick $nick not in notify list. } } ^assign -nick } # add nick $0 to notify list.. If already present, just add to list # of nicks to be checked # if form Nick!user@host, add user@host to notify_masks[Nick] alias notify_add if ([$0]!=[]) { #echo ??? notify_add $0 ^assign nick $0 if (index(! $nick)>[0]) { ^assign nickmask $right(${length($nick) - index(! $nick) + 1} $nick) ^assign nick $left($index(! $nick) $nick) if (match($^*nickmask $notify_masks[$nick])) { # mask already present for nick err Mask $nickmask already present in masks for $nick in notify list. } { ^assign notify_masks[$nick] $concat($nickmask $notify_masks[$nick]) @ notify_added = [$concat(${nick}[${nickmask}] $notify_added)] #ne Mask $nickmask added to masks for $nick in notify list. } ^assign nickidx $match($nick $notify_list) if (![$nickidx]) { # add nick to list @ notify_list = [$concat($nick $notify_list)] @ notify_check = [$concat($nick $notify_check)] } { # nick was already in notify list, just re-check @ notify_check = [$concat($nick $notify_check)] } ^assign -nickmask } { ^assign nickidx $match($nick $notify_list) if (![$nickidx]) { # add nick to list @ notify_list = [$concat($nick $notify_list)] @ notify_check = [$concat($nick $notify_check)] if ([$nickmask]) { @ notify_added = [$concat(${nick}[${usermask}] $notify_added)] ^assign -nickmask } { @ notify_added = [$concat($nick $notify_added)] } #ne Nick $nick added to notify list. } { #err Nick $nick is already in notify list. @ notify_check = [$concat($nick $notify_check)] if ([$nickmask]) { @ notify_added = [$concat(${nick}[${usermask}] $notify_added)] ^assign -nickmask } { @ notify_added = [$concat($nick $notify_added)] } } } ^assign -nickidx ^assign -nick } # show masks, if any, for nickname $0 (format !Nick) alias notify_show_nickmasks { ^assign nick $strip(! $0) if (match($nick $notify_list)) { if ([$notify_masks[$nick]]) { ne Masks for $nick: $notify_masks[$nick] } { ne No masks for $nick (matching *@*). } } { err Nick $nick not in notify list. } ^assign -nick } # show all nicks with masks alias notify_show_allmasks { ne Nicknames with masks defined in notify list: foreach notify_masks currnick { ne $word(${match($currnick $notify_list) - 1} $notify_list): $notify_masks[$currnick] } ^assign -currnick } # main notify alias alias notify { if ([$0]) { if (([$0]==[-])||([$0]==[+])||([$0]==[!])) { if ([$0]==[-]) { notify_clear } { if ([$0]==[+]) { ne Currently present: $notify_present } { notify_show_allmasks } } ^assign notify_check - } { if ([$[1]0]==[-]) { notify_remove $0 } { if ([$[1]0]!=[!]) { notify_add $0 } { notify_show_nickmasks $0 } } @ notify_check = [$concat(- $notify_check)] } # Due to MAX RECURSION COUNT == 10, this has to be done like this: ^assign notify_args $1- if ([8]>[$#notify_args]) { #echo ??? Debug: less than 8: $1- ^assign -notify_args notify $1- } { #echo ??? Debug: more than 7: $1-8, $9- ^assign -notify_args notify $1-8 timer 3 notify $9- } } { # notify_check == - means that something was done, don't display lists if ([$notify_check]) { if (match(- $notify_check)) { @ notify_check = [$sdel(- $notify_check)] } if (match(+ $notify_check)) { @ notify_check = [$sdel(+ $notify_check)] } if ([$notify_check]) { notify_ison_force $notify_check ^assign -notify_check } } { #ne Notify list: $notify_list if ([$notify_list]) { ne Currently present: $notify_present ne Currently absent: $notify_absent } { ne The notify list is empty. } } } } # check those who are online (parse the userhost output) alias notify_parse_userhost { #echo ??? notify_parse_userhost \($0\) if (match($0 $notify_list)) { if ((([$notify_masks[$0]]==[])||(rmatch($3@$4 $notify_masks[$0])))&&([$3@$4]!=[@)) { ^assign nick $0 if ([$1]==[+]) {@ nick = [$nick] ## [*]} if ([$2]==[+]) {@ nick = [\(] ## [$nick] ## [\)]} #echo ??? notify_parse_userhost: 2 if (match($0 $notify_online)) { if (match($^*nick $notify_present)) { # then the status has not changed } { if ([$2]==[-]) { #xecho -level crap ??? notify_parse_userhost: back? $0 if (match(\($0\) $notify_present)||match(\($0\*\) $notify_present)) { hook notify return $0- } } { #xecho -level crap ??? notify_parse_userhost: away? $0 if (match($0 $notify_present)||match($0\* $notify_present)) { hook notify away $0- } } notify_remove_present $0 @ notify_present = [$concat($nick $notify_present)] } } { if ([$word(0 $notify_active)]!=[SILENT]) { hook notify signon $0- } @ notify_online = [$concat($0 $notify_online)] @ notify_present = [$concat($nick $notify_present)] if (match($0 $notify_absent)) { @ notify_absent = [$sdel($0 $notify_absent)] } # else we just added them and they were online } } { # nick didn't match any mask in notify_masks[nick] @ notify_ison = [$sdel($0 $notify_ison)] } } if ([$0]==[$notify_lastnick]) { hook notify noton ^assign -notify_lastnick } } # removes $0 from $notify_present alias notify_remove_present { if (match($0 $notify_present)) { @ notify_present = [$sdel($0 $notify_present)] } { if (match(\($0\) $notify_present)) { @ notify_present = [$sdel(\($0\) $notify_present)] } { if (match($0\* $notify_present)) { @ notify_present = [$sdel($0\* $notify_present)] } { if (match(\($0\*\) $notify_present)) { @ notify_present = [$sdel(\($0\*\) $notify_present)] } { err Error in notify_remove_present: could not remove $0 from \$notify_present } } } } } # re-check the current notify list alias notify_check_list { if ([$notify_list]) { notify_ison $notify_list } } # check a nick if it appears in the notify list, used with joins, signoffs, etc. alias notify_check_nick { if (match($0 $notify_list)) { notify_ison $0- } } # quiet check, don't show changes but update present/absent lists alias notify_check_quiet { if (match($0 $notify_list)) { ^assign notify_type SILENT notify_ison $0- } } # remove current notify handler alias notify_kill_handler if ([$notify_active]) { ^assign -notify_active ^assign -notify_noton ^assign -notify_ison ^assign -notify_check ^assign -notify_type ^on hook -"notify ison" ^on hook -"notify noton" } # remove a delayed notify handler if still active # needs activation time as a parameter alias notify_terminate_handler if ([$word(1 $notify_active)]==[$0]) { ^assign -notify_active ^assign -notify_noton ^assign -notify_ison ^assign -notify_check ^assign -notify_type ^on hook -"notify ison" ^on hook -"notify noton" } # find out who left alias notify_noton { #echo ??? notify_noton \($0-\) #echo ??? notify_noton: online: $notify_online ^on hook -"notify noton" # here should be figured out who _left_ # $notify_ison has list of nicks on, $0- list of nicks checked, # $notify_online has previously online nicks, # $notify_absent previously absent nicks # first create $notify_noton @ notify_noton = [$0-] @ noton_count = [0] #echo ??? notify_noton: ison= $notify_ison while ([$noton_count]<[$#notify_ison]) { @ notify_noton = [$sdel($word($noton_count $notify_ison) $notify_noton)] @ noton_count = noton_count + 1 } #echo ??? notify_noton: noton= $notify_noton @ noton_count = [0] while ([$noton_count]<[$#notify_noton]) { ^assign currnoton $word($noton_count $notify_noton) #echo ??? notify_noton: checking $currnoton if (match($currnoton $notify_list)) { if (match($currnoton $notify_absent)) { # then they were and still are absent #echo ??? notify_noton: already absent $currnoton } { if (match($currnoton $notify_online)) { # Then they must've left if ([$word(0 $notify_active)]!=[SILENT]) { hook notify signoff $currnoton } @ notify_online = [$sdel($currnoton $notify_online)] notify_remove_present $currnoton } #{echo ??? notify_noton: adding absent $currnoton} @ notify_absent = [$concat($currnoton $notify_absent)] #echo ??? notify_noton: 2 } } @ noton_count = noton_count + 1 } ^assign -currnoton ^assign -noton_count ^assign -notify_noton ^assign -notify_ison ^assign -notify_check ^assign -notify_type ^assign -notify_active #timer -delete ${ANOTIFY_SNO} #echo ??? notify_noton: removed notify_kill_handler timer hook notify ison } # "activate" notify, issue the ison call alias notify_ison { #echo ??? notify_ison if (![$notify_active]) { ^on hook -"notify ison" if (![$notify_type]) { # default is ON ^assign notify_active ON $time() } { # SILENT check uses this ^assign notify_active $notify_type $time() } ^assign notify_check $0-19 if ([$20]) { eval ^on ^hook "notify ison" notify_ison $20- } eval ^on ^hook "notify noton" notify_noton $0-19 timer $ANOTIFY_BATCH notify_terminate_handler $word(1 $notify_active) ${K}${K}ison $0-19 } { # else a previous notify check batch is still active # re-submit and hope for the best.. # (this has to be one line.. *sigh*) eval timer 5 if (![$notify_active]) \{notify_ison $0-\} \{timer 10 if (![$notify_active]) \{notify_ison $0-\}\} # else just discard this, and hope a latter check catches any # changes. Some nicks might not ever get checked, but better # that than have 987 timers running and bogging the client # down. The list is just too long in that case, or the # connection too lagged. } } # same as notify_ison, but if already doing a notify call, keep trying # later - don't "drop" batches # Using this is potentially dangerous, as if the connection is very # lagged this could result in the delayed batch looping over and over # again. alias notify_ison_force { #echo ??? notify_ison_force if (![$notify_active]) { ^on hook -"notify ison" if (![$notify_type]) { # default is ON ^assign notify_active ON $time() } { # SILENT check uses this ^assign notify_active $notify_type $time() } ^assign notify_check $0-19 if ([$20]) { eval ^on ^hook "notify ison" notify_ison $20- } eval ^on ^hook "notify noton" notify_noton $0-19 timer $ANOTIFY_BATCH notify_terminate_handler $word(1 $notify_active) ${K}${K}ison $0-19 } { # else a previous notify check batch is still active # re-submit and hope for the best.. timer 5 notify_ison_force $0- } } alias notify_silent_ison { if (![$notify_active]) { ^on hook -"notify ison" ^assign notify_active SILENT $time() ^assign notify_check $0-19 if ([$20]) { eval ^on ^hook "notify ison" notify_ison $20- } eval ^on ^hook "notify noton" notify_noton $0-19 timer $ANOTIFY_BATCH notify_terminate_handler $word(1 $notify_active) ${K}${K}ison $0-19 } { # else a previous notify check batch is still active # re-submit and hope for the best.. eval timer 15 if (![$notify_active]) \{notify_ison $0-\} # else just discard this, and hope a latter check catches any # changes. Some nicks might not ever get checked, but better # that than have 987 timers running and bogging the client # down. The list is just too long in that case. } } alias notify_parse_on { #echo ??? notify_parse_on: $0- @ notify_ison = [$notify_ison] ## [$0-9 ] if ([$10]) { ${K}${K}userhost $0-9 -cmd notify_parse_userhost $$* timer 2 notify_parse_on $10- } { if ([$0]) { #wait -cmd timer 1 hook notify noton ^assign notify_lastnick $~ #echo ??? notify_parse_on: trigger at nick $~ userhost $0- -cmd notify_parse_userhost $$* } { timer 1 hook notify noton } } #echo ??? on 303 (ison): hooking notify_noton } # Debug: #on #^hook 2 "notify *" echo ??? notify: "$1-" # Install the notify functions so they'll actually notice when something # happens. # the ison output handler on ^303 * if ([$notify_active]) { notify_parse_on $0- } { ne Currently online: $0- } # check the list every minute on #^timer 667 * notify_check_list # Check when seeing signoff # signoff eval on #^signoff $ANOTIFY_SNO * { notify_check_nick $0 } # channel signoff eval on #^channel_signoff $ANOTIFY_SNO * { notify_check_nick $0 } # no such nick eval on #^401 $ANOTIFY_SNO * { notify_check_nick $1 } # Check when seeing someone online # whois eval on #^311 $ANOTIFY_SNO * {notify_check_nick $1} # msg eval on #^msg $ANOTIFY_SNO * {notify_check_nick $1} eval on #^action $ANOTIFY_SNO * {notify_check_nick $0} # notice eval on #^join $ANOTIFY_SNO * {notify_check_nick $0} # quietly update list on nick changes eval on #^nick $ANOTIFY_SNO * {notify_check_quiet $0 $1} ne Advanced notify by Wizzu loaded (20 Aug 1996). BETA