Hello i need a script which search on https://darkhelp.uk/ when type example !search terms
he search on https://darkhelp.uk/ and show result in channel
Thx for helping
Code: Select all
##############################################################################################
## ## 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) ## ##
##############################################################################################
catch {package require foobar}
catch {package require http}
catch {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 -tls1 1]
set url https://$url
} else { set url http://$url }
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
## Change the character between the "" below to change the command character/trigger. ##
set cmdchar "."
## 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 "1"
set API_KEY "YOUR API KEY"
set SEARCH_ID "YOUR ID"
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
proc googleweb {nick host hand chan type search site} {
global googlectry googlemax API_KEY SEARCH_ID url
if {$search == ""} {puthelp "PRIVMSG $chan :Error: <search> is blank"; return 1 }
if {$type == ""} {
set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry siteSearch $site q $search]
} else { set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry siteSearch $site q $search searchType $type] }
if {[catch {http::geturl $googleurl -timeout 5000} sockerr]} {
puthelp "privmsg $chan :Timeout querying 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]} {
puthelp "PRIVMSG $chan :[encoding convertfrom utf-8 [dehex $title]] $link"
} else {
puthelp "PRIVMSG $chan :Google found no results"
}
}
}
return 1
}
proc dehex {string} {
regsub -all {[\[]} $string "\(" string
regsub -all {[\]]} $string "\)" string
regsub -all {^\{|\}$} $string "" string
set string [subst [regsub -nocase -all {\\u([a-f0-9]{4})} $string {[format %c [decimal \1]]}]]
set string [subst [regsub -nocase -all {\%([a-f0-9]{2})} $string {[format %c [decimal \1]]}]]
set string [subst [regsub -nocase -all {\&#([0-9]{2});} $string {[format %c \1]}]]
set string [subst [regsub -nocase -all {\&#x([0-9]{2});} $string {[format %c [decimal \1]]}]]
set string [string map {" \" · · & & <b> \002 </b> \002 – – » \
» « « Ü Ü ü ü Á Á á á É É é é Í Í í \
í Ó Ó ó ó Ñ Ñ ñ ñ Ú Ú ú ú æ æ " " ' \' \
\( \002\(\002 \) \002\)\002 \{ \002\{\002 \} \002\}\002} $string]
return $string
}
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 - ${cmdchar}google google
bind pub - ${cmdchar}gimage gimage
proc youtube {nick host hand chan text} { googleweb $nick $host $hand $chan "" $text youtube.com/watch }
foreach bind [binds youtube] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
bind pub - ${cmdchar}youtube youtube
putlog "Google script loaded"
It's a 403 error. That means someone is banning you from accessing google, maybe a proxy? Are you sure the API key and the search ID work? It works flawlessly on my endSlaSerX wrote:i try but
20<SlaSerX>30 .google linux
18<Test118> Error querying Google: 403 -> ok
20<SlaSerX>30 .google test
18<Test118> Error querying Google: 403 -> ok
i setup my api and etc
Code: Select all
(2020-12-22 13:27:56) CP1832: .youtube elephant stone
(2020-12-22 13:28:00) BOT: The Stone Roses - Elephant Stone https://www.youtube.com/watch?v=LcyK-edUByk
This should be sufficient.SlaSerX wrote:from where u take api and token from google console ?