mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
Hello, I need some help with this little script plz.
I made this from topic I read
Quote:
on *:text:*whatever - Type !take* to whatever.:#: if ($nick == MyNickName) { msg # !take* }



Here is my goal, there is a number behind this * at the end of !take and I need to copy paste this number in my msg or copy paste the whole !take(with the number ofc)

It's a number from 1 to 99.

If anyone could help me please.
Thankyou for your time.

Last edited by Truc; 01/06/15 01:55 AM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Can you give an example sentence and what you want to capture from it?

Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
thx for your answer there is a full example

- 1 - Bot > Truc drop an Item - Type !take10 to take the Item.

- 2 - Trucluc > !take10

So, someone drop and item and bot answer with a number from 1 to 99 at the end of !take, then someone esle can write !take10 to take the Item.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Ok, this should capture a number from 0-99. At the moment I can't think of a way to capture 1-99 using only regex, but this will exit if the number is 0, so basically the same thing

Code:
on *:TEXT:*:#: {
if ($regex($1-,/^!take([1-9]?[0-9])$/i)) { 
var %number = $regml(1) 
if (%number == 0) { return }

}

}

Last edited by Sakana; 01/06/15 12:59 PM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
/^!take([1-9][0-9]?)$/i looks ok to me, to match 1-99, just put the '?' on the second [0-9] character class, which can be written as \d btw.

/^!take([1-9]\d?)$/i


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Oh, of course. Derppp^_^

Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
thx both of u it works almost perfectly.
This code just work if the message it's "!take(number)" but in a complet sentense like in my example it doesnt work.

I have 3 issues:
1- do the code only, if ($nick == Bot)
2-find the number in any full sentence or juste in the example
3- write it with !take { msg # take$regml(1) } this doesnt work and I dont know how write text + var

I'm sorry for probably dumb question like the "third" issues but I'm very new at it.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Try this
Code:
on *:TEXT:*:#: {
if ($regex($1-,/!take([1-9]\d?)/i)) { 
if ($nick != BOT) { return }
var %number = $regml(1) 
msg # take $+ %number
   }
}

Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
It works perfectly thx you smile


Link Copied to Clipboard