mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Hi, I'm a noob/newbie.

Do you know how to put in color the nicknames in the messages ?

For example, i'm typing this : <d4rk_b0y> Hey, how are you Nickname ?

I want the "Nickname" to have a different color of the rest of the message.

So I want this result : <d4rk_b0y> Hey, how are you Nickname ?

And I need that have the same color than the color of the nickname on the list because I use the option "Auto-color based on nickname".

Thanks.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Can you clarify what you're wanting? Are you wanting something that hunts through everything you type looking for nicks, even if they're being touched by things like a comma, period, questionmark, etc? Or are you wanting an alias that looks only at the final word to see if that's a nick in that channel?

You can obtain the color of a nick by doing:

//echo -a $nick($chan, nickname).color

If you're putting this number immediately before a nick, then you don't need to worry about single-digit colors causing the 1st number of a text string to become swallowed as part of the color instead of being displayed.

Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
I want it to do it automatically for all the nicknames.

For exemple here is the list of the users : User1, User2, User3

When someone type a message with theses 3 nicknames, I want it to appears in the same color than/in the list. Like that : < Random > Hello, User1, User2, User3 !

And I don't want to configure it manually in the "Nick Colors" because there's a lot of users... I'm not going to do this for each users.

Last edited by d4rk_b0y; 25/11/20 03:34 PM.
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
I wrote the script code for you. It colors all aliases in the text, separated by a space, that were found on the channels where you are sitting. I think this is what you want to see. Try to use it.

    [Linked Image from i.ibb.co]

This code must be inserted into the script editor. To do this, press the key combination "ALT+R" and install as a new script:

Code
on ^*:TEXT:*:#: сolor_nick_message $nick $chan $1-
on *:INPUT:#: .msg $chan $1- | if ($left($strip($1-),1) != /) сolor_nick_message $me $chan $1-
alias -l сolor_nick_message {
  ;# %stype = 1  - color from nickname list.
  ;# %stype = 2  - color from address book.
  ;---------------
  var %stype = 1
  ;---------------
  var %st $3- | var %sts $strip(%st) | var %sq 1 | while (%sq <= $numtok(%sts,32)) {
    var %ss $gettok(%sts,%sq,32)
    if ($comchan(%ss,0) > 0) {
      if (%stype == 1) var %sc $nick($2,%ss).color | if (%stype == 2) var %sc $cnick(%ss).color
      var %snc $+($chr(3),%sc,%ss,$chr(3)) | var %st $puttok(%st,%snc,%sq,32)
    }
    inc %sq
  }
  if (%st) { var %sac $+(<,$chr(3),$cnick($1).color,$1,$chr(3),>) | /echo -t $2 %sac %st | halt }
}

If you have will arise questions or new ideas will appear on what to change or add in this script, then write about it here.

P.S. It will also be interesting and useful to know the opinion of all other forum members who want to test my script in order to improve the code and for exchange share experience.



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Good thing I asked, because it now looks like you want something different than described in the 1st post.

The first post made it look like you wanted to physically change only your message that everyone else sees in channel, by inserting colors. That can be a problem because I've seen channel modes that simply strip colors from everyone's messages before they're sent to the channel, but other times the message containing color is completely blocked. Also, colorizing nicks for everyone else to see is not a great idea, because you can't assume others have the same background color that you do, so while 2=blue looks great against a white background, not easy to see for someone who has a black background. That problem can be solved by forcing your message to be sent containing a color code to set the background color matching your own background color, but that would be irritating for everyone else to see your message striped as a different color than everyone else's message.

The 2nd post makes it look like you just want to change the display-to-self of all messages, both yours and theirs, so that the nick is replaced by a colorized nick, and it wouldn't change your actual message that everyone else sees, it would just make it so that you see your own message having the nicks colorized. That would require hooking ON TEXT and ON ACTION events to handle everyone else's, and hooking ON INPUT to handle your own. It would also add complexity to try to preserve multiple consecutive spaces in how you see messages, because of how /echo displays text with having leading/trailing/consecutive spaces missing.

