!Define — File Browser
Definev2.3 / Definev2.3 / Define / Define.mrc
Define.mrc — 7.5 KB — Download this file
;======= !Define 2.3 =======
;===========================
; A script to define
; a word using dict.org
; using a channel trigger
;---------------------------
; by: MaxP
; e-mail: FSAVoice@hotmail.com
;===========================
; To load type this at a command line: /load -rs <directory>\Define.mrc
; Channel trigger: !define <word>
; Alias: /define <word>
on *:LOAD:{
if (!$isdir(dictonary_files)) { mkdir dictonary_files }
if (!$r.dic($ns,settings,AllChan)) { w.dic $ns settings AllChan on }
var %n = 1
var %c = $chan(0)
while (%n <= %c) {
w.dic $ns Channel $chan(%n) $r.dic($ns,settings,AllChan)
inc %n
}
if ($isfile($shortfn($scriptdir) $+ readme.txt)) { run NOTEPAD.EXE $shortfn($scriptdir) $+ readme.txt }
}
alias df { return $iif(!$isdir(dictonary_files),$shortfn($scriptdir),dictonary_files\) }
menu channel,menubar,status {
-
Dictionary
.Define:{ var %word = $$?="Enter word to look up." | dict.doSearch $me %word }
.-
.$ns Trigger ( $+ $iif($r.dic($ns,settings,AllChan) == on,ON,OFF) $+ ):{
w.dic $ns settings AllChan $iif($r.dic($ns,settings,AllChan) == on,off,on)
echo -a '!Define' trigger for $ns was turned $iif($r.dic($ns,settings,AllChan) == on,ON,OFF)
}
.$iif($menu == channel,$chan Trigger ( $+ $iif($r.dic($ns,Channel,$chan) == on,ON,OFF) $+ )):{
w.dic $ns Channel $chan $iif($r.dic($ns,Channel,$chan) == on,off,on)
echo -a '!Define' trigger for $chan on $ns was turned $iif($r.dic($ns,Channel,$chan) == on,ON,OFF)
}
.-
.unload:{ unload -rs $script }
}
on *:CONNECT:{ if (!$r.dic($ns,settings,AllChan)) { w.dic $ns settings AllChan on } }
on *:JOIN:#:{ if ($nick == $me) { if (!$r.dic($ns,Channel,$chan)) { w.dic $ns Channel $chan $r.dic($ns,settings,AllChan) } } }
on *:TEXT:!define*:#:{
if (($r.dic($ns,settings,AllChan) != on) || ($r.dic($ns,Channel,$chan) != on)) { return }
dict.doSearch $nick $2-
}
alias dict.doSearch {
if ($sock(dict)) { $iif($1 == $me,echo -a,notice $1) Already processing a search please wait a minute and try again | return }
set %dict.m dic $+ $gmt
set %dict.nik $1
set %dict.trm $2-
set %dict.n 1
if ($sock(dict).status == active) || ($sock(dict).status == connecting) { sockclose dict | sockopen dict dict.org 2628 }
else { sockopen dict dict.org 2628 }
}
alias -l r.dic { if ($3 != $null) { return $readini -n $df $+ $+ $1 $+ .ini $2 $3 } }
alias -l w.dic { if ($4 != $null) { writeini -n $df $+ $+ $1 $+ .ini $2 $3 $4- } }
alias define { dict.doSearch $me $1- }
;I found this neat alias, its coded a little better then the one I came up with originally.
alias -l D.rem.insider {
if ($1) {
var %strip,%parm = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
while ($gettok($gettok(%parm,%n,62),1,60)) {
%strip = %strip $ifmatch
inc %n
}
return %strip
}
return $null
}
alias -l sym.pharse {
var %txt1 = $1-
var %toks = $numtok(%txt1,32)
var %n1 = 1
while (%n1 <= %toks) {
var %tok = $gettok(%txt1,%n1,32)
if (($+($chr(38),$chr(35)) isin %tok) && ($chr(59) isin %tok)) {
var %tok = $replace(%tok,&#,$chr(32) $+ $chr(36) $+ chr $+ $chr(40),;,$chr(41))
var %tok = $eval( [ %tok ] )
}
var %txt2 = %txt2 $+ $chr(32) $+ %tok
inc %n1
}
return %txt2
}
on *:sockopen:dict:{
if ($sockerr > 0) {
Q.msg -a %dict.nik Unable to connect to dict server!
sockclose dict | if (%dict.nik != $me) { Q.msg -s %dict.nik }
halt
}
}
on *:sockread:dict:{
unset %itsnext
if ($sockerr > 0) { halt }
:1
sockread %tmp
if (%tmp == $null) { halt }
if ($sockbr == 0) { return }
if ($left(%tmp,3) == 220) { .sockwrite -n dict DEFINE * " $+ %dict.trm $+ " | halt }
if ($left(%tmp,3) == 150) { .write -c $shortfn($scriptdir) $+ dict.txt $+ $gettok(%tmp,2,32) Results found for %dict.trm $+ : | halt }
if ($left(%tmp,3) == 552) { dict.msg Error: no information found on %dict.trm , check your spelling. | goto 3 }
if ($left(%tmp,3) == 500) { dict.msg Error: Syntax error, command not recognized (dict.org) | goto 3 }
if ($left(%tmp,3) == 501) { dict.msg Error: Syntax error, illegal parameters (dict.org) | goto 3 }
if ($left(%tmp,3) == 502) { dict.msg Error: Command not implemented (dict.org) | goto 3 }
if ($left(%tmp,3) == 503) { dict.msg Error: Command parameter not implemented (dict.org) | goto 3 }
if ($left(%tmp,3) == 420) { dict.msg Error: Server temporarily unavailable (dict.org) | goto 3 }
if ($left(%tmp,3) == 421) { dict.msg Error: Server shutting down at operator request (dict.org) | goto 3 }
if ($left(%tmp,3) == 151) { write $shortfn($scriptdir) $+ dict.txt $+ %dict.n $+ ) " $+ $gettok(%tmp,4,34) $+ " | inc %Dict.n | halt }
if ($left(%tmp,3) == 250) { pharse2 | goto 3 }
else { write $shortfn($scriptdir) $+ dict.txt $str($chr(160),4) $replace(%tmp,$chr(123),,$chr(125),,%dict.trm, $+ %dict.trm $+ ,[,[,],],,$chr(32)) }
:2
if ($sockbr) { goto 1 }
return
:3 | sockclose dict | if (%dict.nik != $me) { Q.msg -s %dict.nik }
}
alias -l dict.msg {
if (%dict.nik == $me) { echo -a $1- }
else { Q.msg -a %dict.nik $1- }
}
alias -l pharse2 {
var %n = 1 | var %l = $lines($shortfn($scriptdir) $+ dict.txt)
while (%n <= %l) { dict.msg $read($shortfn($scriptdir) $+ dict.txt,n,%n) | inc %n }
}
;;=========== Messaging ===============
;msg.ini
alias -l inif { return $df $+ $iif($1,$1,$ns) $+ _msg.ini }
alias -l n.ini { if ($1 != $null) { return $iif($1,$ini($inif,$1,0),$ini($inif,0)) } }
alias -l r.ini { if ($2 != $null) { return $replace($readini($inif,n,$1,$2),<b>,,<k>,) } }
alias -l w.ini { if ($2 != $null) { var %ini = $ini($inif,$1,0) | inc %ini | writeini -n $inif $1 %ini $replace($2-,,<b>,,<k>) } }
alias -l d.ini { if ($2 != $null) { remini -n $inif($1) $2 $iif($3,$3) } }
alias -l ns { return $iif($network,$network,$server) }
alias -l v { return [ [ $+(%,Q.,$1,.,$iif($network,$network,$server)) ] ] }
alias -l t { return $1 $+ . $+ $2 }
alias Q.msg {
if ($1 == -a) {
if (!$v($2)) {
if (!%rap) { set -u2 %rap 1 }
set $+(%,Q.,$2,.,$ns) Q. $+ $gmt $+ %rap
inc %rap
}
w.ini $v($2) $3-
}
elseif ($1 == -s) { Q.Send $2 }
}
alias Q.Send {
var %lines = $n.ini($v($1))
if (%lines > 5) {
notice $1 the information you requested is to long to message. Number of lines: ( $+ %lines $+ ). So I will atempt to DCC the information to you.
if (!$chat($1)) { dcc chat $1 | .timer [ $+ [ $network ] $+ . $+ [ $1 ] ] 1 20 Q.halt $ns $1 1 }
else { Q.chat $ns $1 }
}
else { var %m = 1 | while (%m <= %lines) { msg $1 $r.ini($1,%m) | inc %m } | d.ini $network $1 }
}
alias Q.halt {
d.ini $1 $v($2)
$Q.srv(-c,$1)
if ($3) { if ($window(= $+ $2)) { window -c = $+ $2 } }
unset $+(%,Q.,$2,.,$ns)
}
on *:OPEN:=:{ if ($n.ini($v($nick))) { Q.chat $ns $nick } }
alias Q.chat {
if ($timer($1 $+ . $+ $2)) { .timer [ $+ [ $1 ] $+ . $+ [ $2 ] ] off }
$Q.srv(-c,$1) | var %pos = $v($2), %lines = $n.ini(%pos), %m = 1
while (%m <= %lines) { msg = $+ $2 $r.ini(%pos,%m) | inc %m }
Q.halt $1 $2
}
on *:CLOSE:=:{ window -c = $+ $nick }
alias -l Q.srv {
var %n = 1
while ($scon(%n)) {
if (($scon(%n).$network == $2) || ($scon(%n).$server == $2)) {
if ($1 == -v) { return $iif($scon(%n).$status == connected,OK,NC) }
elseif ($1 == -c) { return scon %n }
}
inc %n
}
return NA
}
alias Q.test { var %l = 1 | while (%l <= $1) { Q.msg -a $2 %l | inc %l } | Q.msg -s $2 }