Bots Home
|
Create an App
Seth's App
Author:
silentseth
Description
Source Code
Launch Bot
Current Users
Created by:
Silentseth
var notifications = []; var notification_index = -1; var notification_timeout_id; cb.settings_choices = [ { name: 'notification1', type: 'str', label: 'Rotating Notification 1', required: false }, { name: 'notification2', type: 'str', label: 'Rotating Notification 2', required: false }, { name: 'notification3', type: 'str', label: 'Rotating Notification 3', required: false }, { name: 'notification4', type: 'str', label: 'Rotating Notification 4', required: false }, { name: 'notification5', type: 'str', label: 'Rotating Notification 5', required: false }, { name: 'auto_run_notifications', type: 'choice', choice1: 'Yes', choice2: 'No', label: 'Auto-run notifications', defaultValue:'Yes' }, { name: 'notification_interval', type: 'int', minValue: 1, maxValue: 99, label: 'Minutes between notifications', defaultValue: 4 } ]; if (cb.settings.notification1 != '') notifications.push(cb.settings.notification1); if (cb.settings.notification2 != '') notifications.push(cb.settings.notification2); if (cb.settings.notification3 != '') notifications.push(cb.settings.notification3); if (cb.settings.notification4 != '') notifications.push(cb.settings.notification4); if (cb.settings.notification5 != '') notifications.push(cb.settings.notification5); if (cb.settings.auto_run_notifications=='Yes') startNotifications(); cb.onMessage(function (msg) { var message = msg['m']; if (message.startsWith('/')){ var separator_index = message.indexOf(' '); var value = ''; if (separator_index >= 0) { var command = message.substring(1, separator_index); var value = message.substring(separator_index + 1); }else { var command = message.substring(1); } if (msg['user'] == cb.room_slug) { handleOwnerCommand(command, value); }else{ handleUserCommand(command, value); } msg['X-Spam'] = true; } return msg; }); function handleOwnerCommand(command, value){ switch(command){ case 'setSubject': cb.changeRoomSubject(value); break; case 'startNotifications': startNotifications(); break; case 'stopNotifications': stopNotifications(); break; } } function handleUserCommand(command, value){ } function startNotifications() { stopNotifications(); displayNextNotification(); sendNoticeToOwner('Notifications successfully started'); } function stopNotifications(){ if(notification_timeout_id == null) { sendNoticeToOwner('No pending notifications to stop'); }else { cb.cancelTimeout(notification_timeout_id); notification_timeout_id = null; sendNoticeToOwner('Notifications successfully stopped'); } } function sendNoticeToOwner(message) { cb.sendNotice(message + ' (only you can see this message)', cb.room_slug); } function displayNextNotification() { if (notifications.length > 0) { if (notification_index == notifications.length-1) { notification_index = 0; }else { notification_index++; } cb.chatNotice(notifications[notification_index]); } notification_timeout_id = cb.setTimeout(displayNextNotification, cb.settings.notification_interval*60000); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.