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 

CT-Google.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Sun Mar 28, 2021 9:33 pm    Post subject: CT-Google.tcl Reply with quote

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 Razz
_________________
ComputerTech


Last edited by ComputerTech on Mon Apr 05, 2021 2:08 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Goga
Voice


Joined: 19 Sep 2020
Posts: 35

PostPosted: Mon Apr 05, 2021 5:28 am    Post subject: !Google Reply with quote

Today I received this Error while i do !Google something
Tcl error [goo:gle]: error reading "sock10": Unknown error: 50327587
Back to top
View user's profile Send private message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Mon Apr 05, 2021 2:06 pm    Post subject: Reply with quote

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. Razz


Tested working code:
Code:

######################################################################################
# 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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
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