Guest User

Untitled

a guest
Jan 20th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.31 KB | None | 0 0
  1. let alertDuration = {alertDuration};
  2. alertCoolDown = {alertCooldown};
  3. stopCommand = "!stopalert";
  4. canAlert = true;
  5. aVolume = {alertVolume} * .01;
  6. audio = null;
  7. var onCoolDown =[];
  8. /*
  9. - Tutorials here: https://www.youtube.com/_zanzer (theres one on how to get images / video links)
  10. - You can have multiple images/videos and pick a random one for a command see !test-
  11. use "image" for any gifs/images; use "video" for a video
  12.  
  13. use "sound" if you want a sound with your video, if your video has sound - this will play BOTH. and sound will
  14. play for the duration of your default alert duration or overide ie: Set Length to length of video
  15.  
  16. ---- Image only Parameters ---
  17. use "volume" 1-100 to adjust the volume osf a specific command
  18. Use "length" to set a length overide on the command (play longer or shorter than default)
  19. use "sound" to add a sound to your command
  20.  
  21. "!EXAMPLE": {
  22. "image": "https://cdn.streamelements.com/uploads/f3918cf4-3a29-42c2-8708-e7c1495b4601.gif",
  23. "sound": "https://cdn.streamelements.com/uploads/ffb21cb9-3520-42f6-b69f-d875ddd1eae3.mp3",
  24. "length": 6000, *set the length for that .mp4 or gif in ms*
  25. "volume": 50,
  26. "cooldown": 10000,
  27. "delaysound": 1000,
  28. "delayimage": 2000
  29. "sub": 0, // if you want the command to be subscriber only
  30. "mod": 0, // if you want the command to be mod / broadcaster only
  31.  
  32. "user": ["megalewdslime", "Rory"],
  33. "sound": ["linke #1","link #2","link #3"],
  34. "video": ["linke #1","link #2","link #3"],
  35. "image": ["linke #1","link #2","link #3"], }, */
  36.  
  37. alertCommands ={
  38.  
  39.  
  40.  
  41.  
  42.  
  43. /* ANIME */
  44. /* SCENES */
  45.  
  46. /* 00 */ "!resso": { "cooldown": 1000, // Ochin daiski des!
  47. "video": "https://cdn.streamelements.com/uploads/18b96efb-cde0-4919-b9ea-a82e5debac2e.webm" },
  48.  
  49. /* 01 */ "!ochin": { "cooldown": 60000, "volume": 20, // Ochin daiski des!
  50. "video": "https://cdn.discordapp.com/attachments/1192455917208346737/1192456022682521740/01._ochin_long_small.mp4", },
  51.  
  52. /* 39 */ "!mono": { "cooldown": 60000, "volume": 10,
  53. "video": [
  54.  
  55. "https://cdn.discordapp.com/attachments/1192455917208346737/1192548338403393596/039.1._mono.mp4",
  56. "https://cdn.discordapp.com/attachments/1192455917208346737/1192548338931871784/039.2._mono.mp4",
  57.  
  58. ]},
  59.  
  60.  
  61.  
  62.  
  63. /* END */
  64.  
  65. };
  66.  
  67. // ===============================================================================================================================================
  68. // ===============================================================================================================================================
  69. // ===============================================================================================================================================
  70. // ===============================================================================================================================================
  71.  
  72.  
  73. // ------------------------------- TIMER ------------------------------- // ------------------------------- TIMER -------------------------------
  74. var IntervallId = null;
  75. var timerC = 0;
  76. var start_timer = true;
  77. // ------------------------------- TIMER ------------------------------- // ------------------------------- TIMER -------------------------------
  78.  
  79.  
  80. window.addEventListener('onEventReceived', function (obj) {
  81. if (!obj.detail.event) {
  82. return;
  83. }
  84. const event = obj.detail.event;
  85.  
  86.  
  87. if (obj.detail.listener !== "message") return;
  88.  
  89. var command = event["data"]["text"].split(" ")[0].toLowerCase();
  90. var data = obj.detail.event.data;
  91. var senderName = event["data"]["displayName"].toLowerCase();
  92.  
  93. if(event["data"]["badges"].length > 0) //Twitch Functionality Only
  94. var badge = event["data"]["badges"][0]["type"];
  95.  
  96. var isMod = (badge === 'moderator' || badge === 'broadcaster');
  97. var isSub = (badge === 'subscriber'|| badge === 'broadcaster' || badge === 'moderator' );
  98.  
  99. if(command === stopCommand && isMod)
  100. {
  101. stopVideo();
  102. }
  103. if(command in alertCommands && canAlert && onCoolDown.length <= 0){
  104. if('sub' in alertCommands[command] && !isSub)
  105. return;
  106. if('mod' in alertCommands[command] && !isMod)
  107. return;
  108. if('user' in alertCommands[command] && !alertCommands[command]["user"].includes(senderName))
  109. return;
  110.  
  111.  
  112. // ------------------------------- TIMER ------------------------------- // ------------------------------- TIMER -------------------------------
  113. timerC = 0;
  114. $("#timer").html("");
  115. if(IntervallId != null){
  116. $("#timer").fadeTo(1000,0); // NOT WORKING - SET THE DURATION OF THE FADE OUT FOR THE TIMER
  117.  
  118. //IntervallId.forEach(element => clearInterval(element));
  119. //IntervallId.forEach(element => console.log(element));
  120. //clearInterval(IntervallId);
  121. }
  122. // ------------------------------- TIMER ------------------------------- // ------------------------------- TIMER -------------------------------
  123.  
  124.  
  125. alertCoolDown = {alertCooldown};
  126.  
  127. if("volume" in alertCommands[command])
  128. aVolume = alertCommands[command]["volume"] * .01;
  129. if("cooldown" in alertCommands[command])
  130. alertCoolDown = alertCommands[command]["cooldown"];
  131. if("length" in alertCommands[command])
  132. alertDuration = alertCommands[command]["length"];
  133. if("sound" in alertCommands[command]){
  134.  
  135. var playThis = alertCommands[command]["sound"];
  136. if(Array.isArray(playThis))
  137. playThis = playThis[Math.floor(Math.random() * playThis.length)];
  138.  
  139. if("delaysound" in alertCommands[command]){
  140. setTimeout(function () {
  141. playAudio(playThis, alertDuration);
  142. }, alertCommands[command]['delaysound'] - alertCommands[command]['delaysound']);
  143. }
  144. else
  145. playAudio(playThis, alertDuration);
  146. }
  147. if("image" in alertCommands[command]){
  148. var showThis = alertCommands[command]["image"];
  149. if(Array.isArray(showThis))
  150. showThis = showThis[Math.floor(Math.random() * showThis.length)];
  151.  
  152. if('delayimage' in alertCommands[command]){
  153. setTimeout(function () {
  154. showImage(showThis,alertDuration - alertCommands[command]['delayimage'] );
  155. }, alertCommands[command]['delayimage']);
  156. }
  157. else
  158. showImage(showThis,alertDuration );
  159. }
  160. if("video" in alertCommands[command]){
  161.  
  162. // do stuff in here for video
  163.  
  164.  
  165. var showThis = alertCommands[command]["video"];
  166.  
  167.  
  168. if(Array.isArray(showThis))
  169. showThis = showThis[Math.floor(Math.random() * showThis.length)];
  170.  
  171. // ------------------------------- TIMER ------------------------------- // ------------------------------- TIMER -------------------------------
  172. // ADDED ---- , alertCoolDown, command); ---- TO THE LINE
  173. playVideo(showThis, alertCoolDown, command);
  174. // ------------------------------- TIMER ------------------------------- // ------------------------------- TIMER -------------------------------
  175.  
  176. if("length" in alertCommands[command])
  177. alertDuration = alertCommands[command]["length"];
  178. if("sound" in alertCommands[command])
  179. if("delaysound" in alertCommands[command]){
  180. setTimeout(function () {
  181. playAudio(alertCommands[command]["sound"], alertDuration - alertCommands[command]['delaysound'] );
  182. }, alertCommands[command]['delaysound']);
  183. }
  184. else
  185. playAudio(alertCommands[command]["sound"], alertDuration);
  186. }
  187.  
  188.  
  189.  
  190. canAlert = false;
  191. onCoolDown.push(command);
  192. // ------------------------------- TIMER -------------DOWN------------------ // ------------------------------- TIMER -------------------------------
  193. setTimeout(function () {
  194. // onCoolDown = onCoolDown.filter(function(onCoolDown) { ------ this was deleted
  195. //return onCoolDown !== command}) ------ this was deleted
  196. // }, alertCoolDown); ------ this was deleted
  197.  
  198.  
  199.  
  200.  
  201.  
  202. // setTimeout(function () { ------ this was deleted
  203. canAlert = true;
  204. alertDuration = {alertDuration};
  205. aVolume = {alertVolume} * .01;
  206. }, alertDuration + 1000);
  207. }
  208.  
  209. });
  210.  
  211. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TIMER -------------UP------------------ // ------------------------------- TIMER -------------------------------
  212.  
  213. function playAudio(sound, alertD){
  214.  
  215. audio = new Audio(sound);
  216. audio.volume = aVolume;
  217. audio.play();
  218. setTimeout(function () {
  219. audio.pause();
  220. }, alertD);
  221. }
  222.  
  223. function showImage(imageSRC, alertD){
  224.  
  225. $('#img').attr('src',imageSRC).hide().fadeIn("slow");
  226. //$('#img').attr('src',imageSRC).hide().slideDown(1500);
  227. setTimeout(function () {
  228. $("#img").fadeOut("slow");
  229. }, alertD);
  230. }
  231. function stopVideo(){
  232. var video = document.getElementById("vid");
  233. var img = document.getElementById("img");
  234. $("#img").fadeOut("slow");
  235.  
  236. $("#vid").fadeTo("slow",0);
  237. $("#vid")[0].pause();
  238. audio.pause();
  239.  
  240. }
  241.  
  242. // ------------------------------- TIMER --------------DOWN----------------- // ------------------------------- TIMER -------------------------------
  243.  
  244. function startTimer(duration) {
  245. timerC = alertCoolDown;
  246. var minutes = 0;
  247. var seconds = 0;
  248.  
  249. /*
  250. var TimeOut = function () {
  251. minutes = parseInt(timerC / 60000, 10);
  252. seconds = parseInt((timerC % 60000) / 1000, 10);
  253.  
  254. minutes = minutes < 10 ? "0" + minutes : minutes;
  255. seconds = seconds < 10 ? "0" + seconds : seconds;
  256.  
  257. if (seconds > 100) {
  258. seconds = seconds < 100 ? "0" + seconds : seconds;
  259. };
  260.  
  261. function convert(minutes) { return 60 * minutes; };
  262.  
  263. display.innerHTML = seconds;
  264.  
  265.  
  266. timerC = timerC - 1000;
  267.  
  268. if (timerC < 0) {
  269. //timer = duration;
  270. $("#timer").fadeTo("slow",0);
  271. display.innerHTML = "00";
  272. IntervallId.forEach(element => clearInterval(element));
  273.  
  274. }
  275. };*/
  276.  
  277. var TimeOut = function () {
  278. seconds = parseInt(timerC / 1000, 10);
  279.  
  280. seconds = seconds < 10 ? "0" + seconds : seconds;
  281.  
  282. //display.innerHTML = seconds;
  283. $("#timer").html(seconds);
  284.  
  285.  
  286. timerC = timerC - 1000;
  287.  
  288. if (timerC < 0) {
  289. //timer = duration;
  290. $("#timer").fadeTo(1000,0, function(){ $("#timer").html(""); start_timer = true; clearInterval(IntervallId); }); // FADE OUT - END of the timer
  291. }
  292. };
  293.  
  294. //IntervallId.push(setInterval(TimeOut, 1000));
  295. if(IntervallId != null){
  296. clearInterval(IntervallId);
  297. }
  298. IntervallId = setInterval(TimeOut, 1000);
  299. }
  300.  
  301.  
  302.  
  303. /*
  304. function startTimer(duration, display) {
  305. timerC = duration;
  306. var minutes = 0;
  307. var seconds = 0;
  308.  
  309.  
  310. var TimeOut = function () {
  311. minutes = parseInt(timerC / 60000, 10);
  312. seconds = parseInt((timerC % 60000) / 1000, 10);
  313.  
  314. minutes = minutes < 10 ? "0" + minutes : minutes;
  315. seconds = seconds < 10 ? "0" + seconds : seconds;
  316.  
  317. display.innerHTML = minutes + ":" + seconds;
  318.  
  319. timerC = timerC - 1000;
  320.  
  321. if (timerC < 0) {
  322. //timer = duration;
  323. $("#timer").fadeTo("slow",0);
  324. display.innerHTML = "00:00";
  325. IntervallId.forEach(element => clearInterval(element));
  326.  
  327. }
  328. };
  329.  
  330. IntervallId.push(setInterval(TimeOut, 1000));
  331. }
  332.  
  333. */
  334.  
  335. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TIMER -------------UP------------------ // ------------------------------- TIMER -------------------------------
  336.  
  337.  
  338. // ------------------------------ TIMER --------------DOWN----------------- // ------------------------------- TIMER -------------------------------
  339.  
  340. function playVideo(videoSRC, duration, command){
  341. var vid = document.getElementById("vid");
  342. var cd = alertCoolDown;
  343. $('#vid').attr('src',videoSRC).hide().fadeIn("fast"); // SET - 0 - TO 'SLOW in "slow" ' for transition in the beninning
  344.  
  345. vid.volume = aVolume;
  346. vid.play();
  347.  
  348.  
  349. $("#vid").fadeTo("fast",1); // TRUE TRANSITION OR FALSE???? SET - 0 - TO 'SLOW' for transition in the beninning
  350. $('#vid').on('ended', function () {
  351.  
  352. $("#vid").fadeTo("slow",0, function(){
  353.  
  354. });
  355. if(start_timer){
  356. /*var to_show = cd/1000;
  357. if(to_show > 0){
  358. to_show = to_show < 10 ? "0" + to_show : to_show;
  359.  
  360. $("#timer").html(to_show);
  361. }*/
  362. $("#timer").fadeTo(2000, 1); // FADE IN - START of the timer
  363. start_timer = false;
  364. startTimer(cd);
  365. }
  366. $("#vid")[0].pause();
  367.  
  368. setTimeout(function () {
  369. onCoolDown = onCoolDown.filter(function(onCoolDown) {
  370. return onCoolDown !== command})
  371. }, cd);
  372.  
  373.  
  374.  
  375. });
  376.  
  377. }
  378.  
  379. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TIMER --------------UP----------------- // ------------------------------- TIMER -------------------------------
  380. /*
  381.  
  382. // ORIGINAL PLAY VIDEO
  383.  
  384. function playVideo(videoSRC){
  385. var vid = document.getElementById("vid");
  386. $('#vid').attr('src',videoSRC).hide().fadeIn("slow");
  387.  
  388. vid.volume = aVolume;
  389. vid.play();
  390.  
  391. $("#vid").fadeTo("slow",1);
  392. $('#vid').on('ended', function () {
  393. $("#vid").fadeTo("slow",0);
  394. $("#vid")[0].pause();
  395. });
  396.  
  397. }
  398.  
  399. */
  400.  
  401.  
  402.  
  403.  
  404.  
  405. var senderNameBlob = event["data"]["displayName"].toLowerCase();
  406. var commandBlob = event["data"]["text"].split(" ")[0].toLowerCase();
  407. var textBlob = "!speak'text'".replace('!speak','');
  408.  
  409. if(text="!speak")
  410. {
  411. displayText("haha");
  412. };
  413.  
  414. document.write("My message");
  415.  
  416.  
Advertisement
Add Comment
Please, Sign In to add comment