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 

TCL of google no longer works .. By FordLawnmower
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Mon Jun 06, 2016 12:13 pm    Post subject: Reply with quote

I added and it does not work
I make the request in white and looking directly

if {$search == ""} {puthelp "PRIVMSG $chan :Error: <search> is empty"; return 1 }

so the bot should answer
in channel
[12:09] <Arnold_X-P> .google
[12:09] <@JulieTh> Error: <search> is empty

but never responds jumps directly to search request
example:
[12:09] <Arnold_X-P> .google
[12:09] <@JulieTh> Error querying Google: 403 -> ok

the correct is
[12:09] <Arnold_X-P> .google
[12:09] <@JulieTh> Error: <search> is empty
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Mon Jun 06, 2016 12:38 pm    Post subject: Reply with quote

What piece of code are you using?
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Mon Jun 06, 2016 12:42 pm    Post subject: Reply with quote

hi caesar
that tcl am using
Code:

##############################################################################################
##  ## Advanced Google.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help  ##  ##
##############################################################################################
##  ## To use this script you must set channel flag +google (ie .chanset #chan +google) ##  ##
##############################################################################################

package require http
package require json

if {[catch {package require tls}]} {
set httpsSupport false
} else {
set httpsSupport true
}
set url "www.googleapis.com/customsearch/v1?"
if {$httpsSupport} {
::http::register https 443 [list ::tls::socket -request 1 -require 0 -ssl3 1 -tls1 1]
set url https://$url
} else { set url http://$url }

##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
## Change the country code between the "" below to change the language of your results.     ##
set googlectry "en"
## Change the number between the "" below to change the number of results returned.         ##
set googlemax "3"
set API_KEY   "AIzaSyD290rR6-rFyDRDD5aOerzxflCfZskE7q0"
set SEARCH_ID   "eggdroptcl"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################

setudef flag google

proc googleweb {nick host hand chan type search} {
      global googlectry googlemax API_KEY SEARCH_ID url
      if {![channel get $chan google]} {return}
      if {$search == ""} {puthelp "PRIVMSG $chan :Error: <search> is empty"; return 1 }
      if {$type == ""} {
   set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry q $search]
   } else { set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry q $search searchType $type] }
      if {[catch {http::geturl $googleurl -timeout 5000} sockerr]} {
         puthelp "privmsg $chan :Timeout connecting to Google: $sockerr"
         return 1
      } elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
         puthelp "privmsg $chan :Error querying Google: [http::ncode $sockerr] -> [http::status $sockerr]"
         http::cleanup $sockerr
         return 1
      } else {
         set data [http::data $sockerr]
         http::cleanup $sockerr
         set json [ ::json::json2dict $data ]
         for { set i 0 } { $i < $googlemax } { incr i } {
            set title ""
            set link ""
            catch { set title [ dict get [ lindex [ dict get $json items ] $i ] title ] }
            catch { set link  [ dict get [ lindex [ dict get $json items ] $i ] link ] }
            set index [ expr $i + 1 ]
            if {[string length $title] && [string length $link]} {
               putserv "PRIVMSG $chan :$title $link"
            } else {
               puthelp "PRIVMSG $chan :Google found no results"
            }
         }
      }
return 1
}

proc google {nick host hand chan args} { googleweb $nick $host $hand $chan "" $args}
proc gimage {nick host hand chan args} { googleweb $nick $host $hand $chan image $args}

foreach bind [binds google] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds gimage] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}

bind pub - .google google
bind pub - !google google
bind pub - .gimage gimage

putlog "Google script loaded"

_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
CP1832
Halfop


Joined: 09 Oct 2014
Posts: 51

PostPosted: Mon Jun 06, 2016 2:36 pm    Post subject: Reply with quote

Another mistake I found. args is a special name and is considered a list, so braces are added between the values. Renaming it solves the problem. With this 2 lines replacing the original ones it should work.
Code:
proc google {nick host hand chan text} { googleweb $nick $host $hand $chan "" $text}
proc gimage {nick host hand chan text} { googleweb $nick $host $hand $chan image $text}
https://www.tcl.tk/man/tcl8.5/TclCmd/proc.htm wrote:
If the last formal argument has the name args, then a call to the procedure may contain more actual arguments than the procedure has formals. In this case, all of the actual arguments starting at the one that would be assigned to args are combined into a list (as if the list command had been used); this combined value is assigned to the local variable args.
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Mon Jun 06, 2016 4:08 pm    Post subject: Reply with quote

