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.

factbot based on chuck norris script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
b
b4ugobye
Voice
Posts: 5
Joined: Thu May 25, 2006 7:50 pm

factbot based on chuck norris script

Post by b4ugobye »

I'm trying to make a fact bot off the idea of the chuck norris facts script by Outz.
my desired outcome:
!fact <nick>
<nick> once did open heart surgery... on himself.
the script so far:

Code: Select all

bind pub - !fact pub_fact

proc pub_fact {nick mask hand channel args} {
   global fact
   puthelp "PRIVMSG $channel :[lindex $fact [rand [llength $fact]]]"
   }

set fact {

"\" 's tears cure cancer. Too bad he has never cried. Ever.\""
_______________________________________________--
I am a total newb when it comes to tcl... if it were irc scripting, it would have been up and running... lol... I tried a few things and just ended up with errors. I did at least try, so I'm not just someone who wants ppl to do work for me, just know somone else can look at this and redo it in a matter of a minute. And that would make my life so much easier. So please someone hook me up with a moment of your time and post a solution for my needs.
Last edited by b4ugobye on Thu May 25, 2006 8:55 pm, edited 1 time in total.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

the bind is calling "pub_fact", proc named "pub_chuck" won't work
b
b4ugobye
Voice
Posts: 5
Joined: Thu May 25, 2006 7:50 pm

pub_chuck was typo..

Post by b4ugobye »

missed that edit, but fixed... normally the chuck script reads a random line from the set fact (set chuck previously)
eg: "\"Chuck Norris is not Politically Correct He is just Correct Always.\""

my goal is to make the trigger !fact <nick>
so when you do !fact b4ugobye:
it sends to chan:
b4ugobye (read from set facts)is not Politically Correct He is just Correct Always.
b
b4ugobye
Voice
Posts: 5
Joined: Thu May 25, 2006 7:50 pm

...

Post by b4ugobye »

in reality, I just need this one line converted to tcl, then I can make a txt file named facts.txt.

On *:TEXT:!fact*:#: Set %fact $read(facts.txt) | /msg $chan $2 %fact }
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Re: ...

Post by DragnLord »

b4ugobye wrote:in reality, I just need this one line converted to tcl, then I can make a txt file named facts.txt.

On *:TEXT:!fact*:#: Set %fact $read(facts.txt) | /msg $chan $2 %fact }
Ok, please convert all the variable to expanded functions first. Quite a lot of us do not use that IRC client. so you have to epand out what "%fact" and "$read" actually are.
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

$read(filename, [ntswrp], [matchtext], [N])

Returns a single line of text from a file.

This identifier works in conjunction with the /write command.

//echo $read(funny.txt)

Reads a random line from the file funny.txt.

[........]

If the n switch is specified then the line read in will not be evaluated and will be treated as plain text.

If the p switch is specified, command | separators are treated as such instead of as plain text.

If the first line in the file is a number, it must represent the total number of lines in the file. If you specify N = 0, mIRC returns the value of the first line if it's a number.

If the t switch is specified then mIRC will treat the first line in the file as plain text, even if it is a number.
%fact is just a variable
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

The following should pull a random line from ~/eggdrop/fact.txt

Code: Select all

bind pub - !fact pub_fact

proc pub_fact {n u h c t} {
  set fl [open fact.txt]
  set data [read $fl]
  close $fl
  set lines [split $data \n]
  set randline [lindex $lines [rand [llength $lines]]] 
  putserv "privmsg $c $randline"
}
b
b4ugobye
Voice
Posts: 5
Joined: Thu May 25, 2006 7:50 pm

ty, but i need the other step

Post by b4ugobye »

thats what I'm looking for except I want to make it personalize so if someone types !fact bob .... it will say bob then the fact..

so i think i need a set line to set whatever is typed after !fact

final output: putserv "privmsg $c $factnick $randline"


something along that line. Sorry to be a pain.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

putserv "privmsg $c $n $randline"
b
b4ugobye
Voice
Posts: 5
Joined: Thu May 25, 2006 7:50 pm

not exactly

Post by b4ugobye »

below is example of what it should do (b4ugobye)(done with irc) and what the above code gives (factbot)

<@himself> !fact Maniac
<@b4ugobye> Maniac can win a game of Connect Four in only three moves.
<+Factbot> himself does not sleep. He waits.

****
tried a few more things, and finally got it.

Code: Select all

bind pub - !fact pub_fact 
proc pub_fact {n u h c arg} { 
set fl [open fact.txt] 
set data [read $fl] 
set arg [split $arg] 
set x [lindex $arg 0] 
close $fl 
set lines [split $data \n] 
set randline [lindex $lines [rand [llength $lines]]] 
putserv "privmsg $c $x $randline"
}
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Thought i'm not sure how it would work since you don't use ":" (which _should_ make the ircd only send the first word)

Here is a more compact and cleaner version of what you had:

Code: Select all

bind pub - !fact pub_fact
proc pub_fact {n u h c arg} {
  if {![llength [set target [lindex [split $arg] 0]]]} {
    set target $n
  }
  set data [split [read [set fd [open fact.txt]]] \n][close $fd]
  set randline [lindex $data [rand [llength $data]]]
  putserv "privmsg $c :$target $randline"
}
Post Reply