Bots Home
|
Create an App
snoke's room bot
Author:
leadersnoke
Description
Source Code
Launch Bot
Current Users
Created by:
Leadersnoke
// *------------------------------------ // * App name: Snoke's Room Control Bot (using nested functions - "closures") // * Author: Snoke (cb handle sn0ke) // * Version: 0.1 // * Date created: 1 December 2016 // * Date modified: 1 December 2016 // *------------------------------------ // * Notes: // * 1. This bot uses code from other apps & bots. Credits to their respective authors. String.prototype.equals = function (str) { var match = new RegExp(str, "g"); return this.match(match) !== null; }; String.prototype.equalsIgnoreCase = function (str) { var match = new RegExp(str, "gi"); return this.match(match) !== null; }; String.prototype.isBlank = function() { return this.charAt(0) == "" || this.charAt(0) == "\xA0"; }; function Scb() { // app info const APP_NAME = "Snoke's Room Control Bot", VERSION = "0.1", AUTHOR = "Sn0ke", DATE_CREATED = "2016.12.01", DATE_MODIFIED = "2016.12.01"; // other constants const DASHLINE = new Array(36).join("\u2014"), DASHLINE2 = DASHLINE + "\n", CASTER = cb.room_slug; function sendToCaster (msg, color, background) { if (!msg.isBlank()) cb.sendNotice(msg, CASTER, background, color, "bold"); else sendError("You cannot send a blank message. Mind typing something?", CASTER); } function sendError (user, msg) { cb.sendNotice("\u25c6 " + msg, user, "#b44", "#fff", "bold"); } // this is the very first function to be called; it'll also be called if the bot is reset via /resetbot (force) this.main = function() { sendToCaster(DASHLINE2 + "\u25c6 Starting " + APP_NAME + "...\n" + "\u25c6 Version: " + VERSION + "\n" + "\u25c6 Last modified on: " + DATE_MODIFIED + "\n\n" + "\u25c6 Type /scb or !scb for help.\n" + DASHLINE, "#fff", "#8ba"); } } cb.onMessage(function(msg) { var msgText = msg.m, msgColor = msg.c, msgFont = msg.f, msgHidden = msg["X-SPAM"], user = msg.user; if (msgHidden === undefined) { msgHidden = false; } msg.isCommand = function() { const COMMAND_REGEXP = /^\!|\//gi; return COMMAND_REGEXP.test(msgText); } if (msg.isCommand()) { msgHidden = true; var command = msgText.split(" ")[0].slice(1); function isRestrictedCmd (command) { return; } } cb.log("Message: " + msgText + "Is command: " + msg.isCommand() + "Is hidden: " + msgHidden + "Sent by: " + user); return msg; }); var scb = new Scb(); scb.main();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.