Now if it's okay with no errors..

[16:05] <Arnold_X-P> .recargar
[16:05] -JulieTh:#tcls- el Rehashing fue completado...-= Ejecutado =-
[16:05] <Arnold_X-P> .google
[16:06] <@JulieTh> Error: <search> is empty
[16:06] <Arnold_X-P> .google tcl
[16:06] <@JulieTh> Error querying Google: 403 -> ok
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Mon Jun 06, 2016 4:10 pm    Post subject: Reply with quote

friend
register as a user and password in google api
and register one but not my

set API_KEY "AIzaSyD290rR6-rFyDRDD5aOerzxflCfZskE7q0"
set SEARCH_ID "eggdrop"
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
CP1832
Halfop


Joined: 09 Oct 2014
Posts: 51

PostPosted: Tue Jun 07, 2016 10:27 am    Post subject: Reply with quote

Arnold_X-P wrote:
set API_KEY "AIzaSyD290rR6-rFyDRDD5aOerzxflCfZskE7q0"
set SEARCH_ID "eggdrop"
The API_KEY seems right but the search ID looks wrong, it has to be obtained from
I really don't remember how I got there and I can't find the tutorial I used, sorry. It has to somewhere here: https://www.google.com/search?q=api+key+search+if&filter=0&safe=off&hl=en&complete=0&num=100&gws_rd=ssl
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Wed Jun 08, 2016 1:19 pm    Post subject: Reply with quote

I try on many websites and it does not work
api to create the new search engine ....


Shocked Shocked Shocked Shocked Shocked
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Wed Jun 29, 2016 7:12 pm    Post subject: Reply with quote

someone who teaches me google api register an account to use this tcl
someone who teaches me google api register an account to use this tcl


look manuals but there is not one clear that teaches detail

Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Fri Jul 01, 2016 1:08 pm    Post subject: Reply with quote

CP1832., this tcl does not work and does not seek
just launch this and never looking:

<@Arnold_X-P> .google mirc
<@JulieTh> Error querying Google: 403 -> ok

<@Arnold_X-P> .google irc
<@JulieTh> Error querying Google: 400 -> ok

and believes the current account and does not work tcl


Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
CP1832
Halfop


Joined: 09 Oct 2014
Posts: 51

PostPosted: Fri Jul 01, 2016 3:59 pm    Post subject: Reply with quote

Arnold_X-P wrote:
CP1832., this tcl does not work and does not seek
just launch this and never looking:

<@Arnold_X-P> .google mirc
<@JulieTh> Error querying Google: 403 -> ok

<@Arnold_X-P> .google irc
<@JulieTh> Error querying Google: 400 -> ok

and believes the current account and does not work tcl


Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes
Hi Arnold, that error is caused due to having a wrong API key or search ID. I have them right and the bot answers every query perfectly.
Code:
(2016-07-01 16:52:04) CP1832: .google mcgyver eggdrop
(2016-07-01 16:52:06) Eggdrop: How to Build an Egg Drop Container with Straws | Egg Drop, Straws ... https://www.pinterest.com/pin/484066659919400998/
(2016-07-01 16:56:19) CP1832: .google stone roses this is the one
(2016-07-01 16:56:21) Eggdrop: The Stone Roses - This Is The One - YouTube https://www.youtube.com/watch?v=-aqY-8cMVdg
I edited the script and entered wrong API keys and started getting 400 errors as you are.
Code:
(2016-07-01 16:50:20) CP1832: .google mirc
(2016-07-01 16:50:22) Eggdrop: Error querying Google: 400 -> ok
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Sep 24, 2016 11:43 am    Post subject: Reply with quote

try a lot of forms and I cannot create an api for the searcher google
use manuals and the same happens to me ..

someone can prepare a manual of as to create an api for search in google
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
CP1832
Halfop


Joined: 09 Oct 2014
Posts: 51

PostPosted: Wed Sep 28, 2016 10:44 am    Post subject: Reply with quote

Arnold_X-P wrote:
try a lot of forms and I cannot create an api for the searcher google
use manuals and the same happens to me ..

someone can prepare a manual of as to create an api for search in google
Hi Arnold_X-P, I found the manual I used to create my google search API: https://www.imarc.com/blog/google-custom-search
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sun Jun 04, 2017 5:28 pm    Post subject: google Reply with quote

