mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2007
Posts: 2
B
Bowl of petunias
OP Offline
Bowl of petunias
B
Joined: Jan 2007
Posts: 2
I'm trying to make a short little ON TEXT command to do something if someone posts a line in, for example, red background with white text... is there an easy way to do this I'm missing?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
on *:text:*:#:{
  if $left($1,1) == <ctrl + k> {
    var %fore = $gettok($1,1,44), %back = $gettok($1,2,44)
    if %back !isnum {  %back = 0  }
    if %fore == 0 && %back == 4 {
      <rest of code>
    }
  }
}


UNTESTED

Joined: Jan 2007
Posts: 2
B
Bowl of petunias
OP Offline
Bowl of petunias
B
Joined: Jan 2007
Posts: 2
thanks for the quick response RusselB - I figured I was missing something simple... apparently not.

I'll let you know if it works.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Most people are looking for something to remove the colour codes from an on text event, if they're worried about colours, since most bot commands won't work with coloured text, so the common reference to give is the usage of $strip...however, that removes all colours, not just certain colours (hmmm...maybe a feature suggestion here..an option to specify which colours are removed when using $strip)

Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Originally Posted By: buckrogers
I'm trying to make a short little ON TEXT command to do something if someone posts a line in, for example, red background with white text... is there an easy way to do this I'm missing?


Yes, but I'm not sure how complex you want it.

Code:
on 1:TEXT:*:#: {
  var %badcolor1 = / $+ $chr(3) $+ 4,0/ig
  if $regex($1-,%badcolor1) > 0 {
    echo -a Red Text on White Background!!
  }
}


That will echo to the active window "Red Text on White Background!!" when some uses those two colors (assuming they use both foregroud AND background). You can edit that line to do whatever you like, though.

If you know Regex, its pretty easy to go from there. If not, well, LEARN REGEX, its damn helpful. smile Until then, I'll check back and see if you need further help.

Edit: RusselB has a very good idea, but his won't catch the color code if they use it anywhere except for the first character. While it IS possible to do it using $pos, it becomes kind of painful.

Last edited by Thrull; 18/01/07 10:27 AM.

Yar
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Why not just use $replace?
Code:
echo -a $replace($1-,04 $+ $chr(44) $+ 00,03 $+ $chr(44) $+ 01,4 $+ $chr(44) $+ 00,03 $+ $chr(44) $+ 01)



Note that I have 2 replaces there so it covers 2 of the possible ways to do red on white. I had it replace that with green on black. You can also just use $remove:

Code:
echo -a $remove($1-,04 $+ $chr(44) $+ 00,4 $+ $chr(44) $+ 00)



That will just remove the color codes entirely for red on white.

If you don't want to replace/remove it, then change that into an IF:

Code:
if (04 $+ $chr(44) $+ 00 isin $1- || 4 $+ $chr(44) $+ 00 isin $1-) {
  do this
}


The problem with what you see in all of the above is that it needs extra work to make it handle a single 0 for the background color. You'd have to make any of the three verify that the background doesn't have a # after the single 0 for this to work correctly in those situations. I didn't include that because it was extra work and I don't know if these are what you're really looking for.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard