This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

urban dictionary not working

Support & discussion of released scripts, and announcements of new releases.
Post Reply
s
sk-4
Halfop
Posts: 51
Joined: Sat Oct 06, 2007 6:37 am

urban dictionary not working

Post by sk-4 »

the script is not responding to any words,im getting error

!define eggdrop
Nothing found for "eggdrop".
can anyone look at it..thanks

this is the script code

# Urban Dictionary
# Copyright (C) 2006 perpleXa
# http://perplexa.ugug.co.uk / #perpleXa on QuakeNet
#
# Redistribution, with or without modification, are permitted provided
# that redistributions retain the above copyright notice, this condition
# and the following disclaimer.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#
# Usage:
# !define [id] <term>

# fsck is available at http://perplexa.ugug.co.uk
package require fsck 1.10;
package require http;

namespace eval urbandict {
variable version 1.7;
variable encoding "utf-8";
variable client "Mozilla/5.0 (compatible; Y!J; for robot study; keyoshid)";
bind pub -|- "!define" [namespace current]::pub;
namespace export pub;
}

proc urbandict::getdefinition {definition} {
variable client;
http::config -useragent $client;
set url "http://www.urbandictionary.com/define.php?term=[urlencode $definition]";
if {[catch {http::geturl $url -timeout 20000} token]} {
return [list 0 "Warning: Couldn't connect to \[$url\]"];
}
upvar 0 $token state;
if {![string equal -nocase $state(status) "ok"]} {
return [list 0 "Warning: Couldn't connect to \[$url\] (connection $state(status))."];
}
set data [http::data $token];
http::cleanup $token;
set matches [regexp -all -inline {<div class=\"def_p\">.*?<p>(.*?)<\/p>} $data];
set list
  • ;
    foreach {null definition} $matches {
    regsub -all {<[^>]*?>} [decode $definition] "" definition;
    regsub -all {[\r\n\s\t]+} $definition " " definition;
    lappend list $definition;
    }
    return [concat [llength $list] $list];
    }

    proc urbandict::urlencode {i} {
    variable encoding
    set index 0;
    set i [encoding convertto $encoding $i]
    set length [string length $i]
    set n ""
    while {$index < $length} {
    set activechar [string index $i $index]
    incr index 1
    if {![regexp {^[a-zA-Z0-9]$} $activechar]} {
    append n %[format "%02X" [scan $activechar %c]]
    } else {
    append n $activechar
    }
    }
    return $n
    }

    proc urbandict::pub {nick host hand chan argv} {
    if {![string compare $argv ""]} {
    puthelp "NOTICE $nick :Usage: !define <id> <definition> ex.!define 1 irc";
    return 1;
    }
    if {[string is digit -strict [getword $argv 0]]} {
    if {[splitline $argv cargv 2]!=2} {
    puthelp "NOTICE $nick :Usage: !define <id> <definition> ex.!define 1 irc";
    return 1;
    }
    set id [lindex $cargv 0];
    set argv [lindex $cargv 1];
    if {!$id} {
    set id 1;
    }
    } else {
    set id 1;
    }
    set definitions [getdefinition $argv];
    set count [lindex $definitions 0];
    if {!$count} {
    puthelp "PRIVMSG $chan :Nothing found for4 \"$argv\".";
    return 1;
    } elseif {$id > $count} {
    puthelp "PRIVMSG $chan :Only $count results found for \"$argv\".";
    return 1;
    }
    set definition [lindex $definitions $id];
    if {[string length $definition] <= 300} {
    puthelp "PRIVMSG $chan :4------Meaning Of Words4------( $argv )";
    puthelp "PRIVMSG $chan :14 $definition";
    return 0;
    }
    foreach line [splitmsg $definition] {
    puthelp "PRIVMSG $chan :4------Meaning Of Words4------( $argv )";
    puthelp "PRIVMSG $chan :14 $line";
    puthelp "PRIVMSG $chan :4------End Of the Meaning4------ ";

    }
    return 0;
    }

    proc urbandict::decode {content} {
    if {![string match *&* $content]} {
    return $content;
    }
    set escapes {
      \x20 " \x22 & \x26 &apos; \x27 – \x2D
    < \x3C > \x3E ˜ \x7E € \x80 ¡ \xA1
    ¢ \xA2 £ \xA3 ¤ \xA4 ¥ \xA5 ¦ \xA6
    § \xA7 ¨ \xA8 © \xA9 ª \xAA « \xAB
    ¬ \xAC ­ \xAD ® \xAE &hibar; \xAF ° \xB0
    ± \xB1 ² \xB2 ³ \xB3 ´ \xB4 µ \xB5
    ¶ \xB6 · \xB7 ¸ \xB8 ¹ \xB9 º \xBA
    » \xBB ¼ \xBC ½ \xBD ¾ \xBE ¿ \xBF
    À \xC0 Á \xC1 Â \xC2 Ã \xC3 Ä \xC4
    Å \xC5 Æ \xC6 Ç \xC7 È \xC8 É \xC9
    Ê \xCA Ë \xCB Ì \xCC Í \xCD Î \xCE
    Ï \xCF Ð \xD0 Ñ \xD1 Ò \xD2 Ó \xD3
    Ô \xD4 Õ \xD5 Ö \xD6 × \xD7 Ø \xD8
    Ù \xD9 Ú \xDA Û \xDB Ü \xDC Ý \xDD
    Þ \xDE ß \xDF à \xE0 á \xE1 â \xE2
    ã \xE3 ä \xE4 å \xE5 æ \xE6 ç \xE7
    è \xE8 é \xE9 ê \xEA ë \xEB ì \xEC
    í \xED î \xEE ï \xEF ð \xF0 ñ \xF1
    ò \xF2 ó \xF3 ô \xF4 õ \xF5 ö \xF6
    ÷ \xF7 ø \xF8 ù \xF9 ú \xFA û \xFB
    ü \xFC ý \xFD þ \xFE ÿ \xFF
    };
    set content [string map $escapes $content];
    set content [string map [list "\]" "\\\]" "\[" "\\\[" "\$" "\\\$" "\\" "\\\\"] $content];
    regsub -all -- {&#([[:digit:]]{1,5});} $content {[format %c [string trimleft "\1" "0"]]} content;
    regsub -all -- {&#x([[:xdigit:]]{1,4});} $content {[format %c [scan "\1" %x]]} content;
    regsub -all -- {&#?[[:alnum:]]{2,7};} $content "?" content;
    return [subst $content];
    }

    putlog "Script loaded: Urban Dictionary v$urbandict::version by perpleXa";
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Webby wrote:<speechles> !webby http://www.urbandictionary.com/define.php?term=eggdrop --regexp <div class="def_p">.*?<p>(.*?)<\/p>--
<sp33chy> regexp does not match any html.

<speechles> !webby http://www.urbandictionary.com/define.php?term=eggdrop --regexp <div class="def_p">.*?<p>(.*?)</p>--
<sp33chy> regexp does not match any html.

<speechles> !webby http://www.urbandictionary.com/define.php?term=eggdrop --regexp <div class='definition'>(.*?)</div>--
<sp33chy> regexp capture1 ( a type of irc bot. www.eggheads.org and www.egghelp.org are 2 major eggdrop resource websites. )
So appears, to fix it you simply change this:

Code: Select all

set matches [regexp -all -inline {<div class="def_p">.*?<p>(.*?)<\/p>} $data];
To this, and wallah, it should suddenly work. ;)

Code: Select all

set matches [regexp -all -inline {<div class='definition'>(.*?)</div>} $data];
s
sk-4
Halfop
Posts: 51
Joined: Sat Oct 06, 2007 6:37 am

Post by sk-4 »

speechles .thanks bro..the script is working again. :P
k
kold
Voice
Posts: 2
Joined: Tue Aug 11, 2009 6:05 am

Post by kold »

Speechless is the man!
s
szantovitch
Voice
Posts: 1
Joined: Sat Sep 19, 2009 12:42 am

Post by szantovitch »

Hi guys,

I'm getting:

[00:37] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory
[00:37] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory
[00:41] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory
[00:41] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory

as an error for this every time someone talks in the channel. Any ideas?
User avatar
pogue
Voice
Posts: 28
Joined: Sun May 17, 2009 3:56 am
Contact:

Post by pogue »

szantovitch wrote:Hi guys,

I'm getting:

[00:37] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory
[00:37] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory
[00:41] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory
[00:41] Tcl error [askquestion]: couldn't open "brain.txt": no such file or directory

as an error for this every time someone talks in the channel. Any ideas?
Is that related to the urban dictionary script? I'm not seeing that...
Post Reply