### ### vim:ts=8 ai si sw=4 sta sm: ### $Id: spacekey,v 1.3 2003/12/05 12:51:39 sec Exp sec $ ### it's like tabkey, but for 'nick:' on channels ### # requires: ^u erase_line; ^a bginning_of_line; ^e end_of_line # words(); notword(); substword() # warning: re-aliases /msg # This script uses SERIAL NUMBER #66 alias sk.help { echo *** The spacekey script - it's like tabkey, but for "nick:" on channels echo *** ^@ (Ctrl-Space) - cycle forward through list of nicknames echo *** ^[-^@ (Esc - Ctr-Space) - remove current nick from list echo *** echo *** Features include: echo *** + Nicks get deleted on /leave echo *** + Nicks get added on every line which contains your nick echo *** + Nickchanges are tracked echo *** echo *** /sk.nicklist [channel] - list all nicknames (on channel) echo *** /sk.addnick nick [channel] - add one nick echo *** \$sk.msgmax - max number of nicks to store \($sk.msgmax\) } eval if (!match(%+sk% $script_info)){ assign script_info $script_info+sk };set client_info Sec$script_info # spacekey, Original idea by Valentin!val@daim.wuggi.muc.de # this implementation by Sec!sec@42.org # searches thru list forwards (ctrl-space) or delete ^[-^@ bind ^@ parse_command ^sk.getmsg 1 $(sk.chanlist.$encode($tolower($C))) bind meta1-^@ parse_command sk.delnick # shows all the current nicknames in the list. alias sk.nicklist { if ([$0]){ echo *** Nickname List for $0: $(sk.chanlist.$encode($tolower($0))) }{ echo *** Nickname List for $C: $(sk.chanlist.$encode($tolower($C))) } } # Adds nicknames to the list.. alias sk.addnick { if ([$1]){ sk.addmsg $1 $0 $(sk.chanlist.$encode($tolower($1))) }{ sk.addmsg $C $0 $(sk.chanlist.$encode($tolower($C))) } } # Set this to the max number of nickname you want on the list at a time @ sk.msgmax = 5 # From here down are internal aliases and 'ON's. # keeps list of unique nicks from newest message to oldest message. alias sk.addmsg { @ sk.matched = rmatch($1 $^\2-) if (sk.matched) { @ sk.chanlist.$encode($tolower($0)) = [$(1-${sk.matched}) $(${sk.matched+2}-)] }{ @ sk.chanlist.$encode($tolower($0)) = [$(1-$sk.msgmax)] } eval ^assign sk.msgcnt.$encode($tolower($0)) 0 ^assign -sk.matched } # searches thru list forwards or backwards. ($0==1==forward),($0==-1==back) alias sk.getmsg { if (([$words(1 $L)] == [/msg])||([$words(1 $L)] == [/describe])){ ; }{ eval ^assign sk.msgcnt $(sk.msgcnt.$encode($tolower($C))) @ sk.msgcnt = sk.msgcnt + [$0] eval ^assign sk.amount $(#sk.chanlist.$encode($tolower($C))) if (sk.amount < sk.msgcnt) {@ sk.msgcnt = 1} if (sk.msgcnt <= 0) {@ sk.msgcnt = sk.amount } if (sk.amount > 0) { if ([$right(1 $word(0 $L))] == [:]){ type $($sk.msgcnt): $words(2- $L) }{ type $($sk.msgcnt):  } } eval ^assign sk.msgcnt.$encode($tolower($C)) $sk.msgcnt } } # Adds nick to list when message is sent or received. Doesn't effect output. eval on #-public 66 "% * *$N*" ^sk.addnick $$0 $$1 eval on #-action 66 "% * *$N*" ^sk.addnick $$0 $$1 on #-send_public 66 "% %: *" { ^sk.addmsg $0 $strip(: $1) $(sk.chanlist.$encode($tolower($C))) } on #-leave 66 "* *" { if ([$0] == [$N]) { eval assign -sk.chanlist.$encode($tolower($1)) }{ @ sk.chanlist.$encode($tolower($1)) = [$notword($match($0 $(sk.chanlist.$encode($tolower($1)))) $(sk.chanlist.$encode($tolower($1))))] } } on #-channel_nick 55 * { @ sk.chanlist.$encode($tolower($0)) = substword($match($1 $(sk.chanlist.$encode($tolower($0)))) $2 $(sk.chanlist.$encode($tolower($0)))) } # deletes current nick from list alias sk.delnick { eval ^assign sk.msgcnt $(sk.msgcnt.$encode($tolower($C))) if (sk.msgcnt == 0) { @ sk.msgcnt = 1 } echo *** Nickname for $C: $word(${sk.msgcnt-1} $(sk.chanlist.$encode($tolower($C)))) removed. @ sk.chanlist.$encode($tolower($C)) = [$notword($sk.msgcnt $(sk.chanlist.$encode($tolower($C))))] type ^U eval ^assign sk.msgcnt.$encode($tolower($C)) $sk.msgcnt } # The $notword() function. alias notword { if ([$0] > 0) { if (([$0] > 1) && ([$0] < rmatch($~ $1-))) { @ nw.sep = [ ] } { @ nw.sep = [] } @ function_return = [$(1-${[$0]-1})] ## [$nw.sep] ## [$(${[$0]+1}-)] } { @ function_return = [$1-] } } # The $words() function. alias words ^assign function_return $($0) alias substword { if ([$0] > 0) { if ([$0] > 1) { @ nw.sep1 = [ ] }{ @ nw.sep1 = [] } if ([$0] < rmatch($~ $2-)){ @ nw.sep2 = [ ] }{ @ nw.sep2 = [] } @ function_return = [$(2-${[$0]})] ## [$nw.sep1] ## [$1] ## [$nw.sep2] ## [$(${[$0]+2}-)] }{ @ function_return = [$2-] } }