Solved
This tcl for its correct functioning requires the following

in eggdrop
step 1
conf down and add in two tcl:
http.tcl
json.tcl

these three add tcl in the conf:
source scripts/http.tcl
source scripts/json.tcl

in windrop
step 1
conf down and add in three tcl:
http.tcl
tls.tcl
json.tcl

these three add tcl in the conf:
source scripts/http.tcl
source scripts/tls.tcl
source scripts/json.tcl

step two
then down
tls lib
unzip the contents and paste in your directory. example;
\lib\tcl8.5

and that's all ready, will be working well...

Code:
##############################################################################################
##  ## Advanced Google.tcl for eggdrop by CP1832 & Arnold_X-P network: DALnet irc.dal.net channel #tcls
##############################################################################################
##  ## To use this script you must set channel flag +google (ie .chanset #chan +google) ##  ##
##############################################################################################
## This tcl requires the following in eggdrop: http.tcl json.tcl ##
## This tcl requires the following in windrop: http.tcl json.tcl tls.tcl ##

package require http
package require json

if {[catch {package require tls}]} {
set httpsSupport false
} else {
set httpsSupport true
}
set url "www.googleapis.com/customsearch/v1?"
if {$httpsSupport} {
::http::register https 443 [list ::tls::socket -request 1 -require 0 -ssl3 1 -tls1 1]
set url https://$url
} else { set url http://$url }

##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
## Change the country code between the "" below to change the language of your results.     ##
set googlectry "en"
## Change the number between the "" below to change the number of results returned.         ##
set googlemax "3"
set googlelogo "12G4o7o12g3l4e"

## google api ##
 set API_KEY "AIzaSyA_LD8bDbreyyvP9zMGYaBPWg_Ro4tj9W8"
 set SEARCH_ID "009019420915705956308:f77rldgmcfw"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################
set gaucho "CP1832 & Arnold_X-P"
set googlever "v3.0.0"
setudef flag google

proc googleweb {nick host hand chan type search} {
      global googlectry googlemax API_KEY SEARCH_ID url googlelogo
      if {![channel get $chan google]} {return}
      if {$search == ""} {puthelp "PRIVMSG $chan :Error: <search> is empty"; return 1 }
      if {$type == ""} {
   set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry q $search]
   } else { set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry q $search searchType $type] }
      if {[catch {http::geturl $googleurl -timeout 5000} sockerr]} {
         puthelp "privmsg $chan :$googlelogo Timeout connecting to Google: $sockerr"
         return 1
      } elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
         puthelp "privmsg $chan :$googlelogo Error querying Google: [http::ncode $sockerr] -> [http::status $sockerr]"
         http::cleanup $sockerr
         return 1
      } else {
         set data [http::data $sockerr]
         http::cleanup $sockerr
         set json [ ::json::json2dict $data ]
         for { set i 0 } { $i < $googlemax } { incr i } {
            set title ""
            set link ""
            catch { set title [ dict get [ lindex [ dict get $json items ] $i ] title ] }
            catch { set link  [ dict get [ lindex [ dict get $json items ] $i ] link ] }
            set index [ expr $i + 1 ]
            if {[string length $title] && [string length $link]} {
               putserv "PRIVMSG $chan :$googlelogo $title $link"
            } else {
               puthelp "PRIVMSG $chan :$googlelogo found no results"
            }
         }
      }
return 1
}

proc google {nick host hand chan text} { googleweb $nick $host $hand $chan "" $text}
proc gimage {nick host hand chan text} { googleweb $nick $host $hand $chan image $text}

foreach bind [binds google] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds gimage] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}

bind pub - .google google
bind pub - !google google
bind pub - .gimage gimage
bind pub - !gimage gimage

putlog "Google search loaded by $gaucho $googlever"

_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
taxick
Voice


Joined: 12 Jul 2007
Posts: 9

PostPosted: Tue Jul 25, 2017 2:51 pm    Post subject: Re: google Reply with quote

Hi.

I have followed your guide, but I get this error when i type "!google superman"

Quote:
Google Timeout connecting to Google: protocol not supported


I'm running eggdrop 1.8.1 and I'm on Ubuntu 17.04

I have inserted my own keys, by following this guide: https://www.imarc.com/blog/google-custom-search

Hope you can help me out here

EDIT: I have try to turn my firewall off, and it doesn't help
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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