mIRC Home    About    Download    Register    News    Help

Print Thread
#84137 25/05/04 11:26 PM
Joined: Feb 2004
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2004
Posts: 9
how would i go about doing this, someone types
!Quote <nick>
and the bot would echo back something that <nick> said in the channel, also if someone typed
!Quote <nick> , <word>
the bot would echo something said by <nick> with <word> in it....thanks for any help

#84138 26/05/04 12:36 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hello,

this might be something helpful for you:

Go to Start --> Run --> wordpad.exe and paste the following code in there.
Then copy paste from WordPad to your mIRC Scripts Editor Remote (in mIRC: alt+r --> Remote)
Code:
 
menu channel {
  .$iif($group(#quotes) == on,Disable,Enable) Quotes Script:{
    $iif($group(#quotes) == on,disable,enable) #quotes
  }
}
alias AddQuote { 
  if (!$1) { echo -a Error: You have to specify a nickname. | return }
  if ($2 == $null) { echo -a Error: You have to specify a quote. | return }
  write quotes.txt $+($1,=,$2-)
}
 [color:red]  [/color] 
#quotes on
on *:TEXT:!quote *:#:{
  if ($2 != $null) {
    if !$window(@quotes) { window -h @quotes }
    filter -fwc quotes.txt @quotes $+($2,=,*,$3-,*) 
    if !$filtered { msg # Sorry $nick but I didn't find any match for $2 | return }
    tokenize 61 $line(@quotes,$r(1,$line(@quotes,0)))
    msg # $+(Quote by $1,: ",$2-,") 
  }
}
#quotes end

There are 2 ways of adding quotes to the quotes.txt file:

1) Manually editing the quotes.txt file
2) Using the alias /AddQuote <nickname> <quote> without the <>


Explanation of the script: !quote <nick> [matchtext]

1.
If people type: !quote nickname then the script will filter all matches from the quotes.txt file to a hidden window called @quotes. It will then take a random line from that window (if any), and message it to the channel.

If people type: !quote nickname matchtext then the script will filter all matches for not only the nickname but for the specified matchtext as well together. Once again the script will then msg a random line (if any) to the channel.

2.
You can Enable/Disable the script by right clicking in a channel window.

3.
Important: the way the script is setup now, is that your script will trigger on ANY channel that you are in. Perhaps you can put your channels in a variable like /set %quotechans #chan1,#chan2,... and then use

on *:TEXT:!quote *:%quotechans: {

or simply manually put: on *:TEXT:!quote *:#chan1,#chan2: {

4.
Note that people could take advantage of this by getting you flooded off the server, due to excessive quote requests.

Greetz

Last edited by FiberOPtics; 26/05/04 12:48 PM.

Gone.
#84139 26/05/04 03:18 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
By the way,

you could change this line : tokenize 61 $line(@quotes,$r(1,$line(@quotes,0)))
to this one : tokenize 61 $line(@quotes,$r(1,$filtered))

I made a new post cuz I couldn't edit my previous one anymore.

Greetz



Gone.
#84140 26/05/04 10:49 PM
Joined: Feb 2004
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2004
Posts: 9
thanks a bunch man, that helped alot with my bot, and thanks for explaining it so thouroughly, it makes it easier to mod the code if need be, thanks again.... grin

#84141 26/05/04 11:15 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
You're welcome!

Cya


Gone.
#84142 26/05/04 11:25 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
* Zyzzyx26 pops in and asks a quick question
Code:
$line(@quotes,[color:red]$r[/color](1,$filtered))
What does that $r do there? smile

Thanks, Zyzzy.


"All we are saying is give peace a chance" -- John Lennon
#84143 26/05/04 11:27 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

$r is just a shorter word for $rand, though it is undocumented in the help file.

Greetz


Gone.
#84144 26/05/04 11:29 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Oh, interesting smile

Thanks!


"All we are saying is give peace a chance" -- John Lennon
#84145 26/05/04 11:42 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I did some research in the full versions.txt and found this:

24/10/95 - mIRC v3.72
...
24.Added $r(v1,v2) identifier, returns random number
or letter between v1 and v2.

Cya


Gone.
#84146 26/05/04 11:50 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Cool laugh

thanks for the explanation! wink

Zyzzy.


"All we are saying is give peace a chance" -- John Lennon

Link Copied to Clipboard