mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2012
Posts: 7
G
Go1den Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2012
Posts: 7
Is there a way for me to change a word's color in a received or sent message if it begins with a certain character? Ideally I want to be able to change any chat room names to red, so #anything would be red while the other colors used in the message would go unchanged. Thanks!

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Code:
on ^*:text:*:*:{
  echo -i2tm # $+(<,$nick(#,$nick).pnick,>) $regsubex($1-,/\B(#\S+)/g,4\1)
  haltdef
}


The control codes don't show up on the forum, but copy it into your remote editor and they'll be there. This event matches all text events, so you'll probably need to have it in its own file to make sure it doesn't interfere with other events.

Last edited by Loki12583; 10/06/12 04:18 PM.
Joined: Jul 2006
Posts: 4,155
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
Since a channel name is defined by a # (not dealing with &) followed by anything but a space, a comma or a $chr(7), it should rather be $regsubex($1-,/\B(#[^ \x2c\x07]+)/g,4\1).
But he also said he wants to keep the original colors in the line, and $controlat() can be used to do that:

Code:
on ^*:text:*:*:{
  hadd -m ontext text $1-
  echo -i2tm # $+(<,$nick(#,$nick).pnick,>) $regsubex(test,$hget(ontext,text),/\B(#[^ \x2c\x07]+)/g,04\1 $+ $controlat($hget(ontext,text),$regml(test,\n).pos))
  haltdef
  hfree ontext
}
The hash table is just to prevent the use of %var when $1- is just "", resulting in %var being $null


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2012
Posts: 7
G
Go1den Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2012
Posts: 7
Okay, edited this post twice, because the first edit was my fault for copy-paste failing, but here's the current situation:

Wims, I am using the script you suggested. It appears to be modifying the chat room names to red as I wanted, but I lose my ability to highlight lines AND all of the text after a chat room name also turns to red as opposed to its original color. Any thoughts?

Example:

My default font color is white.

I have a highlight set to make all messages from SomeGuy to turn blue.

<SomeGuy> Hey guys, join #stuff to talk.

SHOULD BE

<SomeGuy> Hey guys, join #stuff to talk.

but with your script I am getting:

<SomeGuy> Hey guys, join #stuff to talk.

(the first part of that line ^^ is white)

Last edited by Go1den; 11/06/12 02:16 AM.
Joined: Jul 2006
Posts: 4,155
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
If you see another line while using the script, it means that you have another on text event conflicting with this one, you need to find it and to mix it with this one.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2012
Posts: 7
G
Go1den Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2012
Posts: 7
See my above edits, I screwed up at first. That is the current situation.

So I guess the major problems I'm having are that (a) I don't necessarily want to strip all color codes from the message, I only want to modify the #chatnames to be red. Everything else should be left alone.

Last edited by Go1den; 11/06/12 02:19 AM.
Joined: Jul 2006
Posts: 4,155
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
The code is only changing #channel in red, nothing else is touched.
I tried the code and it works fine for me.
Did you also get the $controlat() and the $colorat() function in the thread I referenced?

The whole code you need to put in your remote is:

Code:
on ^*:text:*:#:{
  hadd -m ontext text $1-
  echo -i2tml # $+(<,$nick(#,$nick).pnick,>) $regsubex(test,$hget(ontext,text),/\B(#[^ \x2c\x07]+)/g,04\1 $+ $controlat($hget(ontext,text),$regml(test,\n).pos))
  haltdef
  hfree ontext
}
alias colorat {
  if ($prop == set) {
    if ($1 != $chr(15)) {
      var %i $iif($2,$2,$gettok(%colorat,2,44))
      %colorat = $1 $+ $iif($1,$iif(%i,$chr(44) $+ %i))
    }
    else %colorat =
  }
  else {
    set -u %colorat
    var %r /(?:\x03(?:(\d+)(?:,(\d+))?)?|(\x0F))/g,%r $regsubex($left($1,$2),%r,$colorat(\1,\2).set)
    %r = %colorat
    unset %colorat
    return $iif(%r != $null,$chr(3) $+ %r)
  }
}

alias controlat {
  if ($prop == set) {
    if ($1 != $chr(15)) {
      if ($1 isin %controlat) %controlat = $remove(%controlat,$1)
      else %controlat = %controlat $+ $1
    }
    else %controlat =
  }
  else {
    set -u %controlat
    var %c $iif($3,$3,kubir),%r $+(/,$chr(40),$left($regsubex($remove(%c,k),/(.)/g,\x $+ $base($replace(\1,u,31,b,2,i,29,r,22),10,16,2) $+ |),-1),|\x0F,$chr(41),/g),%r $regsubex($left($1,$2),%r,$controlat(\1).set)
    %r = %controlat
    unset %controlat
    return %r $+ $iif(k isin %c,$colorat($1,$2))
  }
}
I added the -l switch of /echo which take care of the highlight settings

Last edited by Wims; 11/06/12 02:48 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2012
Posts: 7
G
Go1den Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2012
Posts: 7
Ah, I missed where you mentioned that. Thanks.

Joined: Jun 2012
Posts: 7
G
Go1den Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2012
Posts: 7
Got it working. Thanks!

Last edited by Go1den; 11/06/12 04:36 AM.
Joined: Jun 2012
Posts: 7
G
Go1den Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2012
Posts: 7
Following up on this:

While it seems to do what I asked, it also has a side effect of removing people's screen names for some reason? I've since abandoned this script.

Joined: Jul 2006
Posts: 4,155
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
yep sorry, it should be:
Code:
echo -i2tml # $+(<,$iif($nick(#,$nick).pnick,$v1,$nick),>) $regsubex(test,$hget(ontext,text),/\B(#[^ \x2c\x07]+)/g,04\1 $+ $controlat($hget(ontext,text),$regml(test,\n).pos))


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard