egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

urban dictionary not working

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
sk-4
Halfop


Joined: 06 Oct 2007
Posts: 51

PostPosted: Thu Jul 09, 2009 7:57 am    Post subject: urban dictionary not working Reply with quote

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 [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 {
&nbsp; \x20 &quot; \x22 &amp; \x26 &apos; \x27 &ndash; \x2D
&lt; \x3C &gt; \x3E &tilde; \x7E &euro; \x80 &iexcl; \xA1
&cent; \xA2 &pound; \xA3 &curren; \xA4 &yen; \xA5 &brvbar; \xA6
&sect; \xA7 &uml; \xA8 &copy; \xA9 &ordf; \xAA &laquo; \xAB
&not; \xAC &shy; \xAD &reg; \xAE &hibar; \xAF &deg; \xB0
&plusmn; \xB1 &sup2; \xB2 &sup3; \xB3 &acute; \xB4 &micro; \xB5
&para; \xB6 &middot; \xB7 &cedil; \xB8 &sup1; \xB9 &ordm; \xBA
&raquo; \xBB &frac14; \xBC &frac12; \xBD &frac34; \xBE &iquest; \xBF
&Agrave; \xC0 &Aacute; \xC1 &Acirc; \xC2 &Atilde; \xC3 &Auml; \xC4
&Aring; \xC5 &AElig; \xC6 &Ccedil; \xC7 &Egrave; \xC8 &Eacute; \xC9
&Ecirc; \xCA &Euml; \xCB &Igrave; \xCC &Iacute; \xCD &Icirc; \xCE
&Iuml; \xCF &ETH; \xD0 &Ntilde; \xD1 &Ograve; \xD2 &Oacute; \xD3
&Ocirc; \xD4 &Otilde; \xD5 &Ouml; \xD6 &times; \xD7 &Oslash; \xD8
&Ugrave; \xD9 &Uacute; \xDA &Ucirc; \xDB &Uuml; \xDC &Yacute; \xDD
&THORN; \xDE &szlig; \xDF &agrave; \xE0 &aacute; \xE1 &acirc; \xE2
&atilde; \xE3 &auml; \xE4 &aring; \xE5 &aelig; \xE6 &ccedil; \xE7
&egrave; \xE8 &eacute; \xE9 &ecirc; \xEA &euml; \xEB &igrave; \xEC
&iacute; \xED &icirc; \xEE &iuml; \xEF &eth; \xF0 &ntilde; \xF1
&ograve; \xF2 &oacute; \xF3 &ocirc; \xF4 &otilde; \xF5 &ouml; \xF6
&divide; \xF7 &oslash; \xF8 &ugrave; \xF9 &uacute; \xFA &ucirc; \xFB
&uuml; \xFC &yacute; \xFD &thorn; \xFE &yuml; \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";
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Thu Jul 09, 2009 6:08 pm    Post subject: Reply with quote

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:
set matches [regexp -all -inline {<div class=\"def_p\">.*?<p>(.*?)<\/p>} $data];


To this, and wallah, it should suddenly work. Wink
Code:
set matches [regexp -all -inline {<div class='definition'>(.*?)</div>} $data];

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
sk-4
Halfop


Joined: 06 Oct 2007
Posts: 51

PostPosted: Thu Jul 09, 2009 7:40 pm    Post subject: Reply with quote

speechles .thanks bro..the script is working again. Razz
Back to top
View user's profile Send private message
kold
Voice


Joined: 11 Aug 2009
Posts: 2

PostPosted: Tue Aug 11, 2009 6:07 am    Post subject: Reply with quote

Speechless is the man!
Back to top
View user's profile Send private message
szantovitch
Voice


Joined: 19 Sep 2009
Posts: 1

PostPosted: Sat Sep 19, 2009 12:44 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
pogue
Voice


Joined: 17 May 2009
Posts: 28

PostPosted: Sat Sep 19, 2009 8:47 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber