mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2006
Posts: 23
L
l0GicAL Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2006
Posts: 23
hello all,

i have permission from the chan owner to echo/relay his bot to another channel (on another network). a sample relay/echo goes like this:

Code:
5:58p (b0T) :: [NEW] :: [BF2142] - http://www.totalbf2142.com/forums/showthread.php?t=17584&goto=newpost
5:58p (b0T) :: [NEW] :: [GameSpot] - http://www.gamespot.com/news/6165159.html?part=rss&tag=gs_pc&subj=6165159
5:59p (b0T) :: [NEW] :: [BF2] - http://www.totalbf2.com/forums/showthread.php?t=108473&goto=newpost
5:59p (b0T) :: [NEW] :: [GameSpy] - http://media.pc.gamespy.com/media/866/866306/vids_1.html



...and my echo script is:

Code:
on *:TEXT:*:#channel: {
  if ($nick == b0T) {
    scon -a if ($network == After-All) { msg #test $1- }
  }
}



however, i switched to using NNS and i'm using a semi-bluish/blackish background and i can't see parts of what's being announced! i can see the [NEW] part and the link but the [GameSpy] or [BF2] part is EXACTLY the same color as my background and therefore, can't see anything!

now, i know i can simply change my background color but i was wondering if i can do a simple modification of my relay script so that i can change the color of the part that i can't see?

secondly, is there anything i can do to my script so that everytime it echoes something, it won't include the :: [NEW] :: part?

thirdly, can i put spaces in the [BF2] part so it'll look like: [ BF2 ] (with spaces)?


thank you all so much!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
on *:TEXT:*:#channel: {
  if ($nick == b0T) {
    scon -a if ($network == After-All) { msg #test $replace($remove($1-,:: [NEW] ::),[,[ $+ $chr(32),],$chr(32) $+ ],02,03) }
  }
}


Replace the 02 with the color you don't like and replace the 03 with the color you want it to be changed to.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 23
L
l0GicAL Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2006
Posts: 23
unbelievable... it worked PERFECTLY! thank you so very much!

if you have time, can you please explain this part of the code:

Code:
$replace($remove($1-,:: [NEW] ::),[,[ $+ $chr(32),],$chr(32) $+ ],14,07)



i'm asking because i want to learn what you did and how i can modify it (again in the future) so that for example, i have this:




...and i want to:

* remove [ TEST ] -
* change the color of SITE


...so it would look like:




i have this:

Code:
on *:TEXT:*:#channel: {
  if ($nick == b0T) {
    scon -a if ($network == After-All) { msg #test $replace($remove($1-,[ TEST ] -),[,[ $+ $chr(32),],$chr(32) $+ ],01,10) }
  }
}



...and of course it doesn't work.


also, just for fun, how would i add a highlight to it so it would look like:




i really would like to learn part-by-part why the above code that you gave me worked and the new one didn't. i mean, what does $chr(32) do? $+... what's it for?

again, thanks for the quick help and hopefully, i'm not asking for too much this time! blush i know that by having these examples, it'll help me figure things out... i just need a li'l help + explanation. this is the second time you've helped me and i really really REALLY appreciate it! smile

Last edited by l0GicAL; 14/02/07 11:32 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Here's a quick rundown...

Start from the ()'s that are furthest in. In this case, it's the $remove. $remove will remove whatever you tell it to. You already know what $1- is. $remove is going to remove :: [NEW] :: from $1-. Next, you move outward and you find $replace. $replace will replace text with something else. In this case, we're replace [ with [ + a space. $chr(32) is a space. $+ combines the two items together. If you just put a space there, mIRC would assume you're just spacing things out, so you need to use $chr(32). And if you didn't use $+, then it would put 2 spaces because then it would assume your space between [ and $chr(32) *was* meant as a space. Of course, mIRC would still output it as a single space, but it's better to do it right. Anyhow, you continue on through there and see that ] is then replace with a space + ]. And then color 14 is replaced by color 07.

Check the /help file for syntax if you want to look into those further.

As for why your example didn't work, it's because of the colors. Change $1- to $strip($1-) and then it would work the way you expect.

To add color to the different parts would take more effort because you'd need to find where each part starts. Maybe I'll look into that a little later.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 23
L
l0GicAL Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2006
Posts: 23
Originally Posted By: Riamus2
To add color to the different parts would take more effort because you'd need to find where each part starts. Maybe I'll look into that a little later.


thanks for the quick explanation! i've played around with $remove and $replace last night and can pretty much do whatever i want. the only problem now that i'm having is adding colors to different parts (or changing the colors of the different parts).

when you have the time, can you please give me a few examples? even the simplest ones would do. i just need to see a few examples how some parts can be changed to whatever color.

