Advertisement
az4521

Untitled

Jun 12th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. /**
  2. * Script: Colors
  3. *
  4. * Gives your text gradient colors. Colors are turned on by typing
  5. * the command "/colors on" and they are turned off by typing the
  6. * command "/colors off".
  7. */
  8. var ignore = [];
  9. var colors = [
  10. '#00efd3',
  11. '#00d7d1',
  12. '#00cacf',
  13. '#00bccd',
  14. '#00afcb',
  15. '#00a1c9',
  16. '#0094c7',
  17. '#0086c4',
  18. '#0079c3',
  19. '#006bc1',
  20. '#005ebf'
  21. ];
  22. var colors_on = false;
  23.  
  24. $api.on("user_join", function(e, data) {
  25. ignore.push(data.name.toLowerCase());
  26. });
  27.  
  28. $api.on("emotes", function(e, data) {
  29. for(var i = 0; i < data.length; i++) {
  30. ignore.push(data[i].name.toLowerCase());
  31. }
  32. });
  33.  
  34. $api.on("send", function(e, data) {
  35. if (data.msg.indexOf("/colors ") === 0 || data.msg.indexOf("/colours ") === 0) {
  36. var arg = data.msg.replace("/colors ", "");
  37. arg = arg.replace("/colours ", "");
  38. colors_on = (arg == "on");
  39. e.cancel();
  40. return;
  41. } else if (data.msg[0] == "/" || data.msg[0] == "$" || data.msg.match(/:([^:]+):/) || data.msg.toLowerCase().indexOf("http://") !=-1 || data.msg.toLowerCase().indexOf("https://") !=-1 || data.msg[0] == ">") {
  42. return;
  43. }
  44. for(var i = 0; i < ignore.length; i++) {
  45. if (data.msg.toLowerCase().indexOf(ignore[i]) !== -1) {
  46. return;
  47. }
  48. }
  49. if (!colors_on) {
  50. return;
  51. }
  52.  
  53. var newstr = '';
  54. var counter = 0;
  55. var chars = data.msg.split('');
  56. for (var x in chars) {
  57. if (chars[x]!=' ') {
  58. newstr = newstr + '[' + colors[counter] + ']' + chars[x] + '[/#]';
  59. counter++;
  60. } else {
  61. newstr = newstr + ' ';
  62. }
  63. if (counter >= colors.length) {
  64. colors.reverse();
  65. counter = 0;
  66. }
  67. }
  68.  
  69. data.msg = newstr;
  70. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement