Dictionary.info.dawg0100644000076400010010000000017107503563570015265 0ustar AdministratorNoneInformation: This script connects to any RFC-2229 compliant dictionary server and shows you the definition of a word.Dictionary1.0.tcl0100644000076400010010000001436707503765710014426 0ustar AdministratorNone################################## ### Dictionary.tcl ### ### Version 1.0 ### ### By Wcc ### ### wcc@techmonkeys.org ### ### http://www.dawgtcl.com:81/ ### ### EFnet #|DAWG|Tcl ### ################################## ############################################################################ ### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ### ############################################################################ ################################################################################ ## This script connects to any RFC-2229 compliant dictionary server and shows ## ## you the definition of a word. ## ################################################################################ ############## ## COMMANDS ## ############################################ ## DCC ## .define (Can be changed) ## ######### Defines a word. ## ############################################ ## PUB ## !define (Can be changed) ## ######### Defines a word. ## ############################################ ########################################################## ## Just load the script, edit the settings, and rehash. ## ########################################################## ############################# # Set the dcc command here. # ############################# set dictionary_setting(cmd_d) "define" ############################# # Set the pub command here. # ############################# set dictionary_setting(cmd_p) "!define" ################################################# # Set the flag required to use the script here. # ################################################# set dictionary_setting(flag) "-|-" ###################################################################### # Set the dictionary server here. This must be an RFC-2229 compliant # # dictionary server. The format is :. # ###################################################################### set dictionary_setting(server) "dict.org:2628" ################################################################# # Set the timeout for connecting to the dictionary server here. # ################################################################# set dictionary_setting(timeout) "15" ################################### # Enable use of bold in dcc chat? # ################################### set dictionary_setting(bold) 1 ############################################## # Prefix "DICTIONARY:" in dcc chat messages? # ############################################## set dictionary_setting(DICTIONARY:) 1 #################### # Code begins here # #################### if {![string match 1.6.* $version]} { putlog "\002DICTIONARY:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." } if {[info tclversion] < 8.2} { putlog "\002DICTIONARY:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." } bind dcc $dictionary_setting(flag) $dictionary_setting(cmd_d) dictionary_dcc bind pub $dictionary_setting(flag) $dictionary_setting(cmd_p) dictionary_pub proc dictionary_dopre {} { if {!$::dictionary_setting(DICTIONARY:)} { return "" } if {!$::dictionary_setting(bold)} { return "DICTIONARY: " } return "\002DICTIONARY:\002 " } proc dictionary_dcc {hand idx text} { if {[string compare [set word [lrange [split $text] 0 0]] ""] == 0} { putdcc $idx "[dictionary_dopre]Usage: .$::dictionary_setting(cmd_d) " ; return } dictionary_connect 0 $idx $word } proc dictionary_pub {nick uhost hand chan text} { if {[string compare [set word [lrange [split $text] 0 0]] ""] == 0} { putserv "NOTICE $nick :Usage: .$::dictionary_setting(cmd_p) " ; return } dictionary_connect 1 $chan $word } proc dictionary_out {type dest text} { if {!$type} { putdcc $dest "[dictionary_dopre]$text" ; return } putserv "PRIVMSG $dest :$text" } proc dictionary_connect {type dest word} { if {[catch {socket -async [lindex [split $::dictionary_setting(server) :] 0] [lindex [split $::dictionary_setting(server) :] 1]} sock]} { dictionary_out $type $dest "Connection to $::dictionary_setting(server) failed." ; return } fileevent $sock writable [list dictionary_write $type $dest $word $sock [utimer $::dictionary_setting(timeout) [list dictionary_timeout $type $dest $sock]]] } proc dictionary_write {type dest word sock timerid} { if {[set error [fconfigure $sock -error]] != ""} { dictionary_out $type $dest "Connection to $::dictionary_setting(server) failed." catch { close $sock } catch { killutimer $timerid } return } puts $sock "DEFINE * \"$word\"" flush $sock fconfigure $sock -blocking 0 fileevent $sock readable [list dictionary_read $type $dest $word $sock $timerid] fileevent $sock writable {} } proc dictionary_read {type dest word sock timerid} { while {![set error [catch {gets $sock output} read]] && $read > 0} { switch -regexp -- [set key [join [lrange [split $output] 0 0]]] { "151" { dictionary_out $type $dest [join [lrange [split $output] 1 end]] } "\\.|250" { dictionary_out $type $dest "End of definition." catch { close $sock } catch { killutimer $timerid } break } "550" { dictionary_out $type $dest "Error: Invalid database." catch { close $sock } catch { killutimer $timerid } break } "551" { dictionary_out $type $dest "Error: Syntax error." catch { close $sock } catch { killutimer $timerid } break } "552" { dictionary_out $type $dest "Error: $word could not be found." catch { close $sock } catch { killutimer $timerid } break } default { if {![regexp "150|220" $key]} { dictionary_out $type $dest [join [lrange [split $output] 1 end]] } } } } if {$error} { dictionary_out $type $dest "Error: Connection to server has been lost." catch { close $sock } catch { killutimer $timerid } } } proc dictionary_timeout {type dest sock} { catch { close $sock } dictionary_out $type $dest "Connection to $::dictionary_setting(server) timed out." } putlog "\002DICTIONARY:\002 Dictionary.tcl Version 1.0 by Wcc is loaded."