| View previous topic :: View next topic |
| Author |
Message |
b4ugobye Voice
Joined: 25 May 2006 Posts: 5
|
Posted: Thu May 25, 2006 7:59 pm Post subject: factbot based on chuck norris script |
|
|
I'm trying to make a fact bot off the idea of the chuck norris facts script by Outz.
my desired outcome:
| Quote: |
!fact <nick>
<nick> once did open heart surgery... on himself.
|
the script so far:
| Code: |
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 |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Thu May 25, 2006 8:49 pm Post subject: |
|
|
| the bind is calling "pub_fact", proc named "pub_chuck" won't work |
|
| Back to top |
|
 |
b4ugobye Voice
Joined: 25 May 2006 Posts: 5
|
Posted: Thu May 25, 2006 9:00 pm Post subject: pub_chuck was typo.. |
|
|
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. |
|
| Back to top |
|
 |
b4ugobye Voice
Joined: 25 May 2006 Posts: 5
|
Posted: Thu May 25, 2006 9:32 pm Post subject: ... |
|
|
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 } |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Thu May 25, 2006 10:48 pm Post subject: Re: ... |
|
|
| 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. |
|
| Back to top |
|
 |
krimson Halfop

Joined: 19 Apr 2006 Posts: 86
|
Posted: Fri May 26, 2006 1:31 am Post subject: |
|
|
| Quote: | $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 |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 26, 2006 2:26 am Post subject: |
|
|
The following should pull a random line from ~/eggdrop/fact.txt
| Code: | 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"
} |
|
|
| Back to top |
|
 |
b4ugobye Voice
Joined: 25 May 2006 Posts: 5
|
Posted: Fri May 26, 2006 1:20 pm Post subject: ty, but i need the other step |
|
|
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. |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 26, 2006 1:52 pm Post subject: |
|
|
| putserv "privmsg $c $n $randline" |
|
| Back to top |
|
 |
b4ugobye Voice
Joined: 25 May 2006 Posts: 5
|
Posted: Fri May 26, 2006 5:17 pm Post subject: not exactly |
|
|
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: |
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"
}
|
|
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Sat May 27, 2006 2:43 am Post subject: |
|
|
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: | 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"
} |
|
|
| Back to top |
|
 |
|