thanks again! smile

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
For your examples, it's not too bad as long as there are always the same number of "words" (text separated by spaces) in all of the notices that you're relaying.

In your example:


The time and bot's name are ignored. The first "word" is ::. That's $1. The second "word" is [NEW] and that's $2. Keep going until the end.

So, you'd output:
msg $chan 01 $+ $1 03 $+ $2 etc.

Just change the colors.

One thing to remember as you're doing this. If you're using the first code that puts spaces around the []'s, then your $1,$2,etc. numbers will change because "[" will not be its own word because there are spaces around it.

Usually, when you're changing a lot about a piece of text, it's helpful do it in a variable and then just msg the variable instead of doing it all on the msg line.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 23
L
l0GicAL Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2006
Posts: 23
Originally Posted By: Riamus2

One thing to remember as you're doing this. If you're using the first code that puts spaces around the []'s, then your $1,$2,etc. numbers will change because "[" will not be its own word because there are spaces around it.


wow, i'm learning a lot! smile

ok, so regarding the above statement, you said that for example:

:: [NEW] ::

$1 = ::
$2 = [NEW]
$3 = ::


...is the above right? if it is, then what if i have this:

[ NEW ]

$1 = [
$2 = NEW
$3 = ]


am i understanding this correctly?

also, one more question about $remove - how come that if i have this:

[ TEST ] -

$remove($1-,[ TEST ])


...only the word TEST gets removed but the [ ] (brackets) and - (dash) does not? is it because there's a space before and after the word TEST? how do i COMPLETELY remove this part: [ TEST ] -




thanks again! laugh

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, your examples are correct.

As for the $remove, it's because it's treating the []'s as evaluation brackets rather than text because they aren't touching any other characters (not counting the ()'s that surround the whole thing). To deal with that, change the []'s to their ascii code equivalents.

Just like a space is $chr(32), all characters have a similar code. To find it out, you can use:

//echo -a $asc([)
//echo -a $asc(])

Then you'd have $remove($1-,$chr(##) TEST $chr(##)) where the ## are the ascii numbers. Most characters can easily be checked with the $asc() command. A few won't work, such as a comma, due to how mIRC interprets code. To get around that limitation, you can look them up online, get a script that works around that, get a script that lists all of the ascii codes, or just try characters that are close to it on the keyboard.

Because . is close to , you can try:
//echo -a $asc(.)

And then, just increase the number or descrease the number until you find the right number.

//echo -a $chr(42)
//echo -a $chr(43)
//echo -a $chr(44)

Kind of line that. Eventually, you memorize the common ones that you use regularly.

As for removing the - in that example, you'll need to make sure that you include it in the $remove command. smile

Btw, you may want to look up $gettok as well. $gettok works similar to using $1,$2,etc., but will let you get parts of text even if the spaces aren't there.

For example, if you wanted to get the text between the first two []'s and nothing else, you'd use $gettok to get it. Check it out and see what you can do with it.

Format:
$gettok(text,#,chr) <<-- My version of it.

text could be $1- or a variable or actual text.
# is the number of the item you want. If you were doing it based on spaces, # would be the number of the word.
chr is the $chr that you're separating the text by. For spaces, $chr(32) is a space. In $gettok, you just put 32 (no $chr part) and it will count by spaces.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 23
L
l0GicAL Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2006
Posts: 23
first off, many many MANY thanks for (patiently) trying to help me! smile

however, i'm still a few modifications away from getting it all right. just to go back to my recent problem, on another channel, this is EXACTLY the format of the text that i'm echoing:




and what i want to happen is to remove the "[ TEST ] -" part so that when i echo it to another channel it'll look like this:




using what i've learned from you so far, here's my current echo script:

Code:
on *:TEXT:*:#channel: {
  if ($nick == b0T) {
    var %text = $remove($1-,$chr(32),TEST,$chr(32),$chr(45))
    scon -a if ($network == After-All) { msg #test %text }
  }
}



it sort of works -BUT- three things:

1. the green []s are still there (if i use $chr(91) and $chr(93) then ALL the []s will be removed)
2. all the spaces have been removed
3. all of the "-" (dashes) have been removed


using my new script, here's what the echo looks like:




again, i just want to make it look like:

from this ->
to this -> (and then later change the color of "SITE" to something else).


again, thanks in advance and i'm really sorry if it seems like we keep going back to the same topic frown!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It's because you're using commas between the things when it's all one piece of data you're trying to remove...

Code:
$remove($strip($1-),$chr(91) TEST $chr(93) -)


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 23
L
l0GicAL Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2006
Posts: 23
wewt, everything's done! many many MANY thanks!!!


Link Copied to Clipboard