;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MODEEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;info: ; ; by wiebe @ QuakeNet ; version 1.0 (written and tested on mIRC 6.14) ; ; ; last edit: Sun Feb 29 2004 ; ; ;What does this script do? ; ; gets the channel modes and channel creation time and sends this to an alias ; ; ;How to use this script? ; ; /modeexec [-p] [params] ; to request the channel modes and creation time for channel and send the info to alias ; ; the script sends the following things to the alias: ; ; ; channel, from where the topic is ; ctime, when the topic was set ; modes, the channel modes set on the channel ; ; No such channel ; this means the channel does not exist ; ; the -p switch (passive) adds the channel with the alias, but does not make the script request the mode ; usefull in combination with a join event, where the server sends the modes ; ; WARNING: DO NOT USE HALT IN AN ALIAS, USE RETURN! ; halt also halts the calling alias/event, return only stops the current alias ; and gives control back to the calling alias/event ; using halt in alias'es that are called from this script can cause it not to work 100% ; ; example at end of script ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS MODEEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; /modeexec [params..] alias modeexec { ; on irc if ($status == connected) { ; set var !var %p ; called as identifier, on channel $1, something in hash table if ($isid) && ($me ison $1) && ($hget($+(modeexec.,$cid,.save),$modeexec.lower($1))) { ; return !return $ifmatch } ; switch is used if ($1 == -p) { ; set var !var %p = 1 ; tokenize !tokenize 32 $2- } ; $2 is there, and $1 is a valid channel if ($2) && ($left($1,1) isin $chantypes) { ; add to hash table !hadd -m $+(modeexec.,$cid) $modeexec.lower($1) $1- ; check var if (!%p) { ; request mode !mode $1 } } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 324 CHANNEL MODES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 324 me channel modes raw 324:& & *: { ; check hash table if ($hfind($+(modeexec.,$cid),$modeexec.lower($2),0)) { ; add to hash table !hadd -m $+(modeexec.,$cid,.mode) $modeexec.lower($2) $3- ; stop raw !haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 329 CHANNEL CTIME ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 329 me channel time raw 329:& & &: { ; set var !var %chan = $modeexec.lower($2) ; check hash table if ($hfind($+(modeexec.,$cid),%chan,0)) { ; loop while ($hfind($+(modeexec.,$cid),%chan,1)) { ; set var !var %t = $hget($+(modeexec.,$cid),$hfind($+(modeexec.,$cid),%chan,1)) ; run alias with the info $gettok(%t,2-,32) $gettok(%t,1,32) $3 $hget($+(modeexec.,$cid,.mode),%chan) ; remove from hash table !hdel $+(modeexec.,$cid) $hfind($+(modeexec.,$cid),%chan,1) ; check if hash table is empty if ($hget($+(modeexec.,$cid),0).item == 0) { ; free hash table !hfree $+(modeexec.,$cid) } ; remove from hash table !hdel $+(modeexec.,$cid,.mode) %chan ; check if hash table is empty if ($hget($+(modeexec.,$cid,.mode),0).item == 0) { ; free hash table !hfree $+(modeexec.,$cid,.mode) } } ; stop raw !haltdef } ; on channel $2 if ($me ison $2) { ; save info in hash table !hadd -m $+(modeexec.,$cid,.save) %chan $3 } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 403 NO SUCH CHANNEL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 403 me chan :No such channel raw 403:& & No such channel:{ ; set var !var %chan = $modeexec.lower($2) ; check hash table if ($hfind($+(modeexec.,$cid),%chan,0)) { ; loop while ($hfind($+(modeexec.,$cid),%chan,1)) { ; set var !var %t = $hget($+(modeexec.,$cid),$hfind($+(modeexec.,$cid),%chan,1)) ; run alias with info $gettok(%t,2-,32) $gettok(%t,1,32) $3- ; remove from hash table !hdel $+(modeexec.,$cid) $hfind($+(modeexec.,$cid),%chan,1) ; check if hash table is empty if ($hget($+(modeexec.,$cid),0).item == 0) { ; free hash table !hfree $+(modeexec.,$cid) } } ; stop raw !haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS MODEEXEC.LOWER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $modeexec.lower(nick/chan) alias -l modeexec.lower { ; on IRC these chars are upper(lower) case of eachother: { = [, } = ], | = \, ~ = ^ ; so here we replace them to make sure we compare the right things right !return $replace($1,$chr(123),$chr(91),$chr(125),$chr(93),$chr(124),$chr(92),$chr(126),$chr(94)) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:disconnect:{ if ($hget($+(modeexec.,$cid)) != $null) { !hfree $+(modeexec.,$cid) } if ($hget($+(modeexec.,$cid,.mode)) != $null) { !hfree $+(modeexec.,$cid,.mode) } if ($hget($+(modeexec.,$cid,.save)) != $null) { !hfree $+(modeexec.,$cid,.save) } } ; example script on *:text:!mode &:#channel:{ modeexec $2 modepub $chan } alias -l modepub { if ($3- == No such channel) { !msg $1 $2- } else { !msg $1 channel $2 was created on $asctime($3) $+ , modes: $4- } } on *:join:#:{ if ($nick == $me) { modeexec -p $chan showmode } } ; chan ctime modes alias -l showmode { if ($me ison $1) { !echo $color(mode) -t $1 * Created $asctime($2,ddd dd mmm yyyy) ( $+ $gettok($duration($calc($ctime - $2)),1-2,32) ago) modes: $3- } } alias cmode { if ($chan) { if (!$1) { modeexec $chan showmode } else { !mode $chan $1- } } } on *:op:#:{ if ($opnick == $me) && (($chan($chan).mode == $null) || ((k isincs $gettok($chan($chan).mode,1,32)) && ($chan($chan).key == $null))) { modeexec -p $chan showmode } }