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.

CT-Google.tcl

Support & discussion of released scripts, and announcements of new releases.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

CT-Google.tcl

Post by ComputerTech »

So i thought it would be better to start a fresh post about CT-Google.tcl since it currently seems to be one of the only working google scripts.

Download


---------------------------------------------------
Requirements

A Standard Google Account
Custom search API Key
Engine ID
---------------------------------------------------

---------------------------------------------------
Start of Setup Guide

(1): https://developers.google.com/custom-search/v1/overview

(2): Scroll down and Click "Get a key".

(3): Copy your New API Key.

( ): API Key gained.
---------------------------------------------------

(1): https://cse.google.com/cse/create/new

(2): Enter in Sites to search *.google.com

(3): Click Create.

(4): from the right of Modify your search engine Click Control Panel.

(5): Scroll down and click Copy to clipboard

(6): Scroll down to Search the entire web and turn it On

( ): Engine ID Gained
---------------------------------------------------
End of Setup Guide

Then simply copy and paste both the API and ID into the correct places on the Script :wink:


Any suggestions and bug reports are more than welcome :P
Last edited by ComputerTech on Mon Apr 05, 2021 2:08 pm, edited 1 time in total.
ComputerTech
G
Goga
Halfop
Posts: 84
Joined: Sat Sep 19, 2020 2:12 am

!Google

Post by Goga »

Today I received this Error while i do !Google something
Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Offtopic: better to keep any new posts about CT-Google here, and not in
http://forum.egghelp.org/viewtopic.php?t=20942&start=30


Ontopic: have you used over 100 searches within 24 hours? as the limit is 100 daily. :P


Tested working code:

Code: Select all

######################################################################################
# CT-Google.tcl
######################################################################################
#Author    ComputerTech
#IRC       Irc.DareNet.Org  #ComputerTech
#Email     ComputerTech@DareNet.Org
#GitHub    https://github.com/computertech312
#Version   0.3
#Released  21/03/2021
######################################################################################
# Description:
#
#               - An Elaborate Google Search Script.
#               - After 100 usages of the script, it will automatically stop until the next day.
#               - Grab your own API key from here
#                 https://developers.google.com/custom-search/v1/overview
#               - And a Engine ID from here
#                 https://cse.google.com/cse/
#
# Credits:
#
#               - Special thanks to launchd, spyda and CrazyCat.
#
# History:
#
#               - 0.3: Added Max results option.
#               - 0.2: Fixed a few minor bugs.
#               - 0.1: First release.
#
######################################################################################
# Start Of Configuration #
##########################
# Set trigger of the script.
##
set ctgg(trig) "!google"


###################
# Set flag for Commands.
##
# Owner     = n
# Master    = m
# Op        = o
# Voice     = v
# Friend    = f
# Everyone  = -
##
set ctgg(flag) "-"


###################
# Set API Key
##
set ctgg(api) "Your-API-Key"


##################
# Set Engine ID
##
set ctgg(id) "Your-Engine-ID"


##################
# Set to use Notice Or Privmsg for Output of Commands
##
# 0 = Notice
# 1 = Privmsg
# 2 = Channel
##
set ctgg(msg) "2"


##################
# Set amount of results to output
##
set ctgg(max) "3"


########################
# End Of Configuration #
######################################################################################

bind PUB $ctgg(flag) $ctgg(trig) goo:gle

package require json
package require tls
package require http

proc goo:gle {nick host hand chan text} {
   global ctgg google
   set ::google "\00302G\00304o\00308o\00302g\00303l\00304e\003"
   http::register https 443 [list ::tls::socket]
   set url "https://www.googleapis.com/customsearch/v1?key=$ctgg(api)&cx=$ctgg(id)&q=[join $text +]"
   set data "[http::data [http::geturl "$url" -timeout 10000]]"
    http::cleanup $data
   set datadict [::json::json2dict $data]
   set items2 [dict get $datadict "searchInformation"]
          switch -- $ctgg(msg) {
         "0" {set ctgg(output) "NOTICE $nick "}
         "1" {set ctgg(output) "PRIVMSG $nick"}
         "2" {set ctgg(output) "PRIVMSG $chan"}
      }
    set time [dict get $items2 "formattedSearchTime"]
    set total [dict get $items2 "formattedTotalResults"]
    putserv "$ctgg(output) :$google  About $total results ($time seconds)"
    set items [dict get $datadict "items"]
   for {set i 0} {$i < $ctgg(max)} {incr i} {
      set item [lindex $items $i]
      set title [dict get $item "title"]
      set link [dict get $item "link"]
      set info [dict get $item "snippet"]
      putserv "$ctgg(output) : $title / $link / $info"
   }
      http::unregister https
}
putlog "$::google.tcl v0.3 by ComputerTech Loaded"
######################################################################################
ComputerTech
G
Goga
Halfop
Posts: 84
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

