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
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Code: Select all

.tcl package require http
Tcl: 2.10a1
.tcl package require json
Tcl: 1.3.3
.tcl package require tls 
Tcl: 1.7.20
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Well your package versions are slightly older than mine, but i really doubt that would be the cause of this problem. :lol:

This problem only happens when the variable is set to 5 correct? Plus did you try search another term? perhaps like "LEGO" for example, or something more popular perhaps.
ComputerTech
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Hi,

Tried Searching Lego or anything at all, and it throws that error. 4 and below is fine.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Weird, as it's working just fine for me, i'll get another server of mine and try install the packages the same version that you have and try that. :roll:
ComputerTech
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

If it helps. It is running on my own personal sever which is running

Ubuntu 20.04.03 LTS Focal
TCL Version 8.6
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Yeah, i'm running Ubuntu 20.04 too, so that isn't the problem in my opinion, haven't had time yet to run another eggdrop on another server just yet, but i'll try make some time later. :P
ComputerTech
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Thanks ComputerTech for taking the time.
G
Goga
Halfop
Posts: 84
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

Code: Select all

[09:53:48] Tcl error in file 'eggdrop.conf':
 [09:53:48] can't read "::google": no such variable
     while executing
 "putlog "$::google.tcl v0.3 by ComputerTech Loaded""
     (file "scripts/search.tcl" line 116)
     invoked from within
 "source scripts/search.tcl"
     (file "eggdrop.conf" line 210)
 [09:53:48] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
Help Please...
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Have you put the API Key In ?

And have you put in the Engine ID key in ?
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

There is an error in the last line of the script:

Code: Select all

putlog "$::google.tcl v0.3 by ComputerTech Loaded"
Must be:

Code: Select all

putlog "CT-google.tcl v0.3 by ComputerTech Loaded"
G
Goga
Halfop
Posts: 84
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

You are always Right, CrazyCat :)
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

New release of CT-google(it's now called Googler), feel free to reply with bugs or suggestions. 8)

Code: Select all

######################################################################################
# Googler.tcl
######################################################################################
#Author    ComputerTech
#IRC       ircs://irc.rizon.net:6697/computertech
#Email     computertech312@gmail.com
#GitHub    https://github.com/computertech312
#Version   0.4
#Released  03/03/2023
######################################################################################
# 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/
#              
# History:
#
#               - 0.4: Added safesearch option and fixed/improved code.
#               - 0.3: Added Max results option.
#               - 0.2: Fixed a few minor bugs.
#               - 0.1: First release.
#
######################################################################################

namespace eval Googler {

    #########################
	# Start of configuration.
	##
	
    # Set the trigger command for the script
    variable trig !google
    
    # Set the flags for the script
    variable flags ofmn
    
    # Set the API key for the Google Custom Search API
    variable api_key "Your-API-Key"
    
    # Set the ID for the search engine associated with the API key
    variable engine_id "Your-Engine-ID"
    
    # Set the message type for the script
    #
    # The message type determines whether the output should be sent as a notice
    # to the user, a private message to the user, or a message to the channel.
    #
    # 0 = notice
    # 1 = private message
    # 2 = channel message
    variable message_type 2
    
    # Set the maximum number of search results to display
    #
    # This setting determines the maximum number of search results to display
    # in the output. The default is 3, but it can be set to any positive integer.
    variable max_results 3
    
    # Set the safe search mode for the script
    #
    # The safe search mode determines how explicit or potentially offensive
    # search results should be filtered. The available options are:
    #
    # "off": No filtering is applied.
    # "medium": Potentially explicit results are filtered, but not offensive
    #            content that is considered safe by some users.
    # "high": All explicit or potentially offensive content is filtered.
    #
    # The default setting is "high".
    variable safe_search "high"
	
	# Set logo 
	variable logo "\0032G\0034o\0038o\0032g\0033l\0034e\003"
	
	#########################
	## End of configuration.
	
    package require json
    package require tls
    package require http
    bind PUB $flags $trig [namespace current]::google_search
	
	proc google_search {nick host hand chan text} {
	http::register https 443 [list ::tls::socket]
	variable data [http::data [http::geturl "https://www.googleapis.com/customsearch/v1?[::http::formatQuery key $::Googler::api_key cx $::Googler::engine_id q [join $text +] safe $::Googler::safe_search]" -timeout 10000]]
	variable result_dict [::json::json2dict $data]
	variable search_info [dict get $result_dict "searchInformation"]
	variable search_results [dict get $result_dict "items"]
	variable num_results [dict get $search_info "formattedTotalResults"]
	variable search_time [dict get $search_info "formattedSearchTime"]
	switch -- $::Googler::message_type {
        "0" {set output "NOTICE $nick"}
        "1" {set output "PRIVMSG $nick"}
        "2" {set output "PRIVMSG $chan"}
    }
	variable output_string "$::Googler::logo About $num_results results ($search_time seconds)"
	putserv "$output :$output_string"
    foreach result [lrange $search_results 0 [expr {$::Googler::max_results - 1}]] {
        set title [dict get $result "title"]
        set link [dict get $result "link"]
        set snippet [dict get $result "snippet"]
        putserv "$output :$title / $link / $snippet"
    }
    http::unregister https
    http::cleanup $data
    
    putlog "$::Googler::logo.tcl v0.4 by ComputerTech Loaded"
   }
}
ComputerTech
B
Bosco
Voice
Posts: 9
Joined: Mon Oct 31, 2022 10:57 pm

Post by Bosco »

work good for me 0.4
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Bosco wrote:work good for me 0.4
Awesome to hear! 8)
ComputerTech
Post Reply