Bots Home
|
Create an App
prjWRX2
Author:
cerebio
Description
Source Code
Launch Bot
Current Users
Created by:
Cerebio
// -------------------------------------------------------------------- // Name : WildBot // Author : cerebio // Version: 0.1 // When : 2016/10/05 - 2016/10/07 // -------------------------------------------------------------------- cb.settings_choices = [{ name: 'members', label: 'Wild Demons (Format: name nickname, name nickname)', type: 'str', minLength: 1, maxLength: 2048, required: false }, { name: 'points', label: 'Wild Points (Format: name points, name points)', type: 'str', minLength: 1, maxLength: 2048, required: false }, { name: 'highlightBG', label: 'Choose a default highlight background colour (HTML coded, for example #FFFF99). Use "#FFFFFF" for no highlight.', type: 'str', minLength: 4, maxLength: 7, required: true }, { name: 'highlightFG', label: 'Provide a default highlight text colour (HTML coded, for example #009933). Use "#000000" for no highlight.', type: 'str', minLength: 4, maxLength: 7, required: true }, { name: 'notifier1text', label: 'Provide a notifier text (leaving it empty will keep the notfier disabled)', type: 'str', minLength: 1, maxLength: 2048, required: false }, { name: 'notifier1timer', label: 'Provide a notifier interval (ms) - min. 5000, max. 300000', type: 'int', minValue: 5000, // 5 sec maxValue: 300000, // 5 min defaultValue: 30000, // 30 seconds required: false } , { name: 'notifier2text', label: 'Provide a notifier text (leaving it empty will keep the notfier disabled)', type: 'str', minLength: 1, maxLength: 2048, required: false }, { name: 'notifier2timer', label: 'Provide a notifier interval (ms) - min. 5000, max. 300000', type: 'int', minValue: 5000, // 5 sec maxValue: 300000, // 5 min defaultValue: 30000, // 30 seconds required: false }, { name: 'notifier3text', label: 'Provide a notifier text (leaving it empty will keep the notfier disabled)', type: 'str', minLength: 1, maxLength: 2048, required: false }, { name: 'notifier3timer', label: 'Provide a notifier interval (ms) - min. 5000, max. 300000', type: 'int', minValue: 5000, // 5 sec maxValue: 300000, // 5 min defaultValue: 30000, // 30 seconds required: false } ]; function memberExists( name ) { var found = false; for ( var i in memberList ) { if( name == memberList[i].name ) { found = true; break; } } return found; } function Member( name, nickname, points ) { this.name = name; this.nickname = nickname; this.points = points; } var memberList = new Object; function parseParameters() { var members = cb.settings.members.split( "," ); var memberPoints = cb.settings.points.split( "," ); for ( var i = 0; i != members.length; ++i ) { var fields = members[i].trim().split( " " ); var points = memberPoints[i].trim().split( " " ); var name = fields[0].trim(); if ( name != points[0].trim()) { cb.sendNotice( "Please check you configuration! Make sure members and points have the same people in the same order", cb.room_slug, "#FF0000", "#FFFFFF", "bold" ); } var nickname = ""; for ( var i2 = 1; i2 != fields.length; ++i2 ) { nickname += fields[i2].trim() + " "; } var member = new Member( name, nickname.trim(), points[1].trim()); cb.sendNotice( "Added wild demon [" + name + "] " + "(" + member.nickname + ") - " + member.points, cb.room_slug, cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); memberList[name] = member; } } var initialised = false; function initialise() { cb.sendNotice( "WildBot: Initialising", cb.room_slug, cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); if ( !initialised ) { initialised = true; parseParameters(); if ( "" != cb.settings.notifier1text ) { cb.setTimeout( notify1, 0 ); } if ( "" != cb.settings.notifier2text ) { cb.setTimeout( notify2, 5000 ); } if ( "" != cb.settings.notifier3text ) { cb.setTimeout( notify3, 10000 ); } cb.sendNotice( "WildBot: initialised", "", cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); } else { cb.sendNotice( "WildBot: already initialised", cb.room_slug, cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); } } cb.setTimeout( initialise, 0 ); function notify1() { cb.chatNotice( cb.settings.notifier1text, "", cb.settings.highlightBG, cb.settings.highlightFG ); cb.setTimeout( notify1, cb.settings.notifier1timer ); } function notify2() { cb.chatNotice( cb.settings.notifier2text, "", cb.settings.highlightBG, cb.settings.highlightFG ); cb.setTimeout( notify2, cb.settings.notifier2timer ); } function notify3() { cb.chatNotice( cb.settings.notifier3text, "", cb.settings.highlightBG, cb.settings.highlightFG ); cb.setTimeout( notify3, cb.settings.notifier3timer ); } cb.onMessage( function( msg ) { var user = msg['user']; var message = msg['m']; if ( '/settings' == message && ( 'cerebio' == user || true == msg['is_mod'] )) { cb.sendNotice( cb.settings.members, user ); cb.sendNotice( cb.settings.points, user ); cb.sendNotice( cb.settings.highlightBG, user ); cb.sendNotice( cb.settings.highlightFG, user ); msg['X-Spam'] = true; } else if ( memberExists( user )) { msg['background'] = cb.settings.highlightBG; msg['foreground'] = cb.settings.highlightFG; if ( '/points' == message ) { cb.sendNotice( "You currently have " + memberList[user].points + " Wild Points", user, cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); msg['X-Spam'] = true; } else { message = ':wrx-demon (' + memberList[user].nickname + ') ' + message; } } else if ( cb.room_slug == user ) { message = ':wrx-angel ' + message; } msg['m'] = message; return msg; }); cb.onEnter( function( user ) { var username = user["user"]; if ( memberExists( username )) { cb.chatNotice( "Wild Demon " + username + " has entered the Wilderness.", "", cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); cb.chatNotice( "Welcome " + username + " <3", username, cb.settings.highlightBG, cb.settings.highlightFG, "bold" ); cb.chatNotice( "type /points in chat to see how many Wild Points you've earned.", username, cb.settings.highlightBG, cb.settings.highlightFG ); } });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.