Bots Home
|
Create an App
M8Bot
Author:
mentaltest
Description
Source Code
Launch Bot
Current Users
Created by:
Mentaltest
/* Magic 8 Ball Bot by MentalCex (The Orgasm Control Wizard) Tested: 100% fully functional Last Update: 11/19/18 1:07 pm Uses the 20 most common magic 8 ball phrases Users type: /8ball when tip amount is empty When tip amount is not empty, bot only responds to exact token amount If advertisement minutes left empty, but will not advertise --advertisement says "The Magic 8 Ball Bot is Active!: type: /8ball <question?>" every (n) minutes --advertise with tips says "The Magic 8 Ball Bot is Active! - Tip: <amount> tokens and ask a question in the tip note for a response!" every (n) minutes If Display Tip Notes set to Yes, the bot will advertise the question and answer for each eaxct tip amount If the tip note was left blank, the bot will still thank the user for their tip! v1.1 it works v1.1.2 fixed a bug in random resulted in "" v1.1.3 removed unused item and made it so bot advertises once even if in advert "quiet" mode v1.2 option to show tip note "questions" publicly. updated output strings. improved error checking and handling. v1.3 optimized code. optimized outputs. made them seem intelligent. now always free for broadcaster. that's a wrap -- or was it? **************************************************************** DM me on Twitter with issues: @CexMental */ cb.settings_choices = []; //functionality settings cb.settings_choices.push({"name": "ColorFG", "type": "str", "required": false, "minLength": 0, "maxLength": 7, "defaultValue": "#C0C0C0", "label": "Text Highlight Color"} , {"name": "ColorBG", "type": "str", "required": false, "minLength": 0, "maxLength": 7, "defaultValue": "#000000", "label": "Text Background Color"} , {"name": "AdvertDelay", "type": "int", "required": false, "minValue": "1", "defaultValue": "", "label": "Advertisement Delay (minutes)"} , {"name": "ShowTipNote", "type": "choice", "choice1": "Yes", "choice2": "No", "defaultValue": "Yes", "label": "Display Tip Notes"} , {"name": "TipAmount", "type": "int", "required": false, "minValue": "1", "defaultValue": "", "label": "Respond only to this tip amount"}); //standard 8ball messages as listed by https://en.wikipedia.org/wiki/Magic_8-Ball#Possible_answers msgBot = ["It is certain.", "It is decidedly so.", "Without a doubt.", "Better not tell you now.", "Yes - definitely.", "You may rely on it.", "Reply hazy, try again.", "Cannot predict now.", "My sources say no.", "Outlook good.", "Signs point to yes.", "My reply is no.", "Most likely.", "Concentrate and ask again.", "Very doubtful.", "Outlook not so good.", "Yes.", "Ask again later.", "Don't count on it.", "As I see it, yes."]; var msgBotIndex = ""; function onMessageHandler(msg) { var inMSG = msg['m']; var fBall = inMSG.slice(0, 6); if (fBall.toLowerCase() == '/8ball' && (!cb.settings['TipAmount'] || msg['user'] == cb.room_slug)) { //hint -- (min * max) returns 0:19 msgBotIndex = Math.floor(Math.random() * 20); cb.sendNotice('The Magic 8 Ball says.. ' + msgBot[msgBotIndex], '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else if (fBall.toLowerCase() == '/8ball' && cb.settings['TipAmount'] > 0) { if (cb.settings['TipAmount'] == "1") { cb.sendNotice('The Magic 8 Ball Bot currently cost ' + cb.settings['TipAmount'] + ' token for a response!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else { cb.sendNotice('The Magic 8 Ball Bot currently cost ' + cb.settings['TipAmount'] + ' tokens for a response!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } } } cb.onTip(function(tip) { if (parseInt(tip['amount']) == parseInt(cb.settings['TipAmount'])) { msgBotIndex = Math.floor(Math.random() * 20); if (cb.settings['ShowTipNote'] == "No") { cb.sendNotice('The Magic 8 Ball says.. ' + msgBot[msgBotIndex], '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else if (cb.settings['ShowTipNote'] == "Yes") { var tipMsg = tip['message']; var tipMsgTrim = tipMsg.trim(); if (tipMsgTrim == "" || tipMsgTrim.length < 2) { cb.sendNotice('The Magic 8 Ball was asked.. hmm you forgot to ask me something ' + tip['from_user'] + '. Thanks for that tip, though!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else { if (tipMsgTrim.endsWith("?") == false) { tipMsgTrim += '?' } setTimeout(function() { cb.sendNotice('The Magic 8 Ball was asked.. ' + tipMsgTrim, '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); }, 100); setTimeout(function() { cb.sendNotice('The Magic 8 Ball says.. ' + msgBot[msgBotIndex], '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); }, 150); } } } }); function advertise() { if (cb.settings['AdvertDelay'] > 0 && !cb.settings['TipAmount']) { cb.sendNotice('The Magic 8 Ball Bot is Active!: type: /8ball <question?>', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); cb.setTimeout(advertise, (cb.settings['AdvertDelay'] * 60000)); } else if (cb.settings['AdvertDelay'] > 0 && cb.settings['TipAmount'] > 0) { if (cb.settings['TipAmount'] == '1') { cb.sendNotice('The Magic 8 Ball Bot is Active! - Tip: ' + cb.settings['TipAmount'] + ' token and ask a question in the tip note for a response!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else { cb.sendNotice('The Magic 8 Ball Bot is Active! - Tip: ' + cb.settings['TipAmount'] + ' tokens and ask a question in the tip note for a response!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } cb.setTimeout(advertise, (cb.settings['AdvertDelay'] * 60000)); } else if (!cb.settings['AdvertDelay'] && !cb.settings['TipAmount']) { cb.sendNotice('The Magic 8 Ball Bot is Active!: type: /8ball <question?>', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else if (!cb.settings['AdvertDelay'] && cb.settings['TipAmount'] > 0) { if (cb.settings['TipAmount'] == '1') { cb.sendNotice('The Magic 8 Ball Bot is Active! - Tip: ' + cb.settings['TipAmount'] + ' token and ask a question in the tip note for a response!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } else { cb.sendNotice('The Magic 8 Ball Bot is Active! - Tip: ' + cb.settings['TipAmount'] + ' tokens and ask a question in the tip note for a response!', '', cb.settings['ColorBG'], cb.settings['ColorFG'], 'bold'); } } } function init() { //start handerler for /tipmenu cb.onMessage(onMessageHandler); //advertise bot 1st time cb.setTimeout(advertise, (1 * 1000)); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.