mIRC Home    About    Download    Register    News    Help

Print Thread
Help Script code !!! #130999 24/09/05 08:48 AM
Joined: Sep 2005
Posts: 5
K
krisd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
K
Joined: Sep 2005
Posts: 5
Hello,

I was recently helped by Raimus2 with some code and it works very well.

I would appreciate help with further enhancement of this with the following:

i used the same above to strip 2min 3 sec in the line below but unfortunately doesn't work

<nick>AutoReply : Buffalo was milked 2min 3 sec ago

i want to be able to strip the numbers in min and sec and assign them to %min and %sec


<nick>AutoReply : Buffalo was milked 2min ago

on *:text:AutoReply*:#pets: {
if ($istok($1-,ago,32)) {
set %min $gettok($gettok($1-,$calc($findtok($1-,ago,32) - 1),32),1,109)
}
}

so its sets %min to 2

This would work for the line above but not when its in the formats:

<nick> Buffalo was milked 2min 3sec ago
<nick> Buffalo was milked 3sec ago

how can i code to include all formats: 2min ago,2min 3sec, 3sec ago
and assign the numbers to %min and %sec

Thanks for any help

Re: Help Script code !!! #131000 24/09/05 10:08 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
on *:TEXT:AutoReply ? Buffalo was milked * ago:#pets: {
set %min $iif((*min* iswm $6-),$gettok($left($6-,$calc($pos($6-,min,1) - 1)),-1,32),0)
set %sec $iif((*sec* iswm $6-),$gettok($left($6-,$calc($pos($6-,sec,1) - 1)),-1,32),0)
}

The above should (fingers crossed) deal with all the following
2min
2min 3sec
2min 3 sec
2 min
2 min 3sec
2 min 3 sec
3sec
3 sec

if case you want to know what its doing
the $iif sees if there is a *min* wildmatch to $6- ($6- is the words after "milked"),
if there is one of them it gets this value $gettok($left($6-,$calc($pos($6-,min,1) - 1)),-1,32)
that value is broken down as follows
$6- might be 12 min 5sec ago
$pos($6-,min,1) FIND THE first occurance of MIN 4
$calc( ^ - 1) get the position before than MIN 3
$left($6-, ^ ) get the string up to that position 12<space>
$gettok( ^ ,-1,32) get the last token in that string based on spaces seperating the token 12

Re: Help Script code !!! #131001 24/09/05 09:41 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline
Fjord artisan
Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
Code:
 on $*:text:/.*buffalo was milked (\n+)\s*(?:min|sec)(?:\s*(\n+)\s*sec)\s*ago/i:*: {
set %sec $iif($regml(2),$regml(2),$regml(1)
set %min $iif($regml(2),$regml(1))
}

UNTESTED
edit: the above didnt work, this should work (but be warned, people can say buffalo 532424min 64325123456sec (ect) and it changes the values, i suggest using a "if ($nick != nick) return"
Code:
on *:text:*buffalo*:*:{
  tokenize 32 $replace($1-,$chr(32),)
  if ($regex(min,$1-,/([0-9]+)min/)) {
    set %min $regml(min,1)
  }
  if ($regex(sec,$1-,/([0-9]+)sec/)) {
    set %sec $regml(sec,1)
  }
}

Last edited by IR_n00b; 24/09/05 10:04 PM.
Re: Help Script code !!! #131002 24/09/05 09:56 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
1) You're missing a ) on line 2.
2) \n matches a newline ($lf) in regex, not a digit as you seem to expect. \d matches a digit.

Re: Help Script code !!! #131003 24/09/05 10:05 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline
Fjord artisan
Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
heh, i havent used regexes for a long time :\