#### Nick completion script (Active Nicks 1.1) #### (c) by [Serge], 2005-2006 #### mailto: coder[at]tools-for[dot]net # - Inserts nick in the input field by single click # on the nick in any place of the chat window # # - The same by double click in the nicklist # # - Replaces nick in the input field by subsequent # clicks on different nicks # # - You can first type text and then click on the nick, # the text will be prepended by the nickname # # - To open query click on the nick to complete # it, then click again (or double click again in the nicklist) # # Format is configured below (default is "NICKNAME: text"): $FORMAT_SPEC = "NICKNAME $+ : "; ### Don't touch anything below this line ### sub format_text { return strrep($FORMAT_SPEC, "NICKNAME", $1); } sub is_completed { $cnick = format_text($1); $curtext = getInputText(getCurrentWindow()); if($cnick isin $curtext){ return 1; } else { return 0; } } sub process_dclick { if(is_completed($1)) { $curtext = getInputText(getCurrentWindow()); $curtext = uncomplete_nick($curtext, $1); setInputText(getCurrentWindow(), $curtext); call("/window $1"); } else { complete_nick($1); halt; } } on dclick { process_dclick($0); halt; } on click { @users = getUsers(getCurrentWindow()); foreach $user (@users) { if($user isin $0 && ((strlen("$0") - strlen("$user")) < 3)){ if ($clicks == 1) { complete_nick($user); } else if ($clicks == 2) { process_dclick($user); } break; } } } sub uncomplete_nick { return strrep($1, format_text($2), ''); } sub complete_nick { if(is_completed($1)) { return; } @users = getUsers(getCurrentWindow()); foreach $user (@users) { $curtext = uncomplete_nick($curtext, $user); } $newtext = format_text($1) . $curtext; setInputText(getCurrentWindow(), $newtext); }