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.
Support & discussion of released scripts, and announcements of new releases.
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Sat Aug 09, 2008 10:19 am
It isn't as easy as a simple Copy & Paste. Google changed their template radically. To fix it requires knowledge of html, regex and tcl syntax...
<speechles> !convert asdasd8723234324234
<sp33chy> Your search - asdasd8723234324234 - did not match any documents.
<speechles> !convert two plus seven times ninety nine / 200 plus 5
<sp33chy> (two plus ((seven times ninety nine) / 200)) plus 5 = 10.46500
<speechles> !convert fturama
<sp33chy> Did you mean: futurama
<speechles> !convert 2 pounds to kilos
<sp33chy> 2 pounds = 0.90718474 kilograms
<speechles> !convert 2 peso + 7 sterling in lira
<sp33chy> (2 Mexican pesos) + (7 British pounds) = 15.8371244 Turkish liras
Get it here :
Gconvert v3.1 (egghelp version)
holycrap
Op
Posts: 152 Joined: Mon Jan 21, 2008 11:19 pm
Post
by holycrap » Thu Oct 09, 2008 2:52 am
Hi,
If I input:
!convert asdasd8723234324234
or
!calc 1/0
or anything it can't compute. The bot will give me a half screen of garbage info. Can you fix this?
Thank You!
This is what I got instead of the default cannot compute message.
Code: Select all
Search Resultsegghelp.org community :: View topic - gconvert.tcl Update Please ...? <sp33chy> Your search - asdasd8723234324234 - did not match any documents. < speechles> !convert two plus seven times ninety nine / 200 plus 5 ...forum.egghelp.org/viewtopic.php?t=15279&start=30&postdays= 0&postorder=asc&highlight= - 24k - Cached - Similar pages
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Thu Oct 09, 2008 8:59 pm
holycrap wrote: Hi,
If I input:
!convert asdasd8723234324234
or
!calc 1/0
or anything it can't compute. The bot will give me a half screen of garbage info. Can you fix this?
Thank You!
http://forum.egghelp.org/viewtopic.php?p=83121#83121
fixed, enjoy
holycrap
Op
Posts: 152 Joined: Mon Jan 21, 2008 11:19 pm
Post
by holycrap » Thu Oct 09, 2008 10:16 pm
It still doesn't work. I did used the new version.
Thanks much for your time, speechles!
Code: Select all
<user>!calc 1/0
<bot> Search Results 1/0 -- Yeah, just the comic these days. Nothing new. Just the comic.? Well, that's it for 1/0 . Hope you enjoyed it. There will be a CD archive (with various special features) available as soon as I get around to making it. ... oneoverzero.comicgenesis.com/ - 6k - Cached - Similar pages 1/0 Archives... comic -by Tailsteak Next comic · Today's comic " 1/0 " is hosted on Keenspace, a free webhosting and site automation service for webcomics.
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Fri Oct 10, 2008 11:27 pm
holycrap wrote: It still doesn't work. I did used the new version.
Thanks much for your time, speechles!
http://forum.egghelp.org/viewtopic.php?t=15279&start=14
Now it works as it did before. I tested it, not just scripting from the hip..
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Sat Aug 08, 2009 12:43 pm
Code: Select all
#############################################
# gconvert.tcl v4.0 by speechles #
# -Parsers/Encoders from Unofficial google- #
#############################################
##############
# OLD INFO #
#############################################
# gconvert.tcl v2.0 by AkiraX #
# <#AnimeFiends@EFNet> #
#############################################
####### DESCRIPTION #########################
# Uses the google calculator to perform
# conversions and mathematics
#############################################
####### USAGE ###############################
# .chanset #yourchan +gconvert
# !convert <quantity> to <quantity> : perform conversions
# !math [.country.code] <equation> : perform mathematics
# !calc [.country.code] <equation> : perform calculations
# !spell [.country.code] <something> : perform spell checks
#
# all 4 of the above commands are identical, each can perform the
# actions of the other depending on the template detected when
# querying google and receiving html. If you wish to use only 1
# command to do everything, this is 100% possible and you
# can remove any binds you wish above to do so.
#############################################
####### CHANGELOG ###########################
# v4.0 : Adapted tempates to fit googles new calculator.
# v3.1 : Adapted script to fit Google's new redesign.
# v3.0 : fixed functionality, added .chanset #yourchan +gconvert
# added multilanguage, added spell check, added dynamic
# messages, added custom static messages, removed
# redundant socket attempts, condensed procedures to
# one for everything.
# v2.1 : fixed functionality, repaired by Scott Glover
# v2.0 : allow convert code to perform math
# v1.0 : support for google conversions
#############################################
####### LICENSE #############################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U
#############################################
####### CONFIG #############################
# this is where you can configure default behavior.
# select your default regional google server
# google.* - it can be any valid domain TLD for google.
variable ConvertCountry "com"
# select your default results not found message
variable ConvertMsg1 "Unable to parse anything meaningful."
variable ConvertMsg2 "Found calculator template but cannot parse within."
############################################
package require http
setudef flag gconvert
bind pub -|- !math gconvert:run
bind pub -|- !calc gconvert:run
bind pub -|- !convert gconvert:run
bind pub -|- !spell gconvert:run
proc gconvert:run { nick host handle chan text } {
if {[lsearch -exact [channel info $chan] +gconvert] == -1} {return}
set convert(nick) $nick
set convert(input) $text
regexp -nocase -- {^\.(.+?)\s(.+?)$} $convert(input) - convert(country) convert(input)
if {![info exists convert(country)]} {
set convert(country) "$::ConvertCountry"
}
# create google URL
set token [http::config -useragent "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e"]
set convert(url) "http://www.google.$convert(country)/search?q=[gconvert:webstring $convert(input)]&safe=off&btnG=Search&lr=lang_all&num=10"
# grab the info from google
catch {set token [http::geturl $convert(url) -timeout 15000]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $chan :Sorry, cannot create a socket to \"$convert(url)\"."
return 0
} elseif {[::http::status $token] == "timeout"} {
puthelp "PRIVMSG $chan :Sorry, your request to \"$convert(url)\" has timed out."
return 0
}
set html [gconvert:clean [http::data $token]]
http::cleanup $token
# find the answer
set convert(answer) ""
if {[string match "*</div><div id=res class=med>*" $html]==1} {
if {[regexp -nocase -- {</div><div id=res class=med><p>(.+?)<a href=.*?>(.+?)</a>} $html {} item did_you_mean]} {
set convert(answer) "${item}${did_you_mean}"
if {[string match "*<img src=/images/calc_img*" $item] == 1} {
regexp -nocase -- {calc_img.+?nowrap.*?>(.+?)</} $item - item
set convert(answer) "${item}"
}
}
regexp -- {(.+?)</td></tr>} $convert(answer) -> convert(answer)
regsub -all -- {<(.+?)>} $convert(answer) "" convert(answer)
} elseif {[regexp {src=/images/calc_img.gif} $html]} {
if {[regexp -nocase -- {calc_img.+?nowrap.*?>(.+?)<tr><td>} $html - convert(answer)]} {
regsub -all {<.*?>} $convert(answer) "" convert(answer)
} else {
set convert(answer) $::ConvertMsg2
}
}
if { $convert(answer) == "" } {
if {![regexp -- {</div><div id=res class=med>(?!<)(.+?)<p style} $html - no_search]} {
set convert(answer) $::ConvertMsg1
} else {
regexp -- {^(.+?)</td></tr>} $no_search - no_search
regsub -- {</a>} $no_search "? " no_search
regsub -all -- {<(.+?)>} $no_search { } no_search
while {[string match "* *" $no_search]} {
regsub -all -- { } $no_search " " no_search
}
set convert(answer) [string trim $no_search]
}
}
puthelp "PRIVMSG $chan :[descdecode $convert(answer)]"
return 1
}
proc gconvert:clean { input } {
regsub -all {(?:\t|\n|\r|\v)} $input "" input
regsub -all "(?:<b>|</b>)" $input "\002" input
regsub -all "(?:\x91|\x92|')" $input {'} input
regsub -all "(?:\x93|\x94|")" $input {"} input
regsub -all " " $input "" input
regsub -all "&" $input {\&} input
regsub -all -nocase {<sup>(.+?)</sup>} $input {^\1} input
regsub -all -nocase {<font.*?>} $input "" input
regsub -all -nocase {</font>} $input "" input
regsub -all -nocase {<span.*?>} $input "" input
regsub -all -nocase {</span>} $input "" input
regsub -all -nocase {<input.*?>} $input "" input
regsub -all -nocase {(?:<i>|</i>)} $input "" input
return $input
}
proc descdecode {text} {
# code below is neccessary to prevent numerous html markups
# from appearing in the output (ie, ", ?, etc)
# stolen (borrowed is a better term) from perplexa's urban
# dictionary script..
if {![string match *&* $text]} {return $text}
set escapes {
\x20 " \x22 & \x26 ' \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 text [string map $escapes $text]
# tcl filter required because we are using SUBST command below
# this will escape any sequence which could potentially trigger
# the interpreter..
regsub -all -- \\\\ $text \\\\\\\\ text
regsub -all -- \\\[ $text \\\\\[ text
regsub -all -- \\\] $text \\\\\] text
regsub -all -- \\\} $text \\\\\} text
regsub -all -- \\\{ $text \\\\\{ text
regsub -all -- \\\" $text \\\\\" text
regsub -all -- \\\$ $text \\\\\$ text
# end tcl filter
regsub -all -- {&#([[:digit:]]{1,5});} $text {[format %c [string trimleft "\1" "0"]]} text
regsub -all -- {&#x([[:xdigit:]]{1,4});} $text {[format %c [scan "\1" %x]]} text
regsub -all -- {&#?[[:alnum:]]{2,7};} $text "?" text
return [subst $text]
}
proc gconvert:webstring { input } {
set url ""
foreach byte [split [encoding convertto utf-8 $input] ""] {
scan $byte %c i
if {$i < 65 || $i > 122} {
append url [format %%%02X $i]
} else {
append url $byte
}
}
return [string map {%3A : %2D - %2E . %2F / %30 0 %31 1 %32 2 %33 3 %34 4 %35 5 %36 6 %37 7 %38 8 %39 9 \[ %5B \\ %5C \] %5D \^ %5E \_ %5F \` %60} $url]
}
putlog "gconvert.tcl v4.0 by speechles (based upon v2.0 by AkiraX <#AnimeFiends@EFnet>) loaded!"
<you> We get signal
<you> Mainscreen turn on
<google> All your base are belong to Google!
<you> Take off every Zig!
Have a fun ;P
holycrap
Op
Posts: 152 Joined: Mon Jan 21, 2008 11:19 pm
Post
by holycrap » Tue Aug 11, 2009 7:29 pm
Thanks for the update!
shadrach
Halfop
Posts: 74 Joined: Fri Dec 14, 2007 6:29 pm
Post
by shadrach » Thu May 06, 2010 2:57 am
broken
Code: Select all
[18:24:58] [@********] !convert 800 litas to euro
[18:24:59] [@*****] Found calculator template but cannot parse within.
devilkin
Voice
Posts: 3 Joined: Wed May 19, 2010 11:18 am
Post
by devilkin » Wed May 19, 2010 11:28 am
I've managed to fix it for my uses, no idea if it's complete... as always: it works for me, might not work for you. If it eats your kitties, your problem
Look for:
Code: Select all
if {[string match "*</div><div id=res class=med>*" $html]==1} {
if {[regexp -nocase -- {</div><div id=res class=med><p>(.+?)<a href=.*?>(.+?)</a>} $html {} item did_you_mean]} {
Change to:
Code: Select all
if {[string match "*<div id=center_col><div id=res class=med role=main>*" $html]==1} {
if {[regexp -nocase -- {<div id=center_col><div id=res class=med role=main><p class=ssp><span class=spell style="color:#cc0000">(.+?)<a href=.*?>(.+?)</a>} $html {} item did_you_mean]} {
Look for:
Code: Select all
if {![regexp -- {</div><div id=res class=med>(?!<)(.+?)<p style} $html - no_search]} {
Change to:
Code: Select all
if {![regexp -- {<div id=center_col><div id=res class=med role=main><table class=std>(.+?)<div style} $html - no_search]} {
shadrach
Halfop
Posts: 74 Joined: Fri Dec 14, 2007 6:29 pm
Post
by shadrach » Wed May 19, 2010 4:59 pm
works ty
Luminous
Op
Posts: 146 Joined: Fri Feb 12, 2010 1:00 pm
Post
by Luminous » Sat Jun 05, 2010 3:26 pm
Wanted to report that this script no longer performs currency conversions, only arithmetic. My guess would be its because google does not always use the calc image, but sometimes brings up a graph instead. Not sure how to work around this. perhaps using a site like
www.xe.com would be better. Google seems to change so much.
devilkin
Voice
Posts: 3 Joined: Wed May 19, 2010 11:18 am
Post
by devilkin » Sat Jun 05, 2010 4:23 pm
Luminous wrote: Wanted to report that this script no longer performs currency conversions, only arithmetic. My guess would be its because google does not always use the calc image, but sometimes brings up a graph instead. Not sure how to work around this. perhaps using a site like
www.xe.com would be better. Google seems to change so much.
Did you apply the changes i put two messages ago? They fix it for me.
holycrap
Op
Posts: 152 Joined: Mon Jan 21, 2008 11:19 pm
Post
by holycrap » Sun Jun 06, 2010 3:01 am
devilkin wrote: Luminous wrote: Wanted to report that this script no longer performs currency conversions, only arithmetic. My guess would be its because google does not always use the calc image, but sometimes brings up a graph instead. Not sure how to work around this. perhaps using a site like
www.xe.com would be better. Google seems to change so much.
Did you apply the changes i put two messages ago? They fix it for me.
It no longer works, they must have changed something again.
devilkin
Voice
Posts: 3 Joined: Wed May 19, 2010 11:18 am
Post
by devilkin » Tue Jun 08, 2010 2:34 pm
Okay, some searches were indeed b0rked. This does it for me. Again, same warranty: if it eats your cats, you'll be catless. :p
Look for:
Code: Select all
if {[regexp -nocase -- {calc_img.+?nowrap.*?>(.+?)<tr><td>} $html - convert(answer)]} {
change to:
Code: Select all
if {[regexp -nocase -- {calc_img.+?nowrap.*?>(.+?)<td>} $html - convert(answer)]} {
regexp -nocase -- {<h2 class=r style="font-size:138%"><b>(.+?)</b></h2>} $convert(answer) - convert(answer)
holycrap
Op
Posts: 152 Joined: Mon Jan 21, 2008 11:19 pm
Post
by holycrap » Tue Jun 08, 2010 9:51 pm
Anything else needed to be changed? It's not working for me.