Bots Home
|
Create an App
DaveyBot
Author:
davey4you
Description
Source Code
Launch Bot
Current Users
Created by:
Davey4you
/* Title: "Snowshoe" bot Author: davey4you Version: 1.0.0 (02/01/2015) Credit: badbadbubba for the original 'Rotating Notifier' bot This will be a growing bot initially designed for rebbecasnowshoe incorporating commonly used functions from other bots. 1. A rotating notifier. Options are 6 Message Texts, Colour and Interval. Messages are rotated in sequence. Message 1 will also be displayed on room entry to users privately. Up to 5 other messages can be set Message colour is from a drop down list to make it simpler for the broadcaster Changes/Additions: Version: 1.1.0 (24/01/2015) Function added to change notice while running */ //Common Variable declarations var prog_version = 'V1.1.0'; //Program version for display purposes // ******** Notifier ************ //Variable declarations var i=1; //Last message number displayed var notice_colour = '#9F000F'; //Colour for notices, html code default dark red #9F000F var notice_back = '#FFFFFF'; //Colour for notices background, html code default white #FFFFFF var notice_interval = 2; //Interval in minutes between notices var notice_seconds = 60;//Number of seconds in a minute, for debug we set to 10 when loading settings var notice = [];//Array for notices /*Commands * /sshelp for a command list * /sslist for a current list of notices * /sschangeX<new notice> amends the notice for the given notice number X */ //*********************************** // ******** Graphics Control ************ // NOT YET REALISED //Variable declarations //var graphic_level = 1; //Default level for Light Blue and above // 0 = All Users // 1 = Light Blue and above // 2 = Dark Blue and above // 3 = Purple and above // Fans, Mods and Broadcaster can always use graphics /*Commands * */ //*********************************** // ******** Just For Fun ************ //NOT YET REALISED //Variable declarations //var davey_best = 0; //When set to 1 the _kor_ gif will change //var user_loves_davey = ''; //Username who's messages will be appended //var davey_user_name = 'davey4youtest'; //var gif_to_check = ':betterthandavey'; //var gif_replacement = ':_betterthandavey'; /*Commands * /daveybest Changes the variable daveybest to 1 * /daveynormal Changes the variable daveybest to 0 * /giftocheck/gifname Name of the emote to check if davey_best is set * /replacegif/gifname Name of the emote to replace with * /lovesdavey/user Name to append messgaes with I love davey */ //*********************************** // ******** Feature Name ************ //Variable declarations /*Commands * */ //*********************************** //*** CB Settings and functions *** cb.settings_choices = [ {name:'notice1', type:'str', required: false, label: 'Message 1 (also displayed privately on room entry)',defaultValue: ''}, {name:'notice2', type:'str', required: false, label: 'Message 2',defaultValue: ''}, {name:'notice3', type:'str', required: false, label: 'Message 3',defaultValue: ''}, {name:'notice4', type:'str', required: false, label: 'Message 4',defaultValue: ''}, {name:'notice5', type:'str', required: false, label: 'Message 5',defaultValue: ''}, {name:'notice6', type:'str', required: false, label: 'Message 6',defaultValue: ''}, {name:'notice_colour', type:'choice', choice1: 'Dark Red', choice2: 'Orange', choice3: 'Black', choice4: 'Dark Blue', label: 'Message colour', defaultValue: 'Dark Red'}, //{name:'usegraphic', type:'choice', // choice1: 'Yes', // choice1: 'No', // label:'Use built-in graphic at start of Notice', defaultValue: 'No'},//Future use {name: 'notice_interval', type:'int', minValue: 1, maxValue: 999, defaultValue: 2, label: 'Delay in minutes between notices (minimum 1)'} //Graphic control settings //{name:'graphic_level', type:'choice', // choice1: 'All can use Graphics', // choice2: 'Light Blue and above', // choice3: 'Dark Blue and above', // choice4: 'Purple and above', // label: 'Graphic Control', defaultValue: 'Light Blue and above'} ]; cb.onEnter(function(user) { //Fires when a user enters the room, always show notice 1 // user davey4you specific var extra_message = '' //if (davey_user_name === user['user']) { //davey4you user, set variables // davey_best = 1; //extra_message = '\ndavey_best = ' + davey_best; //} cb.sendNotice('Welcome ' + user['user'] + '! ' + notice[1] + extra_message ,user['user'],notice_back,notice_colour,'bolder'); }); cb.onMessage(function (msg) { //Fires when a message is typed in chat // msg holds the following fields: //c - message colour //m - message text //user - user name //f - message font //in_fanclub - user is in fanclub (green) //has_tokens - user has tokens (blue user) //is_mod - user is a mod (red) //tipped_recently - user has tipped recently (dark blue) // gender: m (male), f (female), s (shemale), or c (couple) var strList = ""; var strMessage = msg['m']; //store the message in case we need to pass it to a function //Check for commands, initially set msg to X-Spam as soon as a '/' is found if (msg['m'][0] == '/') { msg['X-Spam'] = true; } // now check for a legal command // room slug (broadcaster) can view messagelist and set new messages if (cb.room_slug === msg['user']) {//Broadcaster, process broadcaster commands if (msg['m'].search('/sshelp') > -1) { //call the helper function to display the help message ShowHelp(cb.room_slug); } if (msg['m'].search('/sslist') > -1) { //call the helper function to display the current notices ShowNotices(cb.room_slug); } if (msg['m'].search('/sschange') > -1) { //call the helper function to display the current notices ChangeNotice(cb.room_slug, strMessage); } } // user davey4you specific //if (davey_user_name === msg['user']) { //davey4you user, process commands //if (msg['m'].search('/daveybest') > -1) { //set davey_best ON // davey_best = 1; //} //if (msg['m'].search('/daveynormal') > -1) { //set davey_best OFF // davey_best = 0; //} //if (msg['m'].search('/replacegif') > -1) { //set the emote/gif for the davey_best functionality // gif_replacement = msg['m'].substring(12); //} //if (msg['m'].search('/giftocheck') > -1) { //set the emote/gif for the davey_best functionality // gif_to_check = msg['m'].substring(12); //} //if (msg['m'].search('/lovesdavey') > -1) { //set the emote/gif for the davey_best functionality // user_loves_davey = msg['m'].substring(12); //} return msg; }); //*** Bot Helper Functions *** function ShowHelp(user) { //Show the Help message //user = user requesting the function var blank_msg = ''; var new_line = '\n'; var help_sep = '--------------------------------' var msg = '** COMMAND LIST: BROADCASTER ONLY **' + new_line; //Message list msg = msg + 'To see a list of current messages:' + new_line; msg = msg + 'Type /sslist' + new_line + help_sep + new_line; //Change a current message msg = msg + 'To change a message:' + new_line; msg = msg + 'Type /sschangeX then the new message' + new_line; msg = msg + 'where X is the message number. e.g. /sschange1New Message 1' + new_line + help_sep + new_line; msg = msg + '******** END OF COMMAND LIST *********'; //send message list to user cb.sendNotice(msg, user,'','#000000','bolder'); } function ShowNotices(user) { //Show the list of current notices //user = user requesting the function var blank_msg = ''; var new_line = '\n'; var msg = '** LIST FOR BROADCASTER EYES ONLY **\n'; var msgnum =1; //counter for loop, starts at 1, 0 is a dummy while (msgnum < notice.length) { //loop through messages if (notice[msgnum] == '') { //Show Warning blank_msg = ' is BLANK'; } //Assign the message and add a new line msg = msg + notice[msgnum] + ' (Notice No. ' + msgnum + blank_msg + ')' + new_line; blank_msg = ''; //Increment the counter ready for the next message msgnum++; } msg = msg + '*********** LIST END ************'; //send message list to user cb.sendNotice(msg, user,notice_back,notice_colour,'bolder'); } function ChangeNotice(user, strMsg) { //Change a notice text //user = user requesting the function //msg = the message as passed into the cb.onmessage function var blank_msg = ''; var new_line = '\n'; var user_notice = '** FOR BROADCASTER EYES ONLY **\n'; user_notice = user_notice + '** Message Change Request **\n'; var msg_back_colour = '#000000'; var msg_colour = '#FFFFFF'; var msg_num = -1; //Message number to change //Extract the Message number (format is /sschangeXnew text) where X is the message number msg_num = strMsg.charAt(9); //Check it is numeric between 1 and 6 inclusive if (isNaN(msg_num)) { //Not a number user_notice = user_notice + '** CHARACTER AFTER /sschange IS NOT NUMERIC **\n'; user_notice = user_notice + '** Message NOT Changed **\n'; } else { //Check is in the range 1-6 if (msg_num < 1) { //Out of range user_notice = user_notice + '** Number Must Be In Range 1-6 **\n'; user_notice = user_notice + '** Message NOT Changed **\n'; } else { //Number in range, change message and inform user notice[msg_num] = strMsg.substring(10); cb['settings'].notice1 = notice[msg_num]; user_notice = user_notice + '** Message Number ' + msg_num + ' Is Now **\n'; user_notice = user_notice + notice[msg_num] + new_line; } } //Close broadcaster message user_notice = user_notice + '** End Message Change Request **'; //send message to user cb.sendNotice(user_notice, user,msg_back_colour,msg_colour,'bolder'); } function chatAd() { //Fires each time the notice timer expires var msg;//Holds the message to be sent to the room while (notice[i] == '') { //skip empty messages i++;//Move on to try the next message if (i > 6) { //loop back to first message i=1; } } //Assign the message msg = notice[i]; //Increment the counter ready for the next message i++; if (i > 6) { //loop back to first message i=1; } cb.sendNotice(msg,'',notice_back,notice_colour,'bolder');//Send notice to room cb.setTimeout(chatAd, notice_interval);//Reset timer } function LoadSettings() { //Load CB settings into local variables //************* NOTIFIER FUNCTION SETTINGS ******************* //Assign notices to the array notice[0] = '';//dummy for loops notice[1] = cb['settings'].notice1; notice[2] = cb['settings'].notice2; notice[3] = cb['settings'].notice3; notice[4] = cb['settings'].notice4; notice[5] = cb['settings'].notice5; notice[6] = cb['settings'].notice6; notice_colour = cb['settings'].notice_colour; //Assign the HTML colour code to the notice_colour variables //Dark Red = 9F000F //Dark Blue = #0B0B61 //Orange = #FE9A2E //Black = #000000 switch(notice_colour) { case 'Dark Red': notice_colour = '#9F000F' notice_back = '#FFFFFF' break; case 'Dark Blue': notice_colour = '#0B0B61' notice_back = '#FFFFFF' break; case 'Orange': notice_colour = '#FFFFFF' notice_back = '#F97C08' break; case 'Black': notice_colour = '#000000' notice_back = '#FFFFFF' break; default: notice_colour = '#9F000F' } //Assign the interval //notice_seconds = 10;//DEBUG ONLY !!! notice_interval = cb['settings'].notice_interval * notice_seconds * 1000; //************* GRAPHICS FUNCTION SETTINGS ******************* //Assign the numeric graphic level setting /* switch(cb['settings'].graphic_level) { case 'All can use Graphics': graphic_level = 0 break; case 'Light Blue and above': graphic_level = 1 break; case 'Dark Blue and above': graphic_level = 2 break; case 'Purple and above': graphic_level = 3 break; default: graphic_level = 1 } */ } function init() { //Initialise Function //Call the helper function to load in the user settings from CB LoadSettings(); //Initialise the timer cb.setTimeout(chatAd, notice_interval); //Send notice to room var msg = '--- Snowshoe bot ' + prog_version + ' by davey4you has started ---'; cb.sendNotice(msg); //Send notice to Broadcaster msg = '** Message For Broadcaster Only **'; //msg = msg + '\nGraphic Level Set To - ' + cb['settings'].graphic_level + ' (' + graphic_level + ')'; msg = msg + '\nType /sshelp for a list of commands'; msg = msg + '\n**** Messages End ****'; cb.sendNotice(msg,cb.room_slug,'','','bold'); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.