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 

Markov Chain'ish Script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Rash
Voice


Joined: 20 Jan 2022
Posts: 6

PostPosted: Fri Jun 24, 2022 8:22 pm    Post subject: Markov Chain'ish Script Reply with quote

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?
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1193

PostPosted: Sat Jun 25, 2022 7:31 am    Post subject: Re: Markov Chain'ish Script Reply with quote

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 !
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 831
Location: Tennessee, USA

PostPosted: Sat Jun 25, 2022 1:08 pm    Post subject: Read random file line Reply with quote

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

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

# 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
.
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1193

PostPosted: Sat Jun 25, 2022 3:55 pm    Post subject: Re: Read random file line Reply with quote

SpiKe^^ wrote:

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


Wow ... I sure recognized the style! Smile 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 !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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