mathetes-pipe.tcl

mathetes-pipe.tcl

Old eggdrop script that was made to chat with an AI bot over the web.

Postat de Copyright Categorie Review user Vizualizari Data
ircfan Pistos sockopen Cod testat 210 2026-02-28 00:39:55

# mathetes-pipe.tcl

# by Pistos
# http://purepistos.net/mathetes
# January 10, 2005

# Be sure to put this file AFTER egghttp.tcl is loaded.

# There's no need to change any variables, this script is plug-and-play.
# Just source it in your eggdrop.conf and you're off to the races!

# To have your bot talk, you must directly address it, using its nick.
# For example, if your bot's nick is MyLeetBot, then you go:
# <you> MyLeetBot: Hello!
# You can use either a colon or a comma after the nick, and there must
# be a space after the colon or comma.

# I would appreciate it if you came to irc.freenode.net #mathetes to
# let me know where you're using this script, and how you like the
# chat engine.

# Alternatively: [email protected] or http://purepistos.net/forums

# ----------------------------------------------------------------------

bind pubm -|- "*" pub_mathetes

set mathetes_pipe_version "1.2.0"
# HTTP timeout, in seconds.  Default is 4 minutes (240 seconds)
set mathetes_timeout 240

proc mathetes_http {sock} {
global mathetes_convos
    set headers [egghttp:headers $sock]
    set body [egghttp:data $sock]
    regsub -all "\n" $body "" body
    set nick_chan $mathetes_convos($sock)
    set chan [lindex $nick_chan 0]
    set nick [lindex $nick_chan 1]

    if {[regexp {Mathetes: (.+?)<} "$body" whole_match group_match] == 1} {
        if {[string equal $group_match "</li>"]} {
            putserv "PRIVMSG $chan :$nick: ..."
        } else {
            putserv "PRIVMSG $chan :$nick: $group_match"
        }
    } else {
        putserv "PRIVMSG $chan :I seem to be experiencing technical difficulties.  Tell Pistos, or complain in http://purepistos.net/forums ."
    }
}

proc pub_mathetes {nick uhost handle chan text} {
    global mathetes_convos botnick mathetes_timeout
    
    if {[regexp "(?i)^$botnick\[^ \] *.+" $text matchtext]} {
        regsub "(?i)^$botnick." $text "" text
        set text [string trim $text]
        set sock [egghttp:geturl http://rome.purepistos.net/mathetes/ mathetes_http -query "nick=$nick&input_line=$text" -timeout $mathetes_timeout]
        set mathetes_convos($sock) [list $chan $nick]
    }
    
    #set text [split $text]
    #set first_word [lindex $text 0]
    #if {[string equal $first_word "$botnick:"] || [string equal $first_word "$botnick,"]} {
        #set text [lrange $text 1 end]
        #set sock [egghttp:geturl http://rome.purepistos.net/mathetes/ mathetes_http -query "nick=$nick&input_line=[join $text]" -timeout $mathetes_timeout]
        #set mathetes_convos($sock) [list $chan $nick]
    #}
    
    return 0

}

putlog "mathetes-pipe.tcl v$mathetes_pipe_version by Pistos now loaded."