| View previous topic :: View next topic |
| Author |
Message |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Jun 06, 2016 12:13 pm Post subject: |
|
|
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 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Jun 06, 2016 12:38 pm Post subject: |
|
|
What piece of code are you using? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Jun 06, 2016 12:42 pm Post subject: |
|
|
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"
|
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Mon Jun 06, 2016 2:36 pm Post subject: |
|
|
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 |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Jun 06, 2016 4:08 pm Post subject: |
|
|
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 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Jun 06, 2016 4:10 pm Post subject: |
|
|
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" _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Wed Jun 08, 2016 1:19 pm Post subject: |
|
|
I try on many websites and it does not work
api to create the new search engine ....
 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Wed Jun 29, 2016 7:12 pm Post subject: |
|
|
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
 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Fri Jul 01, 2016 1:08 pm Post subject: |
|
|
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
 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Fri Jul 01, 2016 3:59 pm Post subject: |
|
|
| 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
 | 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 |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Sep 24, 2016 11:43 am Post subject: |
|
|
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 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Wed Sep 28, 2016 10:44 am Post subject: |
|
|
| 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 |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sun Jun 04, 2017 5:28 pm Post subject: google |
|
|
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 ##
#you must create a key for your google search engine in https://cloud.google.com/docs/authentication/api-keys?visit_id=637728160970526198-325218571&rd=1 #creating_an_api_key#
set API_KEY "your-api-key"
set SEARCH_ID "your-id"
##############################################################################################
## ## 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
putlog "Google search loaded by $gaucho $googlever" |
_________________
thanks to that they help, that others learn 
Last edited by Arnold_X-P on Thu Nov 18, 2021 3:27 am; edited 3 times in total |
|
| Back to top |
|
 |
taxick Voice
Joined: 12 Jul 2007 Posts: 24
|
Posted: Tue Jul 25, 2017 2:51 pm Post subject: Re: google |
|
|
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 |
|
 |
|