Error Is :

Code: Select all

Tcl error [goo:gle]: unsupported url type "https"
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

I'll try look at it in a bit to see what the problem is :wink:
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Goga, i do not see the problem you are facing.

Code: Select all

20<ComputerTech>30 !google eggdrop github
18<CX18> 02G04o08o02g03l04e  About 35,600 results (0.43 seconds)
18<CX18>  eggheads/eggdrop: The Eggdrop IRC Bot - GitHub / https://github.com/eggheads/eggdrop / May 5, 2021 ... The Eggdrop IRC Bot. Contribute to eggheads/eggdrop development by creating an account on GitHub.
18<CX18>  Eggheads / https://www.eggheads.org/ / Eggdrop is the oldest Internet Relay Chat (IRC) bot still in active development. Originally created by Robey Pointer in December 1993 for use on a channel ...
18<CX18>  eggheads/eggdrop-docker - GitHub / https://github.com/eggheads/eggdrop-docker / eggdrop-docker. This is the Git repo for the official Docker image of Eggdrop, the Internet's oldest IRC bot still under active development.
Perhaps your Engine ID or API is invalid?
ComputerTech
G
Goga
Halfop
Posts: 84
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

Can you give me hint what could be the Problem is ? I am getting these two ERRORs.

Code: Select all

Tcl error [goo:gle]: key "items" not known in dictionary
 Tcl error [goo:gle]: key "items" not known in dictionary
 Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
 Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587

User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

The only possible cause is a invalid Engine ID or API key, try getting another Engine ID.
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

If you're confused on how to create a new Engine ID, use this one

Code: Select all

ddd815d6eed4ec2ff
:)
ComputerTech
G
Goga
Halfop
Posts: 84
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

Code: Select all

[05:21:59] Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
[05:23:14] Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
[05:23:24] Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
[05:23:40] Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
[05:24:18] Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
[05:28:18] Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Obviously the problem is on your side and not the script, as it works perfectly for me, have you tried the suggestions I suggested? or i don't know maybe .restart your bot?
ComputerTech
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

I have the script spitting out the following error.

Tcl error [goo:gle]: unsupported url type "https"
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Dominatez wrote:I have the script spitting out the following error.

Tcl error [goo:gle]: unsupported url type "https"
Do you have the tls package installed/loaded on your bot/server?

Code: Select all

.tcl package require tls
Should return what version of tls you have.
ComputerTech
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Yes i do.

I have Tcl: 1.7.20 installed

I changed the

set ctgg(max) "5"

To 5

It has started spitting the error out when i changed it to that.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Not sure what the problem is on your end, as when i set the max variable to 5 and here's the results.

Code: Select all

<ComputerTech> !google lego
<Eggdrop> Google  About 5,760,000,000 results (0.50 seconds)
<Eggdrop>  Home | Official LEGO® Shop US / https://www.lego.com/en-us / Explore the world of LEGO® through games, videos, products and more! Shop awesome LEGO® building toys and brick sets and find the perfect gift for your kid.
<Eggdrop>  LEGO IDEAS - Home / https://ideas.lego.com/ / Skip to main content. LEGO IDEAS Logo. Explore. Blog. How It Works. Me. Log In. Log in Create account. LEGO IDEAS Logo.
<Eggdrop>  Themes | Official LEGO® Shop US / https://www.lego.com/en-us/themes / Develop children's creativity with LEGO® Classic. Sets contain ideas to help them get started, while special pieces alongside classic LEGO bricks inspire even ...
<Eggdrop>  LEGO® Education: Classroom Solutions for STEM and STEAM / https://education.lego.com/ / LEGO® Education solutions teach children 21st century skills for future success, starting with preschool and moving through elementary, middle and high ...
<Eggdrop>  Sonic the Hedgehog™ – Green Hill Zone 21331 | Ideas - LEGO / https://www.lego.com/en-us/product/sonic-the-hedgehog-green-hill-zone-21331 / Get in the brick-built zone of an iconic 1990s game.
And here is the package versions.

Code: Select all

<ComputerTech> .tcl package require tls
<Eggdrop> Tcl: 1.7.20
<ComputerTech> .tcl package require http
<Eggdrop> Tcl: 2.9.1
<ComputerTech> .tcl package require json
<Eggdrop> Tcl: 1.3.4
Can you show me your package versions perhaps?
ComputerTech
Post Reply