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.

Markov Chain'ish Script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
R
Rash
Voice
Posts: 6
Joined: Thu Jan 20, 2022 9:10 pm

Markov Chain'ish Script

Post by Rash »

A longtime IRC Friend recently died and I would love to honor his memory by having a bot that spouts out a sentence or two based off of what he previously has said.

I am sure this already exists. I was thinking of a trigger such as Andrew?
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: Markov Chain'ish Script

Post by willyw »

Anything here that will do what you want?

http://tclarchive.org/search.php?Quote
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Read random file line

Post by SpiKe^^ »

Here's something quite basic to work with...

From http://forum.egghelp.org/viewtopic.php?t=20572 (Thanks willyw:)

Code: Select all

# Jan 11, 2019
# http://forum.egghelp.org/viewtopic.php?t=20572
#
# Real simple... just want any user to be able to type !topic making the bot pull a random line from the topic.txt file and post to the channel
# with "Your topic is..." preceding the line.
#
###################################################################


###  config   ###

# set the path/filename to the topic.txt file
set topicfile "scripts/added/experiment_for_somebody/random_line_from_file/topic.txt"


### end config ###




bind pub - "!topic" random_line


#####
proc random_line {nick uhost handle chan text} {
global topicfile


        if {![file exists $topicfile]} {
                putserv "privmsg $chan :Sorry $nick, but $topicfile doesn't exist"
                return 0
        }


        # reference : http://forum.egghelp.org/viewtopic.php?t=6885

        set fp [open $topicfile "r"]
        set data [read -nonewline $fp]
        close $fp

        set lines [split $data "\n"]

        set numlines [llength $lines]

        set num [rand $numlines]
        set randline [lindex $lines $num]


        putserv "privmsg $chan :Your topic is: $randline"

}
#####

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: Read random file line

Post by willyw »

SpiKe^^ wrote: From http://forum.egghelp.org/viewtopic.php?t=20572 (Thanks willyw:)
Wow ... I sure recognized the style! :) But I'd totally forgotten it.

Thank YOU for posting it and the link to that thread.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Post Reply