Also, how do you want to handle messages where someone has already inserted color codes in the text? If there's a message where someone has the text be normal color, then has the color code to make the text red, then more text, then users someone's nick, then has more text. It would be extremely difficult to have the text color return back to red, because there's no identifier to inform what the color is at a specific position within the text. Also, even if there were, you don't always see the color as that color, because changing the text to a different color following the use of Ctrl+R to make the text be reverse - the text doesn't appear in that new color until you toggle Ctrl+R off again.

Here's a first attempt to change the way a string appears when you echo it, by looking for strings containing the valid characters of a nick, then replaces them with the colorized version. You would paste these aliases into any remote script, and then you can try them out by pasting this command including the double // slash but first editing it to contain text that contains actual nicks and text that isn't a real nick in that channel. But don't change the | pipe or anything following it. Let me know if this does what you want, or give examples where it doesn't do things correctly. I have it strip out color codes, then hunt for a nick. It shouldn't find User2 within LUser2, and should handler User2 and User22 correctly, and if the nick is actually User2 it will use whatever you actually type like UsEr2 or user2. If it finds no match, it echoes the original string, otherwise it returns the string that first has the colors stripped before replacing just-the-nick.

Pasting in editbox:

//tokenize 32 test $+($chr(3),04) test User1,User2,NoSuchNick,User3 test | echo -a $replace_nick_with_colors( $1-)

After pasting these into a script in the remotes tab:

Code
alias color_the_nick {
  if ($nick($chan,$1) && ($1 !isnum)) { bset &color_the_nick 1 1 | return $+($chr(3),$nick($chan,$1).color,$1,$chr(3)) }
  return $1
}

alias replace_nick_with_colors {
  bunset &color_the_nick
  var %a $regsubex(foo,$strip($1-,c),/([a-zA-Z0-9_\\\]\[{}|^-]+)/g,$color_the_nick(\t))
  if (!$bvar(&color_the_nick,0)) return $1-
  return %a
}


Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Hmmm it's worked only one time ! And after that... all the nicknames in the tchat was white... but the nicknames in the list of users are still colored.

Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
1. Please name your version of the client?
2. Are you using do you use any additional scripts related to coloring the nicknames in the list?
3. Are you using do you use any additional DLLs for coloring nicknames?
4. Do you use the settings for colors selected in "ToolBar/Colors/Listbox text" or sets up through the "Address Book/Nick Colors" or do you color nicks with the "/cnick" command?
5. Have you tried switching the value of the variable "%stype" to 2 instead of 1? (var %stype = 2)

I will try to understand what the problem might be. But everything works fine for me in every message.

Enter this command in the text input line and write your response:
Code
//echo -a $os - $version $beta - $md5($mircexe,2) - $alias(0) - $script(0) - $dll(0) - $com(0)




🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Yeah, I use "Nick Colors" in Adress Book, to put all the nicknames in the list of users and the tchat, in color !

And when I use your first script... It doesn't change the colors in the list of users but the nicknames in the chat like this : < Random > Hello !

Random has become white... But i've took a screenshot for you ! https://ibb.co/fG3wwWm

As you can see, I've started using your script at 06:02 from Meta's message.

The version of my client is 7.63 !


Last edited by d4rk_b0y; 26/11/20 03:50 AM.
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Thanks Maroon but... it's not working... smirk

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
what's not working? Is there an error message in the status window when you try to run my example? Nothing happens at all? It displays an echo that isn't doing what you want? The echo is not colorizing the nicks when you substitute them in place of User1 User2 User3?

This was an example snippet to make sure whether this is what you want, since your story was changing between your posts. The goal was for you to test it to see which cases it worked correctly and which it didn't. My example isn't auto-magically handling all incoming and outgoing text, since I wasn't clear which of your 2 prior posts was describing what you really want. But my example command needs to be done in the channel window or it can't know which nicks to colorize. Does this next show your own nick in the right color?

//echo -a $color_the_nick($me)

Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
I have fixed and improved my script code for you. Please check if everything is working properly in it.
It so happens that several installed scripts can conflict with each other and interfere with the correct operation of one of them.
If you encounter problems, then try installing this script on a pure mIRC client (without other scripts) to test the script's functionality.

The script will correctly display all colors only in the most recent versions of the mIRC client, which have a to choose from 98 colors add-on. This code was tested on mIRC v7.63

Updates:

