#version 0.1.4 /* * dict.dsm - Dictionary module for Darkstar/EPIC4 * * Written by Joshua Hamor * Copyright (c) 2002 Joshua Hamor * See the 'COPYRIGHT' file for more information. * * This script is intended to interface dict.org to darkstar. */ /* Configuration */ config.add DICT_HOST dict.org config.add DICT_PORT 2628 /* Force the loading of saved settings */ module.load_saved_settings queue cleanup.dict { for ii in (110 111 150 151 220 221 250 550 552) { ^on dcc_raw -'% \$CONFIG.DICT_HOST D $ii *' } for ii in (C D E) { ^on dcc_raw -'% \$CONFIG.DICT_HOST $ii *' } for ii in (A) { ^on -dcc_lost -'% RAW \$CONFIG.DICT_HOST' } } alias dict { if (![$0]) { xecho -b -- Usage: xecho -b -- /dict [-d ] xecho -b -- /dict [-d ] -match xecho -b -- /dict <-showdb|-showstrat> xecho -b -- xecho -b -- argument can be located using: -showdb xecho -b -- argument can be located using: -showstrat return } /* Set dictionary */ if (pattern($0* -dictionary)) { @ :dictionary = [$1] @ :args = [$2-] } else { @ :dictionary = [*] @ :args = [$*] } /* Connect to dictionary server */ @ :fd = connect($CONFIG.DICT_HOST $CONFIG.DICT_PORT) /* Process flags */ switch ($tolower($word(0 $args))) { /* Run a match search */ (-match) { @ :strat = tolower($word(1 $args)) @ dict.Word = word(2 $args) ^msg =$fd match $dictionary $strat $dict.Word } /* Show databses */ (-showdb) { ^msg =$fd show db } /* Show strategies */ (-showstrat) { ^msg =$fd show strat } /* Normal defination */ (*) { @ dict.Word = word(0 $args) ^msg =$fd define $dictionary $dict.Word } } /* End connection */ ^msg =$fd QUIT } /* Display the connection closure */ ^on ^dcc_lost '% RAW $CONFIG.DICT_HOST' { xecho -b -- [dict] Connection with $2 closed. } /* Display established connection */ ^on ^dcc_raw '% $CONFIG.DICT_HOST E *' { xecho -b -- [dict] Connection with $1 on port $3. } /* Display number of databases */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D 110 *' { xecho -b -- [dict] ----] $4 present databases. xecho -b -- [dict] --] } /* Display number of strategies */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D 111 *' { xecho -b -- [dict] ----] $4 present strategies. xecho -b -- [dict] --] } /* Display number of definations */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D 150 *' { xecho -b -- [dict] ----] $4 definitions displayed. xecho -b -- [dict] --] } /* Display dictionary which entry is from */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D 151 *' { @ :def = chop(1 $6-) @ :def.a = sar(/"/.:[/$def) @ :def.b = sar(/"/]:./$def.a) xecho -b -- [dict] --] $def.b xecho -b -- [dict] --] } /* Remove misc output */ ^on ^dcc_raw '% $CONFIG.DICT_HOST C *' { # } ^on ^dcc_raw '% $CONFIG.DICT_HOST D 220 *' { # } ^on ^dcc_raw '% $CONFIG.DICT_HOST D 221 *' { # } ^on ^dcc_raw '% $CONFIG.DICT_HOST D 250 *' { # } /* Display dictionary not found */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D 550 *' { xecho -b -- [dict] --] Invalid dictionary. } /* Display word not found */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D 552 *' { xecho -b -- [dict] --] No matches for \"$dict.Word\" found. } /* Display addition defination */ ^on ^dcc_raw '% $CONFIG.DICT_HOST D *' { @ :def = chop(1 $3-) /* Dont display periods */ if ([$3] == [.]) { xecho -b -- [dict] --] } else { xecho -b -- [dict] --] $def } } /* EOF */