mIRC Home    About    Download    Register    News    Help

Print Thread
need some help on using an echo script #218348 10/02/10 01:45 AM
Joined: Jan 2008
Posts: 19
K
kwiknuts Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
Hi,

I need some help on using an echo script. Heres the situation: There are 3 lines from a twitter feed that come up in my mirc main window. The 1st and 3rd lines are constant and I have no trouble echoing them into a new window. The 2nd line in the middle however has the twitter message and there is no way I can echo it (because it changes) like the 1st and 3rd lines. What I need to figure out is how to echo the 2nd line right after the 1st and before the 3rd line echo's. Here is what they look like:

<nick> Twitter Update - Tue Feb 9, 2010, 3:28pm
<nick> changing twitter message << (note: this line can be anything in a standard twitter message)
<nick> http://twitter.com/ScoobeeDoo

and here is my script:

if (Twitter Update isin $strip($1-)) { /echo #newbox $1- }
if (http://twitter.com/ScoobeeDoo isin $strip($1-)) { /echo #newbox $1- }

So is there a way to make the first line of script echo 2 lines not just the first, which would catch the 2nd or middle line?

In other words is there a script command that will echo not just that line but the next line or even the next N number of lines?

Any help would be appreciated.

Thanks

Last edited by kwiknuts; 10/02/10 02:30 AM.
Re: need some help on using an echo script [Re: kwiknuts] #218349 10/02/10 01:59 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
If you receive the 2nd line-to-echo always right after the first line, you could use the "event" of receiving the first matching line to set some kind of "one time marker". Something like:
Code:
if (Twitter Update isin $strip($1-)) && (!%twitter.updated) {
  echo #newbox $1-
  set -eu5 %twitter.updated x
}
elseif (%twitter.updated) {
  echo #newbox $1-
  unset %twitter.updated
}
elseif (http://twitter.com/ScoobeeDoo isin $strip($1-)) { echo #newbox $1- }

Else I think we'd have to see a further part of the script in question - some on sockread I guess - to find a sollution.

Edit: Sorry, I just realized you receive this in a channel/query. I hope you got the idea and it's of use for you though smile
And nope, there is no such command. you'd have to "count" the remaining lines-to-relay yourself.

Last edited by Horstl; 10/02/10 02:06 AM.
Re: need some help on using an echo script [Re: Horstl] #218350 10/02/10 02:40 AM
Joined: Jan 2008
Posts: 19
K
kwiknuts Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
not sure what the %twitter.updated means? Keep in mind that 2nd line changes all the time.

And what is the "x" mean?

thanks again

danke schon

Re: need some help on using an echo script [Re: kwiknuts] #218351 10/02/10 02:53 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
"x" is but a dummy value for a global variable "%twitter.updated". The variable itself is a marker that you're now waiting for "line no. two". If this variable had been set, the script will echo the next line and thereafter unset the variable.

Anyway, here's another idea. It should work more robust (i.e. also for intersecting messages and for multiple channels / server connections).

Code:
; I guess you start with an on text event
; change the "#" if your current script is set to a specific channel.
on *:text:*:#: {

  ; set local variable "<connection ID><channelname><nick>" (repeated use below)
  var %i = $cid $+ $chr(1) $+ $chan $+ $chr(1) $+ $nick

  ; no item "<connection ID><channelname><nick>" found in a "twitterupdates" hash table
  if (!$hget(twitterupdates,%i)) {

    ; message starts with key term "Twitter Update -"
    if ($strip($1-3) === Twitter Update -) {
      ; add that item to the hash table. After a time frame of 20 seconds, the item will unset itself (just to play safe)
      ; the item's data equals the no. of remaining lines to echo (for example two lines)
      hadd -mu20 twitterupdates %i 2
      ; and echo the current line to your channel
      echo #newbox $1-
    }

  }

  ; such an item had already been set (thus the current line of text is a "successive" line)
  else {
    ; decrease the item's value (= remaining lines) by one / unset the item if the value equals one
    $iif(($hget(twitterupdates,%i) > 1),hdec,hdel) twitterupdates %i
    ; and echo the line to your channel
    echo #newbox $1-
  }

}

Note that I did not test this one...

Re: need some help on using an echo script [Re: Horstl] #218370 11/02/10 06:01 PM
Joined: Jan 2008
Posts: 19
K
kwiknuts Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
Horst

I tried the:

Code:
if (Twitter Update isin $strip($1-)) && (!%twitter.updated) {
echo #newbox $1-
set -eu5 %twitter.updated x
}
elseif (%twitter.updated) {
echo #newbox $1-
unset %twitter.updated
}
elseif (http://twitter.com/ScoobeeDoo isin $strip($1-)) { echo #newbox $1- }

and it works well, now how can I tell it to also play a wav file when the first line is echoed?

my file is located at C:\Program Files\mIRC\sounds\twitter.wav

thanks again

Re: need some help on using an echo script [Re: kwiknuts] #218371 11/02/10 06:27 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: kwiknuts
now how can I tell it to also play a wav file when the first line is echoed?
Code:
/splay twitter.wav
You don't need to specify a path if the sound file is stored in mirc's sounds folder.

Re: need some help on using an echo script [Re: Tomao] #218372 11/02/10 06:46 PM
Joined: Jan 2008
Posts: 19
K
kwiknuts Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
ok but where does the /splay go in the script for the first line?

do I put it on nxt line after the echo command? Or is there a way to do both the echo command and the sound file together?

thanks

Re: need some help on using an echo script [Re: kwiknuts] #218373 11/02/10 07:00 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Just put it between the 'echo' and the 'set' command lines.

Re: need some help on using an echo script [Re: kwiknuts] #218379 11/02/10 08:44 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
And if you want to use the latter, "longer" script, put the /splay-command on a new line below "hadd -mu20 twitterupdates %i 2".
I recommend to you to use the longer version, as it should work proper even if you're on many/busy channels. The first script may work most of the time, but won't work in all situations. smile

Re: need some help on using an echo script [Re: kwiknuts] #220354 12/04/10 04:43 AM
Joined: Jan 2008
Posts: 19
K
kwiknuts Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
Ok I have been using the script from Horstl:

I tried the:

Code:
if (Twitter Update isin $strip($1-)) && (!%twitter.updated) {
echo #newbox $1-
set -eu5 %twitter.updated x
}
elseif (%twitter.updated) {
echo #newbox $1-
unset %twitter.updated
}
elseif (http://twitter.com/ScoobeeDoo isin $strip($1-)) { echo #newbox $1- }

and it works real fine

but now the situation has changed and I have 4 lines to echo, with the 1st and 4th same as before and now I need to not only echo line 2 but now a line 3 into #newbox as before.


ex:

<nick> Twitter Update - Tue Feb 9, 2010, 3:28pm
<nick> changing twitter message 2nd line << (note: this line can be anything in a standard twitter message)
<nick> changing twitter message 3rd line << (note: this line can be anything in a standard twitter message)
<nick> http://twitter.com/ScoobeeDoo


Would I simply add another <echo #newbox $1-> to the script so it looks like this now to catch the 2nd and 3rd lines:

elseif (%twitter.updated) {
echo #newbox $1-
echo #newbox $1-
unset %twitter.updated

Would that catch the additional 3rd line or do I need to do some other trick?

Thanks again

Last edited by kwiknuts; 12/04/10 04:48 AM.
Re: need some help on using an echo script [Re: kwiknuts] #220361 12/04/10 10:29 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
It won't. But why not use the other script and change the line
Code:
      hadd -mu20 twitterupdates %i 2
to
Code:
      hadd -mu20 twitterupdates %i 3
smile

Last edited by Horstl; 12/04/10 10:30 AM.
Re: need some help on using an echo script [Re: Horstl] #220362 12/04/10 11:39 AM
Joined: Jan 2008
Posts: 19
K
kwiknuts Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
well I'd much rather use the simpler script since I can understand what it is doing somewhat ( lol ) plus I only need this for one room not multiple rooms

would think there is a simple way to tell it to echo the next 2 lines that show up versus just the next line?

anyone have a solution?

Thanks

Last edited by kwiknuts; 12/04/10 11:41 AM.
Re: need some help on using an echo script [Re: kwiknuts] #220365 12/04/10 01:56 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Using what you had, here's an update to get the 3rd line as well:

Code:
if (Twitter Update isin $strip($1-)) && (!%twitter.updated) {
  echo #newbox $1-
  set -eu5 %twitter.updated 1
}
elseif (%twitter.updated) {
  echo #newbox $1-
  if (%twitter.updated == 2) { unset %twitter.updated }
  set -eu5 %twitter.updated 2
}
elseif (http://twitter.com/ScoobeeDoo isin $strip($1-)) { echo #newbox $1- }


Invision Support
#Invision on irc.irchighway.net