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"
######################################################################################
Code: Select all
Tcl error [goo:gle]: unsupported url type "https"
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.
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
Code: Select all
ddd815d6eed4ec2ff
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
Do you have the tls package installed/loaded on your bot/server?Dominatez wrote:I have the script spitting out the following error.
Tcl error [goo:gle]: unsupported url type "https"
Code: Select all
.tcl package require tls
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.
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