Bots Home
|
Create an App
TagHag
Author:
dickavatar
Description
Source Code
Launch Bot
Current Users
Created by:
Dickavatar
/* * Copyright 2019 Dick Avatar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Change Log * * 1.0.0 * - Initial release. */ const VERSION = '1.0.0-RC1' const broadcaster = cb.room_slug // Configuration options when the bot is started cb.settings_choices = [ {name:'item0', type:'str', label:'Subject 1', required:false, defaultValue:'cute sexy young'}, {name:'item1', type:'str', label:'Subject 2', required:false, defaultValue:'Make me wet with your tip -- lovense omibod'}, {name:'item2', type:'str', label:'Subject 3', required:false, defaultValue:'Help me cum --'}, {name:'item3', type:'str', label:'Subject 4', required:false, defaultValue:''}, {name:'item4', type:'str', label:'Subject 5', required:false, defaultValue:''}, {name:'item5', type:'str', label:'Subject 6', required:false, defaultValue:''}, {name:'item6', type:'str', label:'Subject 7', required:false, defaultValue:''}, {name:'item7', type:'str', label:'Subject 8', required:false, defaultValue:''}, {name:'item8', type:'str', label:'Subject 9', required:false, defaultValue:''}, {name:'item9', type:'str', label:'Subject 10', required:false, defaultValue:''}, ] const NUM_LINES = 10 let lines = [] function hash(s) { if (s.length === 0) { return s } return s.split(' ').map(x => '#' + x).join(' ') } function init() { for (let i = 0; i < NUM_LINES; ++i) { let line = cb.settings['item' + i] if (line != null && line.length > 0) { let subject = '' let dashes = line.indexOf('--') if (dashes === -1) { subject = hash(line) } else { let prefix = line.substring(0, dashes) let suffix = hash(line.substring(dashes+3)) subject = `${prefix} ${suffix}` } cb.log(`Subject line ${i}: ${subject}`) lines.push(subject) } else { cb.log("Pusing empty line at index " + i) lines.push('') } } } function list() { let listing = 'Subject lines' for (let i = 0; i < lines.length; ++i) { if (lines[i].length > 0) { let j = i + 1 listing += `\n${i+1}: ${lines[i]}` } } notify(broadcaster, listing) } const _onMessage = function(message) { let user = message['user'] if (user !== broadcaster) { return message } let msg = message['m'] if (!msg.startsWith('/tags')) { return message } message['X-Spam'] = true if (msg === '/tags') { list() return message } let arg = msg.substring(6) let n = parseInt(arg) if (isNaN(n)) { notify(broadcaster, `Invalid subject number: ${arg}`) } else if (n < 1 || n > lines.length) { notify(broadcaster, 'The subject number must be between 1 and 10') } else { let subject = lines[n-1] if (subject == null || subject.length === 0) { notify(broadcaster, `No subject line defined in slot ${arg}`) } else { cb.changeRoomSubject(subject) } } return message } cb.onMessage(_onMessage) // Send a notification to a specific user. function notify(user, message) { cb.sendNotice('[TagHag] ' + message, user) } init()
© Copyright Chaturbate 2011- 2024. All Rights Reserved.