mIRC Homepage
Posted By: firefox Identifying text of a certain colour code? - 26/02/10 06:20 PM
If I have:

($gettok(%filter,1,32) = sometext)

how can I do

($gettok(%filter,1,32) = anytextwithcolourcodeof15)
Posted By: Wims Re: Identifying text of a certain colour code? - 26/02/10 06:45 PM
Can you be more precise ?
There is no way to see what color text is other than seeing the actual control code. If you did something like:

04This is red text

And you check the word "red," there's no way for mIRC to know what color that word is without checking the entire line and seeing what the most recent color code was.
Posted By: 5618 Re: Identifying text of a certain colour code? - 26/02/10 07:23 PM
Originally Posted By: firefox
If I have:
($gettok(%filter,1,32) = sometext)
how can I do
($gettok(%filter,1,32) = anytextwithcolourcodeof15)

Code:
if (15 isin $gettok(%filter,1,32))

?
Posted By: Tomao Re: Identifying text of a certain colour code? - 26/02/10 07:27 PM
Code:
alias find {
  if ($regex($1-,/\cc15(\S+)/)) && ($gettok(%filter,1,32) = $regml(1)) {
    echo -a TRUE
  }
}
This will match against text (anywhere in a sentence) with the color 15 in your %filter variable for the first word when you enter:
Quote:
/find sometextwiththecolour15

It'll echo TRUE

You don't put color codes in your %filter but enter /find with the color code to match.

You can apply this to an event to match too...
@5618: That won't work unless the color is in the word, like I mentioned.

@Tomao: Yeah, as I mentioned, you have to check the entire line and not a specific word. Whether you do that with regex or another method, it still requires checking the entire line.
If I were at a mirc this is what I'd do.

I'd copy and paste the ctrl + k color code box in $asc to find the value for it. Then I would search for this in a string of text. If I find it I'd look for number following it with no space.
Originally Posted By: Wims
Can you be more precise ?
I want to extract words which have colour code 15 in a specific place for an on text event

the line has multiple colour codes - I only want to match it if it is in a certain position which is found by filtering out brackets from $1

var %filter $replace($replace($1,],$chr(32)),[,$chr(32))

[text1][text2][ text3 ]

text3 and the brackets are always 15
text1 is always the same colour
text2 is various colours and sometimes 15

I actually use gettok to get text1 atm
I want to use gettok again to get text2 and then if it is in 15 echo it to an @window and if it is something else then just ignore it
[text1][text2][text3]
Or...
[text1][text2][text3]


You could do this:

Code:
var %word1 = $remove($gettok($1-,1,93),[)
var %word2 = $remove($gettok($1-,2,93),[)
var %word3 = $remove($gettok($1-,3,93),[)
if ($left(%word2,3) == 15) { echo @window %word2 }


You can, of course, remove any of the %word var lines that you don't need and adjust as necessary. Note that this will not show []'s around the text.
Posted By: Tomao Re: Identifying text of a certain colour code? - 27/02/10 12:06 AM
Originally Posted By: firefox
I want to extract words which have colour code 15 in a specific place for an on text event
the line has multiple colour codes - I only want to match it if it is in a certain position which is found by filtering out brackets from $1

var %filter $replace($replace($1,],$chr(32)),[,$chr(32))

[text1][text2][ text3 ]

text3 and the brackets are always 15
text1 is always the same colour
text2 is various colours and sometimes 15

I actually use gettok to get text1 atm
I want to use gettok again to get text2 and then if it is in 15 echo it to an @window and if it is something else then just ignore it
If I read you correctly, this should do what you're after:
Code:
on $*:text:/\cc15\133?(.+)\cc15\135?/:*: {
  echo @window * Text consists of colour 15: $regsubex($regml(1),/\133|\135/gS,$chr(32))
}
This will match text with the color code 15 enclosed within the '[text]' and echo it to the @window as 'text'
if text2 and text3 have color code 15 in them, they'll be matched as well.
Posted By: Venus78 can help me? - 07/03/10 03:38 PM
why my seen no detect when ppl use colour text

on *^:text:*cari*:#:{
if ($1 == %c $+ cari) {
if ($2 == $null) { .msg $chan 5cara yg betul bonggok: %c $+ cari <nick> | halt }
if ($2 == $me) { .msg $chan 5ko buta ke tak nampak aku $+ . | halt }
if ($2 == $nick) { .msg $chan 5ko giler $nick $+ , carik diri sendiri | halt }
if ($2 ison $chan) { .msg $chan 5 $+ $2 ada ko buta ke tak nampak dia alaa dia bukan penting pon buang karen jer | halt }
if ($readini ini\users.ini $2 date == $null) { .msg $chan 5 $+ $2 aku tak nampak dia lah dia sapa tak penting pon | halt }
else {
if ($readini ini\users.ini $2 me == $null) {
if ($readini ini\users.ini $2 part == yes) { .msg $chan 5 $+ $2 last nampak dia keluar [ $readini ini\users.ini $2 chan ]  $+ $duration($calc($ctime($fulldate)-$ctime($readini ini\users.ini $2 date))) ago. }
else { .msg $chan [ 5 $+ $2 ] last nampak dia blah  $+ $duration($calc($ctime($fulldate)-$ctime($readini ini\users.ini $2 date))) lepas mangkok nie tinggalkan message: " $+ [ $readini ini\users.ini $2 message ] $+ ". }
}
else {
if ($readini ini\users.ini $2 part == yes) { .msg $chan 5 $+ $2 last nampak dia keluar [ $readini ini\users.ini $2 chan ]  $+ $duration($calc($ctime($fulldate)-$ctime($readini ini\users.ini $2 date))) ago. | .msg $chan 5 $+ $2 $+ 's last melalak: 6 $+ [ $readini ini\users.ini $2 me ] }
else { .msg $chan 5 $+ $2 last nampak dia blah  $+ $duration($calc($ctime($fulldate)-$ctime($readini ini\users.ini $2 date))) lepas mangkok nie tinggalkan message: " $+ [ $readini ini\users.ini $2 message ] $+ ". | .msg $chan 5 $+ $2 $+ 's last melalak: 6 $+ [ $readini ini\users.ini $2 me ] }
}
}
else { halt }
}
}

sorry use my lang word
Posted By: Horstl Re: can help me? - 07/03/10 05:47 PM
As I don't want to fiddle with the code itself - for a quick fix, you could try:
Quote:
on *^:text:*cari*:#:{
tokenize 32 $strip($1-)
if ($1 == %c $+ cari) {

[...]
Posted By: chacha Re: can help me? - 07/03/10 05:48 PM
replace $1 by $strip($1)
Posted By: Venus78 Re: can help me? - 08/03/10 02:28 PM
thank for this last one i can't work i changed coz the they play with my seen n got flood in main chat..i changed to this but can't work with this

tokenize 32 $strip($1-)
if ($1 == %c $+ cari) {


on *:TEXT:!cari*:#: {
.timerfloods 1 10 unset %s
if ( %s >= 3 ) { halt }
inc %s 1
if ( $2 ison $chan ) {
msg $chan $2 is currently in the channel
halt
}
Posted By: chacha Re: can help me? - 08/03/10 02:50 PM
for the flood use set -uN

Code:
on *:text:*:#:{
  if (!%fld) {
    set -u2 %fld 1
    tokenize 32 $1-
    if $1 == !cari {
      if $2 == $null {
        your cmd and word here
      }
      elseif $2 == $me {
        your cmd and word here
      }
      elseif $2 == $nick {
        your cmd and word here
      }
      ....
      .....
      ......
    }
  }
}
© mIRC Discussion Forums