Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.77 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2016 Luigi Martinelli <xdefconhd@gmail.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * @author Luigi Martinelli <xdefconhd@gmail.com>
  18. *
  19. */
  20.  
  21.  
  22. registerPlugin({
  23. name: "Animated Nickname",
  24. version: "1.4",
  25. description: "This scripts kicks some fun in your bot, you can set a custom animated nickname or description.",
  26. author: "Luigi M. - xDefcon (xdefconhd@gmail.com)",
  27. vars: {
  28. enableSwitch: {
  29. title: "Activate the script?", type: "select", options: ["no", "yes"]
  30. }, animatedMode: {
  31. title: "Animated mode [nick/desc/both]",
  32. type: "select",
  33. options: ["nickname", "description", "nickname + description"]
  34. }, delayTime: {
  35. title: "Nick/Desc changer delay [milliseconds]",
  36. type: "number",
  37. placeholder: "Change nick/description every... (Default: 1000ms)."
  38. }, customNicks: {
  39. title: "Nicknames list",
  40. type: "string",
  41. placeholder: "A comma separated list of nicks/descs (e.g: BOT 1,BOT 2,BOT 3)."
  42. }, adminUUID: {
  43. title: "Command admin UUIDs",
  44. type: "string",
  45. placeholder: "A comma separated list of Unique IDs of admins to run the !animated on/off command"
  46. }, debugSwitch: {
  47. title: "Enable debug messages?", type: "select", options: ["no", "yes"]
  48. }
  49. }
  50. }, function (sinusbot, config) {
  51. var i = 0;
  52. var minimumDelay = 100;
  53. var adminUUID = [];
  54. var initialNick = sinusbot.getNick();
  55. if (typeof config.enableSwitch == "undefined") {
  56. config.enableSwitch = false;
  57. }
  58. if (typeof config.animatedMode == "undefined") {
  59. config.animatedMode = 0;
  60. debug("No mode selected, selecting NICK mode...")
  61. }
  62. if (typeof config.debugSwitch == "undefined") {
  63. config.debugSwitch = 0;
  64. }
  65. if (config.adminUUID) {
  66. adminUUID = config.adminUUID.split(",");
  67. debug(adminUUID.length + " Admin UUIDs loaded.")
  68. } else {
  69. debug("No Admin UUIDs found.");
  70. }
  71. if (typeof config.delayTime == "undefined") {
  72. config.delayTime = 1000;
  73. debug("Nick/Desc changer delay set to 1000ms.");
  74. } else if (config.delayTime < minimumDelay) {
  75. debug("To avoid lag/crashes, the delay MUST be greater than 100 milliseconds.");
  76. config.delayTime = 1000;
  77. debug("Delay set to 1 second.");
  78. } else {
  79. debug("Nick/Desc changer delay set to " + config.delayTime + ".");
  80. }
  81. if (typeof config.customNicks == "undefined") {
  82. debug("Nickname/description list empty or wrong, SCRIPT STOPPED.");
  83. return;
  84. }
  85.  
  86. var intervalN = setInterval(nickChange, config.delayTime);
  87. sinusbot.on("chat", function (ev) {
  88. var message = ev.msg;
  89. if (adminUUID.indexOf(ev.clientUid) >= 0) {
  90. switch (message) {
  91. case "!animated on":
  92. config.enableSwitch = 1;
  93. debug("Enabling script by command.");
  94. break;
  95. case "!animated off":
  96. config.enableSwitch = 0;
  97. debug("Disabling script by command.");
  98. if (config.animatedMode == 0) sinusbot.setNick(initialNick);
  99. if (config.animatedMode == 1) sinusbot.setDescription(" ");
  100. if (config.animatedMode == 2) {
  101. sinusbot.setDescription(" ");
  102. sinusbot.setNick(initialNick);
  103. }
  104. break;
  105. default:
  106. var split = message.split(" ");
  107. if (split[0] + " " + split[1] == "!animated mode") {
  108. switch (split[2]) {
  109. case "nickname":
  110. config.animatedMode = 0;
  111. sinusbot.chatPrivate(ev.clientId, "Animated mode set to: nickname.");
  112. debug("Animated mode set to: nickname via COMMAND by: " + ev.clientUid);
  113. break;
  114. case "description":
  115. config.animatedMode = 1;
  116. sinusbot.chatPrivate(ev.clientId, "Animated mode set to: description.");
  117. debug("Animated mode set to: description via COMMAND by: " + ev.clientUid);
  118. break;
  119. case "both":
  120. config.animatedMode = 2;
  121. sinusbot.chatPrivate(ev.clientId, "Animated mode set to: nickname + description.");
  122. debug("Animated mode set to: nickname + description via COMMAND by: " + ev.clientUid);
  123. break;
  124. default:
  125. sinusbot.chatPrivate(ev.clientId, "Unknown mode for '" + split[2] + "', valid ones are: 'nickname', 'description' and 'both'.");
  126. break;
  127. }
  128. }
  129. if (split[0] + " " + split[1] == "!animated delay") {
  130. if (!isNaN(split[2])) {
  131. var msgDelay = parseInt(split[2]);
  132. if (msgDelay < minimumDelay) {
  133. sinusbot.chatPrivate(ev.clientId, "To avoid lag/crashes, the delay MUST be greater than 100 milliseconds.");
  134. } else {
  135. config.delayTime = msgDelay;
  136. clearInterval(intervalN);
  137. intervalN = setInterval(nickChange, config.delayTime);
  138. sinusbot.chatPrivate(ev.clientId, "Delay time set to: " + msgDelay + " milliseconds.");
  139. debug("Delay time set to: " + msgDelay +" by: " + ev.clientUid);}
  140. }
  141. }
  142. break;
  143. }
  144.  
  145. }
  146. });
  147.  
  148. function debug(msg) {
  149. if (config.debugSwitch == 1) {
  150. sinusbot.log("[DEBUG] " + msg);
  151. }
  152. }
  153.  
  154. function nickChange() {
  155. if (!config.enableSwitch) return;
  156. var nickArr = config.customNicks.split(",");
  157. debug("Found " + nickArr.length + " nickname(s)/description(s).");
  158. if (i >= nickArr.length) {
  159. i = 1;
  160. if (config.animatedMode == 0) sinusbot.setNick(nickArr[0]);
  161. if (config.animatedMode == 1) sinusbot.setDescription(nickArr[0]);
  162. if (config.animatedMode == 2) {
  163. sinusbot.setNick(nickArr[0]);
  164. sinusbot.setDescription(nickArr[0]);
  165. }
  166. debug("Reset counter.");
  167. } else {
  168. if (config.animatedMode == 0) sinusbot.setNick(nickArr[i]);
  169. if (config.animatedMode == 1) sinusbot.setDescription(nickArr[i]);
  170. if (config.animatedMode == 2) {
  171. sinusbot.setNick(nickArr[i]);
  172. sinusbot.setDescription(nickArr[i]);
  173. }
  174. i++;
  175. }
  176. }
  177. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement