Bots Home
|
Create an App
Notification
Author:
wonderalice69
Description
Source Code
Launch Bot
Current Users
Created by:
Wonderalice69
/* Notification Domination Version: 0.01 Programmed by losthearted Creation Date: Oct 25, 2013 Last Modified: Nov 4, 2013 Description: Notification Domination is meant to act as a single bot to allow multiple notifications of different types, without running multiple bots. Help: All notes are inactive until you either set a interval, or set another type that does not require one. /note new TEXT adds a new note with TEXT, seperate multiple lines with \n to display multiple notices at once usage: /note add TIP for requests usage: /note add tip 25 tokens for boob flash\ntip 50 tokens for ass flash\ntip 100 tokens for vagina flash /note mod # TEXT modifies the specified note number to say TEXT usage: /note mod 1 NO demands /note type # time #SECONDS sets the note # to display at the specified interval of time in seconds you can also specify multiple note numbers, by seperating them with a comma, though it is suggested that you use a multi-line note instead of the same timing on multiple notes usage: /note int 1 time 60 this sets note number 1 to display every minute usage: /note int 1,5,8 time 120 this sets notes 1, 5, and 8 to occur every 2 minutes /note type # msg #MESSAGES sets the interval of the specified note number to occur ever X number of chat messages the # can also be multiple note numbers, seperated by a comma, though it is suggested that you use a multi-line note instead of the same interval on multiple notes usage: /note int 1 msg 20 sets note number 1 to display every 20 messages in the chat usage: /note int 2,6,8 msg 15 sets notes 2, 6, and 8 to display every 15 messages in the chat /note type # entry (all|grey|blue|red|lgblue|dkblue) this converts the specified note # to a private note that displays to a user when they enter you you can also select multiple notes by seperating their numbers with a comma the last parameter is optional, and lets you set notes to display to a certain user class on entry all OR any- display the note to all users on entry, this is the default behavior grey - display to only greys blue - display to only blues red - display to only mods lgblue - display to only light blues dkblue - display to only dark blues usage: /note type 1 entry converts note 1 to an entry note usage: /note type 1 entry red converts note 1 to display to mods only upon entry usage: /note type 2,6,9 entry blue sets notes number 2, 6, and 9 to display to blues upon entry /note type # entrypub (all|grey|blue|red|lgblue|dkblue) same as above, except the note is displayed in the public chat it is HIGHLY recomended that you select a user class such as blue or red, to avoid the note being displayed too often usage: /note type 1 entrypub red converts note 1 to display upon entry of mods /note type # tip RANGE this converts the note to display to EVERYONE when a particular tip amount or range is specified multiple notes can also be specified by using numbers seperated by commas usage: /note type 1 tip displays the note to EVERYONE when someone tips any number usage: /note type 1 tip 100 displays the note to EVERYONE when someone tips EXACTLY 100 usage: /note type 1 tip 1000+ displays the note to EVERYONE when someone tips OVER 1000 usage: /note type 1 tip 100-500 displays the note to EVERYONE when someone tips between 100-500 usage: /note type 2,5,7 tip 50+ displays notes 2, 5, and 7 to EVERYONE when someone tips over 50 /note type # tippriv RANGE same as above, but only displays the note to the tipper multiple notes can be specified by seperating their numbers with a comma usage: /note type 1 tippriv 333 displays a note to the tipper, such as a thanks for joining your club usage: /note type 2,3,5 tippriv 100+ displays notes 2, 3, and 5 to tippers that tip over 100 /note delete # deletes note number usage: /note delete 1 deletes note number 1 /note export # exports the note number(s) to later be imported when you relaunch the bot if no number(s) is/are specified, then all notes will be exported using specified numbers, you can export notes for standard requests seperately from ads for your room, in case your rates change you can also export ads that are specific to a show happening in a week, and import them seperately /note import JSON this imports the JSON data that was previously exported, for quick note setup /note list lists all notes with thier note number and data, for reference while editing */ /*global setInterval, clearInterval, cb */ /*jslint plusplus: true */ var notes = [{}]; var msgCount = 0; var $1, $2, $3; function newNote (noteText) { //creats a new note cb.log("Creating new note."); var $i; for ($i = 0; $i <= notes.length; $i++) { //iterates through each note to see if it's the last if (notes[$i] === undefined){ notes[$i] = {'ntext': noteText}; notes[$i]['ntext'] = noteText; cb.chatNotice("New note # " + $i + " has been created.", cb.room_slug); } else if ( (notes[$i] !== undefined) && ($i === notes.length) ) { notes[$i+1] = {'ntext':noteText}; cb.chatNotice("New note # " + ($i+1) + " has been created.", cb.room_slug); } } } function setNoteIntTime (noteNum, noteTimeInt) { //sets timer info, sets timer cb.log("Setting note #" + noteNum + " to occur every " + noteTimeInt + "seconds."); if (notes[noteNum].timerRef !== undefined) { clearInterval(notes[noteNum].timerRef); //clears the timer if one exists } notes[noteNum] = {'intType':'time', 'timeInt':noteTimeInt, 'timerRef':setInterval(cb.chatNotice(notes[noteNum].ntext), noteTimeInt*1000)}; cb.chatNotice("Note # " + noteNum + " has been set to display every " + noteTimeInt +" seconds.", cb.room_slug); } function setNoteIntMsg (noteNum, noteMsgInt) { if (notes[noteNum].timerRef !== undefined) { clearInterval(notes[noteNum].timerRef); //clears the timer if one exists notes[noteNum].timerRef = undefined; } notes[noteNum] = {'intType':'msg', 'msgInt':noteMsgInt}; cb.chatNotice("Note # " + noteNum + " has been set to display every " + noteMsgInt + " messages.", cb.room_slug); } function delNote (noteNum) { if (notes[noteNum].timerRef !== undefined) { clearInterval(notes[noteNum].timerRef); //clears the timer if one exists } delete notes[noteNum]; cb.chatNotice("Note # " + noteNum + " has been deleted.", cb.room_slug); } cb.onEnter(function (entry) { // iterates through notes to determine if any need to be displayed var $i; for ($i = 0; $i <= notes.length; $i++) { if ( (notes[$i] !== undefined) && ( (notes[$i].nType === "entry") || (notes[$i].nType === "entrypub") ) ) { if (notes[$i].userClass === undefined) { if (notes[$i].nType === "entrypub") { cb.chatNotice(notes[$i].nText); } else { cb.chatNotice(notes[$i].nText, entry.user); } } else if ( ( (notes[$i].userClass === "grey") && (entry.has_tokens === "False") ) || ( (notes[$i].userClass === "blue") && (entry.has_tokens === "True") ) || ( (notes[$i].userClass === "dkblue") && (entry.has_tokens === "True") && (entry.tipped_recently === "True") ) || ( (notes[$i].userClass === "lgblue") && (entry.has_tokens === "True") && (entry.tipped_recently === "False") ) || ( (notes[$i].userClass === "red") && (entry.is_mod === "True") ) ) { if (notes[$i].nType === "entrypub") { cb.chatNotice(notes[$i].nText); } else { cb.chatNotice(notes[$i].nText, entry.user); } } } } }); cb.onMessage(function (msg) { //handles all messages var $i; if ((msg.user === cb.room_slug) && (/\/note/.test(msg.m))) { // message sent by broadcaster, and is a note command msg['X-Spam'] = true; cb.log("/note command recognized sent by broadcaster"); if (/\/note\snew\s(.+)$/i.test(msg.m)){ //create new note with text $1 newNote($1); } else if (/\/note\smod\s(\d+)\s(.+)$/i.test(msg.m)) { if (notes[$1] === undefined) { cb.chatNotice("Note # " + $1 + " does not exist! Ensure that you are using the correct note number, and try again. Use '/note new TEXT' to create a new note.", cb.room_slug); return msg; } notes[$1].ntext = $2; //modify note $1 to new text $2 cb.chatNotice("Note # " + $1 + " has been modified to the new text.", cb.room_slug); } else if (/^\/note\stype\s(\d+(,\s?\d+)?)\s([a-zA-Z]+)\s(\d+)$/i.test(msg.m)) { //modify note(s) $1 interval to specified type and number var noteNums = $1.split(","), intType = $2, intNum = $3; if ( /^time$/i.test(intType) ) { //modify note(s) noteNums to occur every intNum seconds for ($i = 0; $i < noteNums.length; $i++) { if (notes[noteNums.$i] === undefined) { cb.chatNotice("Note # " + noteNums.$i + " does not exist! Ensure that you are using the correct note number, and try again. Use '/note new TEXT' to create a new note.", cb.room_slug); return msg; } setNoteIntTime(parseInt(noteNums[$i], 10), intNum); } return msg; } else if ( /^time$/i.test(intType) ) { //modify note(s) noteNums to occur every intNum messages for ($i = 0; $i < noteNums.length; $i++) { if (notes[noteNums.$i] === undefined) { cb.chatNotice("Note # " + noteNums.$i + " does not exist! Ensure that you are using the correct note number, and try again. Use '/note new TEXT' to create a new note.", cb.room_slug); return msg; } setNoteIntMsg (noteNums.$i, intNum); } return msg; } else { cb.chatNotice("Sorry, you seem to have made an error in syntax. Please refer to the documentation and try again.", msg.user); return msg; } } else if (/^\/note\stype\s(\d+(,\s?\d+)?)\s([a-zA-Z]+)(\s([a-zA-Z0-9]+)(\+|(\-[a-zA-Z0-9]))?)?$/i.test(msg.m)) { //converts note(s) $1 to another type var noteNums = $1.split(","), nType = $2, userClass = $3; if (/^entry(pub)?$/i.test(nType)) { for ($i = 0; $i <= noteNums.length; $i++) { if (notes[noteNums.$i] === undefined) { cb.chatNotice("Note # " + noteNums.$i + " does not exist! Ensure that you are using the correct note number, and try again. Use '/note new TEXT' to create a new note.", cb.room_slug); return msg; } if (notes[noteNums.$i] === undefined) { cb.chatNotice("Note # " + noteNums.$i + " does not exist! Ensure that you are using the correct note number, and try again. Use '/note new TEXT' to create a new note.", cb.room_slug); return msg; } if ( (userClass === undefined) || (/(any)|(all)/i.test(userClass)) ) { notes[$i] = {'nType':nType}; // appears to all in on entry } else if ( /^((grey)|(blue)|(red)|(lgblue)|(dkblue))$/i.test(userClass) ){ // appears to defined userClass upon entry notes[$i] = {'nType':nType, 'userClass':userClass.toLowerCase()}; } else { //oops! entered bad user class! cb.chatNotice("Sorry, that is an invalid user class. Please refer to the documentation and try again.", msg.user); } } return msg; } else if (/^tip(priv)?$/i.test(nType)) { for ($i = 0; $i <= noteNums.length; $i++) { if (notes[noteNums.$i] === undefined) { cb.chatNotice("Note # " + noteNums.$i + " does not exist! Ensure that you are using the correct note number, and try again. Use '/note new TEXT' to create a new note.", cb.room_slug); return msg; } notes[$i] = {'nType':nType.toLowerCase()}; } } else { cb.chatNotice("Sorry, that is an invalid note type. Please refer to the documentation and try again.", msg.user); return msg; } } else { cb.chatNotice("Sorry, you seem to have made an error in syntax. Please check the documentation and try again.", msg.user); return msg; } } else if ( (msg.user !== cb.room_slug) && (/\/note/.test(msg.m)) ) { // only broadcasters can command the bot! msg['X-Spam'] = true; cb.chatNotice("Only the broadcaster can use this command!", msg.user); return msg; // returns the message } else { // not a command msgCount++; // counting messages! // iterate through notes to see if any should be printed for ($i = 0; $i <= notes.length; $i++) { if ( (notes[$i].intType === 'msg') && ( msgCount % parseInt(notes[$i].msgInt, 10) === 0) ) { // note occurs on message! and it's this message! YAY! cb.chatNotice(notes[$i].nText); } } return msg; } }); cb.onTip(function (tip) { // called when a user tips // iterates through notes to determine if any need to be displayed var $i; for ($i = 0; $i <= notes.length; $i++) { if ( (notes[$i] !== undefined) && (notes[$i].noteType !== undefined) && ((notes[$i].noteType === 'tip') || (notes[$i].noteType === 'tippriv')) ) { // note displays when a user tips...but is it the right amount? if (notes[$i].tipAmount === undefined) { // display on every tip if (notes[$i].noteType === 'tippriv') { cb.chatNotice(notes[$i].nText, tip.from_user); } else { cb.chatNotice(notes[$i].nText); } } else if ( (/^(\d+)\+$/.notes[$i].tipAmount) && (tip.amount >= $1) ) { //deals with 100+ type tip ranges if (notes[$i].noteType === 'tippriv') { cb.chatNotice(notes[$i].nText, tip.from_user); } else { cb.chatNotice(notes[$i].nText); } } else if ( (/^(\d+)\-(\d+)$/.notes[$i].tipAmount) && (tip.amount >= parseInt($1, 10)) && (tip.amount <= parseInt($2, 10)) ) { //tip is in the range! YAY! if (notes[$i].noteType === 'tippriv') { cb.chatNotice(notes[$i].nText, tip.from_user); } else { cb.chatNotice(notes[$i].nText); } } else if ( (/^(\d+)$/.notes[$i].tipAmount) && (tip.amount === parseInt($1, 10)) ) { if (notes[$i].noteType === 'tippriv') { cb.chatNotice(notes[$i].nText, tip.from_user); } else { cb.chatNotice(notes[$i].nText); } } } } });
© Copyright Chaturbate 2011- 2026. All Rights Reserved.