Now the script can detect nicknames in messages even when they are followed by such characters: [.,:=?!()].
Also, now the script can automatically assign a color for a nickname for which there is no color in the address book, as soon as the user join the channel, or change their nickname, or sends a message.

You can independently make the necessary settings for the script through the "color_nick_message_set" alias:

Variable "%cnm_ignore_color" – adjusts space-separated color numbers that cannot be used to for coloring nicknames. (You can change this to suit your chat background)
Variable "%cnm_ignore_chan" – adjusts space-delimited channels on which nicknames in messages cannot be colored. (You can change this channel list)
Variable "%cnm_auto_color" – controls whether to enable (true) or disable (false) to automatically record the color for nickname in address book. (You can change it)
Variable "%cnm_method_color" – adjusts the method for displayed colors, where 0 = color for nickname will be simultaneously in messages and in the list of nicknames, or separately 1 or 2.
Variable "%cnm_sort_list" – sorts the nicknames in the address book, where 1 = will be the first line in the address book list.

I am attaching screenshots of how it looks in my chat:
  [Linked Image from i.ibb.co]

This code must be inserted into the script editor. To do this, press the key combination "ALT+R" and replace the old code with this code:


Code
#####################################################################
#   Name: ColorNickMessage v1.0
#   Description: Colors all the specified nicknames in the text that are present on the same channels where you are.
#   Author: Epic
#   Email: epicnet@mail.ru
#   Site: http://epicnet.ru
#####################################################################

on *:NICK: сolor_nick_message_auto $newnick
on *:JOIN:#: сolor_nick_message_auto $nick
on ^*:TEXT:*:#: сolor_nick_message $nick $chan $1-
on *:INPUT:#: if ($left($strip($1-),1) != /) { .msg $chan $1- | сolor_nick_message $me $chan $1- }
-------------------------------------------
alias -l сolor_nick_message_set {
  %cnm_ignore_color = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 36 37 48 60 88 89 90 92 93 94 95 96 97 98
  %cnm_ignore_chan = #Services #MyTest
  %cnm_auto_color = true
  %cnm_method_color = 0
  %cnm_sort_list = 1
}
-------------------------------------------
alias -l сolor_nick_message_auto {
  if (%cnm_auto_color == true && $cnick($1) == 0) {
    var %cnm_key $+(-m,%cnm_method_color,s,%cnm_sort_list)
    :next1 | var %cnm_rcol $rand(1,98) | if ($istok(%cnm_ignore_color,%cnm_rcol,32)) goto next1
    .cnick %cnm_key $1 %cnm_rcol
  }
}
alias -l сolor_nick_message {
  сolor_nick_message_set | if ($istok(%cnm_ignore_chan,$2,32)) { halt } | сolor_nick_message_auto $1
  var %cnm_text $3- | var %cnm_stext $strip(%cnm_text) | var %cnm_inc 1 | while (%cnm_inc <= $numtok(%cnm_stext,32)) {
    var %cnm_tok $gettok(%cnm_stext,%cnm_inc,32) | var %cnm_rtok $remove(%cnm_tok,$chr(40),$chr(41),$chr(44),.,=,:,?,!)
    if ($comchan(%cnm_rtok,0) > 0) {
      var %cnm_col $cnick(%cnm_rtok).color | var %cnm_ncol $+($chr(3),%cnm_col,%cnm_rtok,$chr(3))
      var %cnm_rncol $replace(%cnm_tok,%cnm_rtok,%cnm_ncol) | var %cnm_text $puttok(%cnm_text,%cnm_rncol,%cnm_inc,32)
    } | inc %cnm_inc
  }
  if (%cnm_text) { var %cnm_nick $+(<,$chr(3),$cnick($1,1).color,$1,$chr(3),>) | .echo -t $2 %cnm_nick %cnm_text | halt }
}





🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Thanks for your help ! It's not working as I want but it's fine ! Thanks you very much.

Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
I have my own ideas for finalizing this script with the addition of a dialog box for easy control and settings.

If you try to explain in more detailed examples with screenshots what you are missing in this script, then I can try to expand its capabilities or change something in it. To make the script more flexible and customizable, in accordance with what you want to see in it or what other users will want and will be able to customize in this script. Please offer your ideas and I will think about what can be done. Or maybe other experienced scripters will help you. And don't forget to let me know about any bugs you find in this script.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Well your script seems to work but not for all the nicknames. I don't know why it's only working on somes of them and the others nicknames are all in white.

