mIRC Home    About    Download    Register    News    Help

Print Thread
Script to generate random Twitch user name color #259489 07/12/16 05:56 AM
Joined: Dec 2016
Posts: 3
N
Neo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Dec 2016
Posts: 3
I am curious if anyone knows how to write a script that would generate a random color for one's username every time they type something into chat on Twitch.Tv. I've seen this before but am unsure of how it is accomplished. Any suggestions would be great!

Re: Script to generate random Twitch user name color [Re: Neo] #259501 09/12/16 10:47 PM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Do you want a random color from Twitch's predetermined colors (not Prime/Turbo user) or a random color from a hex code (Prime/Turbo user)?

Re: Script to generate random Twitch user name color [Re: Blas] #259502 10/12/16 07:12 AM
Joined: Dec 2016
Posts: 3
N
Neo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Dec 2016
Posts: 3
A random color from a hex code (Prime/Turbo user) is what I'm looking for.

Re: Script to generate random Twitch user name color [Re: Neo] #259503 10/12/16 10:54 AM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Assuming that you are logged into mIRC on your Twitch account, and that you are using another way to chat in the channel that is not the same copy of mIRC that this script it on, this will do the trick. Every time that you type anything in chat, your login on mIRC will try to change your color for you.

Code:
ON *:TEXT:*:#: {
  IF ($nick == $me) {
    VAR %hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
    MSG $chan .color $chr(35) $+ $gettok(%hex,$rand(1,16),32) $+ $gettok(%hex,$rand(1,16),32) $+ $gettok(%hex,$rand(1,16),32) $+ $gettok(%hex,$rand(1,16),32) $+ $gettok(%hex,$rand(1,16),32) $+ $gettok(%hex,$rand(1,16),32)
  }
}

Re: Script to generate random Twitch user name color [Re: Neo] #259504 10/12/16 11:13 AM
Joined: Apr 2010
Posts: 939
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 939
Just for clarity: When sending a message to twitch, is that message originating from within your web browser or from an mIRC instance?

If from the webbrowser, this is not the site/program to do such.

If from mIRC you can use the following:
Code:
;; when text is input in a channel window
on *:INPUT:#:{
  ;; if ctrl+enter was NOT used
  ;; the text isn't being pasted in
  ;; the text doesn't start with /
  ;; the text doesn't start with a user defined command character
  if (!$ctrlenter && !$inpaste && /* !iswm $1 && $comchar $+ * !iswm $1) {
    
    ;; pick a random 16bit color, then convert it to a 6-character hex value
    var %color = $chr(35) $+ $base($rand(0, 16777215), 10, 16, 6)

    ;; msg the channel with the color change
    msg $chan .color %color
  }
}


I am SReject
My Stuff
Re: Script to generate random Twitch user name color [Re: Blas] #259505 10/12/16 11:20 AM
Joined: Dec 2016
Posts: 3
N
Neo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Dec 2016
Posts: 3
That's awesome! Works great I appreciate it. One other question though, if I only wanted the script to randomly choose from a list of specific hex codes such as (#000000, #FF00FF, #00FFFF, #FFFF00, and #FFFFFF) how would I accomplish this? Thanks!

Re: Script to generate random Twitch user name color [Re: Neo] #259506 10/12/16 02:56 PM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Originally Posted By: Neo
That's awesome! Works great I appreciate it. One other question though, if I only wanted the script to randomly choose from a list of specific hex codes such as (#000000, #FF00FF, #00FFFF, #FFFF00, and #FFFFFF) how would I accomplish this? Thanks!

Just change/add the six character hex codes in the VAR.

Code:
ON *:TEXT:*:#: {
  IF ($nick == $me) {
    VAR %hex 000000 FF00FF 00FFFF FFFF00 FFFFFF
    MSG $chan .color $chr(35) $+ $gettok(%hex,$rand(1,$numtok(%hex,32)),32)
  }
}

Re: Script to generate random Twitch user name color [Re: Blas] #259509 11/12/16 12:14 PM
Joined: Apr 2015
Posts: 42
A
Artiiz Offline
Ameglian cow
Offline
Ameglian cow
A
Joined: Apr 2015
Posts: 42
Can you get ban for using this script on Twitch with your Twitch.tv account?

Re: Script to generate random Twitch user name color [Re: Artiiz] #259512 11/12/16 09:17 PM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Originally Posted By: Artiiz
Can you get ban for using this script on Twitch with your Twitch.tv account?


No idea. I doubt it, although it would not surprise me though as I would imagine the nickname color system was never meant to be used this way.

Anyways, I was bored, I took the code a tiny step further and now it will never repeat your current color by chance when changing colors. You'll need Twitch msgtags enabled for it to work.

Code:
ON *:TEXT:*:#: {
  IF ($nick == $me) {
    VAR %hex 000000 FF00FF 00FFFF FFFF00 FFFFFF
    VAR %hex $remtok(%hex,$remove($msgtags(color).key,$chr(35)),0,32)
    MSG $chan .color $chr(35) $+ $gettok(%hex,$rand(1,$numtok(%hex,32)),32)
  }
}

Re: Script to generate random Twitch user name color [Re: Neo] #260617 23/05/17 07:29 PM
Joined: May 2017
Posts: 1
J
JumboPaperClip Offline
Mostly harmless
Offline
Mostly harmless
J
Joined: May 2017
Posts: 1
Is there anyway to make it so it doesn't repeat a color (color range) within like 10 lines of text? Just trying to make it more colorful, less colors that are almost the same would be nice.

Kind Regards,
-JumboPaperClip