mIRC Home    About    Download    Register    News    Help

Print Thread
Watch next few lines with ON TEXT triggerd #197912 16/04/08 04:23 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
I thought i saw it somewhere but can't find.
What i'm looking for is how to "watch" a few lines after a ON TEXT is triggerd for specific string (or not if it doesn't come)

Let's say 5 lines would be max to keep track of.

Re: Watch next few lines with ON TEXT triggerd [Re: ots654685] #197922 16/04/08 10:13 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You'd have to set a variable, or something similar...

Code:
on *:text:*:#: {
  if ($1- == original trigger) { set %watch 1 }
  else inc %watch 1
  if ((what you're looking for isin $1-) && (%watch)) { do something }
  if (%watch > 5) { unset %watch }
}


Just as a note, you should probably consider a different variable name (something unique) so it doesn't conflict with other scripts. Also, you may want to specify the channel so it's not counting 5 lines from *any* channel.


Invision Support
#Invision on irc.irchighway.net
Re: Watch next few lines with ON TEXT triggerd [Re: Riamus2] #197942 17/04/08 09:35 AM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
Thanks for your input.
When some example is there it always looks more simple as i was thinking.
I'm going to modify it so it fit my needs also adding your advice about channel name.

Re: Watch next few lines with ON TEXT triggerd [Re: Riamus2] #198140 21/04/08 06:49 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
@Riamus2

I was adding that part to my current script but needed to add it several times so i was thinking making it an alias, can that be done using { return } in it?

example
Code:
on *:text:*:#: {
  if (*sampletext* iswm $strip($1-)) { /watch | /nextstep }
}
alias watch {
  set %watch 1
  else inc %watch 1
  if ((what you're looking for isin $1-) && (%watch)) { return }
  if (%watch > 5) { unset %watch }
}

above piece looks like rubbish i think and isn't gonna work, or is it?

Last edited by ots654685; 21/04/08 06:49 PM.
Re: Watch next few lines with ON TEXT triggerd [Re: ots654685] #198153 21/04/08 11:25 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, you can use an alias... something like this probably:

Code:
on *:text:*:#: {
  Watch $1-
  if ((what you're looking for isin $1-) && (%watch)) { do something }
}

alias Watch {
  if ($1- == original trigger) { set %watch 1 }
  else inc %watch 1
  if (%watch > 5) { unset %watch }
}


This should give you the idea of how to do it for what you need. It may need some tweaking depending on what you're doing, if course.


Invision Support
#Invision on irc.irchighway.net
Re: Watch next few lines with ON TEXT triggerd [Re: ots654685] #198155 21/04/08 11:32 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You're correct about it not working.
First off, and if you had tested your code you would've seen this error, you need an if before an else
Here's a suggestion
Code:
on *:text:*:#:{
  if (*sampletext* iswm $strip($1-)) {
    watch $nick $chan $1-
  }
}
alias watch {
  inc $+(%,watch,.,$1,.,$2)
  if $($+(%,watch,.,$1,.,$2),2) > 5 {
    unset $+(%,watch,.,$1,.,$2)
  }
  if (*sampletext2* iswm $3) && $($+(%,watch,.,$1,.,$2),2) {
    ;code to be executed if text is detected while being watched
  }
}

This will keep track of the lines entered on a nick by nick basis as well as a channel by channel basis. This type of tracking is handy for things like detecting who swears in what channels how many times.

Re: Watch next few lines with ON TEXT triggerd [Re: RusselB] #198171 22/04/08 12:24 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You're getting too complicated for what the OP needs. The OP isn't testing specific nicks or channels... just a specific phrase. Also, as was mentioned to you previously, you do not need to send $nick or $chan to an alias. It's unnecessary.

You are also only incrementing the lines if the text is in the line, which isn't what was requested. The increment should happen every line of text in the channel.


Invision Support
#Invision on irc.irchighway.net