; DictIRC v1.0.3 by Riamus 2005 ; #OldGames on irc.undernet.org ; Dictionary Data from http://www.onelook.com/ ; ; The most common types of words (nouns, verbs, etc) have color settings ; that can be set up. Uncommon types like Definite Articles and Conjunctions ; do not have settings for colors and use a default dark grey color. If for ; some reason, anyone wants these to have color settings in the dialog, just ; let me know. If you just want to manually change them, do Ctrl-F and ; search for 14 ... change those to whatever color you want them to be. ; ; Note that depending on the search, this can easily flood a channel with many ; definitions. ; ; Use the flood protection if you don't want words with long definitions to ; fill your channel. Although you won't get all your definitions for each ; word, you may not want to see 36 definitions for a word like "go". ; ; Credits: Indenting idea thanks to XMog on irc.irchighway.net in #Invision. ctcp *:version:*: { .ctcpreply $nick version #SurrealHosting Dictionary' By coNNect aka u } menu * { - DictIRC Setup: dialog -m DictionarySetup DictionarySetup } on *:load:{ dialog -m DictionarySetup DictionarySetup } alias dictionarysock { set %word $replace($1-,$chr(32),+) sockopen dictionarysock www.onelook.com 80 } on *:sockopen:dictionarysock: { sockwrite -n $sockname GET /?w= $+ %word $+ &ls=a HTTP/1.0 sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) sockwrite -n $sockname Host: www.onelook.com sockwrite -n $sockname Accept-Language: en-us sockwrite -n $sockname Accept-Encoding: gzip, deflate sockwrite -n $sockname Accept: */* $+ $crlf $+ $crlf } on *:sockread:dictionarysock: { if ($sockerr) { echo -a Error. halt } else { var %temptext sockread %temptext if (*Quick definitions* iswm %temptext) { set %dictionary.word $htmlfree($gettok($gettok(%temptext,2,40),1,41)) } if (
  • * iswm %temptext) { inc %defcnt set %definitions [ $+ [ %defcnt ] ] $htmlfree(%temptext) } if (
  • $+ $chr(40) $+ * iswm %temptext) { inc %defcnt set %definitions [ $+ [ %defcnt ] ] $htmlfree(%temptext) } if (

    $+ %word $+ * iswm %temptext) { inc %defcnt set %definitions [ $+ [ %defcnt ] ] $gettok($htmlfree(%temptext),2-,32) } if (
    * iswm %temptext) { sockclose dictionarysock DisplayDefinitions } if (* iswm %temptext) { sockclose dictionarysock DisplayDefinitions } } } alias DisplayDefinitions { if (%defcnt == $null) { msg %dictchan Word cannot be found. unset %dict.delay return } var %z = 1 while (%z <= 13) { set %dcol [ $+ [ %z ] ] $gettok(%dictionary.settings,%z,32) if ($gettok(%dictionary.settings,$calc(%z + 13),32) == 1) { set %dcol [ $+ [ %z ] ] %dcol [ $+ [ %z ] ] $+  } if ($gettok(%dictionary.settings,$calc(%z + 26),32) == 1) { set %dcol [ $+ [ %z ] ] %dcol [ $+ [ %z ] ] $+  } inc %z } msg %dictchan  $+ %dcol1 $+ Word:  $+ %dcol11 $+ %dictionary.word var %c = 1 msg %dictchan  $+ %dcol2 $+ Definitions: while (%c <= %defcnt) { var %output = $replace(%definitions [ $+ [ %c ] ],noun:, $+ %dcol3 $+ Noun:,verb:, $+ %dcol4 $+ Verb:,ad $+ %dcol4 $+ Verb:, $+ %dcol6 $+ Adverb:,name:, $+ %dcol10 $+ Name: ,adjective:, $+ %dcol5 $+ Adjective:,$chr(40) $+ pron. $+ $chr(41), $+ %dcol7 $+ Pronoun:,$chr(40) $+ imp. $+ $chr(41), $+ %dcol8 $+ Imperative:,$chr(40) $+ prep. $+ $chr(41), $+ %dcol9 $+ Preposition:,(definite article.),14Definite Article:,(adv.), $+ %dcol6 $+ Adverb:,$chr(40) $+ $chr(41),14*:,$chr(40) $+ conj. $+ $chr(41),14Conjunction:,$chr(40) $+ a. $+ $chr(41), $+ %dcol5 $+ Adjective:,$chr(40) $+ n. $+ $chr(41), $+ %dcol3 $+ Noun:,$chr(40) $+ v. i. $+ $chr(41), $+ %dcol4 $+ Verb (Intransitive):,$chr(40) $+ v. t. $+ $chr(41), $+ %dcol4 $+ Verb (Transitive):) var %output = $replace(%output,$chr(40) $+ pron. $+ $chr(44) A. $+ $chr(44) conj. $+ $chr(44) & adv. $+ $chr(41), $+ %dcol7 $+ Pronoun $+ $chr(44)  $+ %dcol5 $+ Adjective $+ $chr(44) 14Conjunction $+ $chr(44)  $+ %dcol6 $+ Adverb:,$chr(40) $+ pron. & a. $+ $chr(41), $+ %dcol7 $+ Pronoun $+ $chr(44)  $+ %dcol5 $+ Adjective:,$chr(40) $+ pron. $+ $chr(44) A. $+ $chr(44) & adv. $+ $chr(41), $+ %dcol7 $+ Pronoun $+ $chr(44)  $+ %dcol5 $+ Adjective $+ $chr(44)  $+ %dcol6 $+ Adverb:,$chr(40) $+ interrog. Adv. $+ $chr(41), $+ %dcol6 $+ Interrogative Adverb:,$chr(40) $+ interj. $+ $chr(41),14Interjection:,$chr(40) $+ adv. & conj. $+ $chr(41), $+ %dcol6 $+ Adverb $+ $chr(44) 14Conjunction:) if ($left($gettok(%output,2,32),1) islower) { var %output = $gettok(%output,1,32) $upper($left($gettok(%output,2,32),1)) $+ $right($gettok(%output,2,32),-1) $gettok(%output,3-,32) } var %output = $gettok(%output,1,58) $+ :  $+ %dcol12 $+ $strip($gettok(%output,2-,58)) write dicttemp.txt     $replace($reptok(%output,$chr(40) $+ Example:, $+ %dcol13 $+ $chr(40) $+ Example:,32),,#k#,,#b#,,#u#,,#o#) inc %c } .play -a replacecodes %dictchan dicttemp.txt 1500 .unset %dict.delay .remove dicttemp.txt unset %dictionary.word unset %definition* unset %dictchan unset %defcnt unset %dcol? unset %dcol?? unset %word } alias replacecodes { if ($gettok(%dictionary.settings,40,32) == 1) { inc %dictline.cnt if (%dictline.cnt > $gettok(%dictionary.settings,41,32)) { .play stop | unset %dictline.cnt | return } } msg %dictchan $replace($1-,#k#,,#b#,,#u#,,#o#,) } alias htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) return %x } dialog DictionarySetup { title "DictIRC Setup" size -1 -1 180 175 option dbu text "DictIRC v1.0.3 by Riamus 2005",1,1 1 178 10,center check "",97,10 10 5 10 text "Only display X definitions (prevent flooding the channel)",98,17 11 140 10 edit "",99,155 10 17 10 box "Display Settings",10,5 20 170 140 text "Word Heading",11,7 29 50 8 combo 21,60 27 50 60,drop check "Bold",31,115 28 20 10 check "Underline",41,140 28 34 10 text "Definition Heading",12,7 39 50 8 combo 22,60 37 50 60,drop check "Bold",32,115 38 20 10 check "Underline",42,140 38 34 10 text "Noun Heading",13,7 49 50 8 combo 23,60 47 50 60,drop check "Bold",33,115 48 20 10 check "Underline",43,140 48 34 10 text "Verb Heading",14,7 59 50 8 combo 24,60 57 50 60,drop check "Bold",34,115 58 20 10 check "Underline",44,140 58 34 10 text "Adjective Heading",15,7 69 50 8 combo 25,60 67 50 60,drop check "Bold",35,115 68 20 10 check "Underline",45,140 68 34 10 text "Adverb Heading",16,7 79 50 8 combo 26,60 77 50 60,drop check "Bold",36,115 78 20 10 check "Underline",46,140 78 34 10 text "Pronoun Heading",17,7 89 50 8 combo 27,60 87 50 60,drop check "Bold",37,115 88 20 10 check "Underline",47,140 88 34 10 text "Imperative Heading",18,7 99 50 8 combo 28,60 97 50 60,drop check "Bold",38,115 98 20 10 check "Underline",48,140 98 34 10 text "Preposition Heading",19,7 109 50 8 combo 29,60 107 50 60,drop check "Bold",39,115 108 20 10 check "Underline",49,140 108 34 10 text "Name Heading",20,7 119 50 8 combo 30,60 117 50 60,drop check "Bold",40,115 118 20 10 check "Underline",50,140 118 34 10 text "Word",61,7 129 50 8 combo 71,60 127 50 60,drop check "Bold",81,115 128 20 10 check "Underline",91,140 128 34 10 text "Definitions",62,7 139 50 8 combo 72,60 137 50 60,drop check "Bold",82,115 138 20 10 check "Underline",92,140 138 34 10 text "Examples",63,7 149 50 8 combo 73,60 147 50 60,drop check "Bold",83,115 148 20 10 check "Underline",93,140 148 34 10 button "OK",100,80 163 20 10,ok } on *:dialog:dictionarysetup:init:*:{ var %i = 21 while (%i <= 73) { did -a $dname %i White did -a $dname %i Black did -a $dname %i Blue did -a $dname %i Green did -a $dname %i Red did -a $dname %i Brown did -a $dname %i Purple did -a $dname %i Orange did -a $dname %i Yellow did -a $dname %i Light Green did -a $dname %i Cyan did -a $dname %i Light Cyan did -a $dname %i Royal Blue did -a $dname %i Pink did -a $dname %i Grey did -a $dname %i Light Grey did -a $dname %i Default inc %i if (%i == 31) { var %i = 71 } } if (%dictionary.settings == $null) { set %dictionary.settings 12 12 10 03 06 09 11 13 08 04 16 16 05 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 999 } var %c = 1 while (%c <= 13) { if (%c < 11) { did -c $dname $calc(%c + 20) $calc($gettok(%dictionary.settings,%c,32) + 1) if ($gettok(%dictionary.settings,$calc(%c + 13),32) == 1) { did -c $dname $calc(%c + 30) } if ($gettok(%dictionary.settings,$calc(%c + 26),32) == 1) { did -c $dname $calc(%c + 40) } } else { did -c $dname $calc(%c + 60) $calc($gettok(%dictionary.settings,%c,32) + 1) if ($gettok(%dictionary.settings,$calc(%c + 13),32) == 1) { did -c $dname $calc(%c + 70) } if ($gettok(%dictionary.settings,$calc(%c + 26),32) == 1) { did -c $dname $calc(%c + 80) } } inc %c } if ($gettok(%dictionary.settings,40,32) == 1) { did -c $dname 97 } did -a $dname 99 $gettok(%dictionary.settings,41,32) if ($did(97).state == 0) { did -b $dname 99 } } on *:dialog:dictionarysetup:sclick:*:{ unset %dictionary.settings if ($did == 100) { var %c = 1 while (%c <= 13) { if (%c < 11) { var %settings = $iif($len($calc($did($dname,$calc(%c + 20)).sel - 1)) == 1,0 $+ $calc($did($dname,$calc(%c + 20)).sel - 1),$calc($did($dname,$calc(%c + 20)).sel - 1)) set %dictionary.settings %dictionary.settings %settings } else { var %settings = $iif($len($calc($did($dname,$calc(%c + 60)).sel - 1)) == 1,0 $+ $calc($did($dname,$calc(%c + 60)).sel - 1),$calc($did($dname,$calc(%c + 60)).sel - 1)) set %dictionary.settings %dictionary.settings %settings } inc %c } var %c = 1 while (%c <= 13) { if (%c < 11) { set %dictionary.settings %dictionary.settings $did($dname,$calc(%c + 30)).state } else { set %dictionary.settings %dictionary.settings $did($dname,$calc(%c + 70)).state } inc %c } var %c = 1 while (%c <= 13) { if (%c < 11) { set %dictionary.settings %dictionary.settings $did($dname,$calc(%c + 40)).state } else { set %dictionary.settings %dictionary.settings $did($dname,$calc(%c + 80)).state } inc %c } set %dictionary.settings %dictionary.settings $did(97).state $did(99) } if ($did == 97) { if ($did(97).state == 0) { did -b $dname 99 } else { did -e $dname 99 } } } on *:text:!dict *:#: { if (%dict.delay == 1) { .notice $nick Please wait until the current word is done being displayed. | return } set %dictchan $chan set -u60 %dict.delay 1 dictionarysock $2- } on *:input:*: { if ($1 == !dict) { if (%dict.delay == 1) { .notice $nick Please wait until the current word is done being displayed. | return } echo -a 10*** By Default, you won't see your own definitions. Definition display is disabled because a bot won't usually want to see all that data all the time. echo -a 10*** To enable it, you'll need to remove the "." in front of .play on line 109. I may add an option for this later to avoid having to edit it manually. set %dictchan $chan set -u60 %dict.delay 1 dictionarysock $2- } }