For the moment, it's like this. https://ibb.co/2tyFY0F

https://ibb.co/nCsS9G9

https://ibb.co/Wcy1c9F

Last edited by d4rk_b0y; 03/12/20 08:58 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Can you confirm that you created the %stype variable as a *global* variable not local? This should return a 1 or 2 instead of a blank:

//echo -a stype value is: %stype

you create a local variable with /var and a global variable with /set. And with /set you don't use the = unless you want the = to be part of the value. With /var the = is optional. like:

/set %stype 1

If you don't have %stype defined, nothing is going to happen other than removing leading/trailing/consecutive spaces from the string

--

You never answered my post about what you meant by my alias not working. If you put my aliases into that remote script, does this color to match the nicklist:

//var %text test Meta, hello Meta test Eric test $me test | echo -a $replace_nick_with_colors( %text )

Also in Epic's script, it depends on the nick being the entire word, so if there is anything else touching it, there will be no color. So in my example it colors both "Meta" if that nick is in the active window, even though the 1st one has a comma touching it.
However Epic's script colors only the 2nd Meta that doesn't have punctuation touching it.

My alias only worked as a //command, because I was waiting to get your confirmation of exactly what you were wanting, before I tried to include it in the TEXT or INPUT events. Mine is only coloring to match how it shows in the nicklist, so mine doesn't support the "2" definition of %stype

Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Thanks for your remark. But since that was beta code, you probably haven't noticed that we have moved a little further and if you look below there is already was written a new script -> #Post268140.
And now I am working on the continuation of the script.

For variables "var", I set the = sign only for the sake of easier navigation in the code while adjusting these values.

Your the above example code with the identifier $regsubex seems to me also quite interesting. Please modify finalize it to a finished script so that we can all start using it and describe the results.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Hey guys i'm not sure that you understand that i'm not used to write script. You are funny because you tell me to do that and this without telling me where to copy the script.

I don't know where's the global or local variable.

And I don't know what the **** you are talking about.

Can you just tell me what to do and how to do it, like you are talking to a ******* monkey which's just start learning to use a computer.

And I think it's funny too to ask me to prove it if it's work or not, to be use by the others who need it too, because you are supposed to try it first, before me.

And I don't know why I have the "OP" on my profile but I'm not an operator.

Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Here, most likely the question was to check the specific settings of your client. Because each user can configure the program in his own way, and we do not know what pitfalls there may be and what other installed scripts can cause conflict. Some things can interfere with the correct operation of the script, so most likely you were asked for help in testing the code in order to create script that will work exactly with your specific settings and meet your needs. Anyway, we're just trying to help, and in theory expect some average understanding when installing scripts for each job seeker in this forum. If you are at a loss for something, then do not hesitate to ask in more detail about it and formulate your question more clearly so as not to be misleading if you want to be understood as quickly as possible and provide the necessary support.

For us it is a hobby and practice to brush up on our scripting knowledge and to create something new. After reading this forum, other users will also be able to learn something new for themselves while creating their scripts, or they will be able to find a solution to a similar issue using these scripts.

Specifically on my own behalf, I will say that with the next presented script in the near future, I will try to convey to you as much as possible how and what will need to be done and what to press so that you everything works out.

As for the white nicknames in quotes <nick>, most likely the whole problem is in the "Any nick (Auto)" setting. Try to remove this line in "Nick Colors", because it can prevent the script from working properly. In the last script I presented, all nicknames are entered into the address book automatically with a random color, when the "%cnm_auto_color = true" variable is enabled and then the script checks the color of each alias from that list to display it correctly in the channel window. Therefore this list must exist. Perhaps this will help.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Nov 2020
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Nov 2020
Posts: 9
Thanks you, it's working ! I had to disable the "Auto Nick Colors" function. But... What can I do to... not have a long list of users that is feeding my list of "Nick Colors"...

But can you guys, help me to keep the "Auto Color Nicks" and the color of my fonts... because it's changed to white when I use your script. You can see it in the previous pictures that
I had share to you.


Link Copied to Clipboard