mIRC Home    About    Download    Register    News    Help

Print Thread
#228818 11/01/11 03:48 PM
Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Hi.

I have an away script, which put me on away when I change my nick to mynick-away, it does not output any message in the channel, which is fine.

What i'm after is a random message, when I change to away, and possibly with a random timer on when the message is outputted.

Is this possible? and I hope I explained myself okay.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try this:

Code:
on *:nick: {
  if ($newnick == $me && *-away iswm $newnick) {
    .timer 1 $rand(5,30) msg #somechannel $read(away.txt)
  }
}


Then, create a file called away.txt and insert any messages you want. They will be randomly displayed. You can use this command to easily add the messages-

/write away.txt Some message here.

(Repeat for every message you want)

Things you'll need to change-
* Change #somechannel to the channel you want the message to be sent to. If you want it sent to all active channels, the script would need to be adjusted to loop through $chan().

* Change $rand(5,30) to the time range you want to randomly use. As-is, this will display the message somewhere between 5 and 30 seconds.

One last thing-
This doesn't check whether or not you're still in the channel. So if you change your nick to *-away and then leave the channel before the timer triggers, you'll send the message while no longer in the channel (if the channel allows external messages). Depending on the channel, that may be inappropriate. Or, if you change your nick and then disconnect before the timer triggers, you will get an error message that you are not connected. Either of these things can be included in the script, but it's probably not necessary. In most cases, you're not going to change your nick to *-away and then part the channel or disconnect. But, if you need that functionality, just ask.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Thank you very much, I will test this out later.

Thanks once again.

Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Could some of this, be used for an alias, say I wanted an alias like
Code:
 /f1 /say Sorry, but the channel is in +m stay tuned

where
Code:
Sorry, but the channel is in +m stay tuned

would just be one sentence out of a random list, I mean, every time I press f1 it would choose a random line from a given txt document.

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Yes. Create a tekst file (e.g. file.txt) and put the random lines in there. Then change your alias to:

/F1 /say $read(file.txt,n)

Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Doh, why didn't I think of that, now I feel a bit silly, but thanks alot for your answer.

*EDIT* Will it pick random order, or just read from first line and down?

Last edited by starpossen; 28/02/11 04:21 PM.
Joined: Sep 2006
Posts: 59
R
Babel fish
Offline
Babel fish
R
Joined: Sep 2006
Posts: 59
It will pick a random line out of the text file

Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Thanks for the reply, and yes, it's working to my needs.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
If you don't have many random lines to display, you can use something like this:
Code:
$gettok(stay tuned;2nd random line;3rd random line,$r(1,3),59)
depending on how many responses you have, you will then change the number 3 in the $r(). In this example, we have three lines, so we put 3 there. The code will then randomize the lines from 1 to 3. Every response is divided by a ; punctuation character.


Link Copied to Clipboard