Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registerPlugin({
- name: 'KLT Back to Default Channel',
- version: '1.0.0',
- description: 'Moves Client back to Default Channel if ClientCount 1',
- author: 'Klaus Thieme <kl_aus@msn.com>',
- engine: '>= 0.9.18',
- vars: [
- {
- name: 'idleChannel',
- title: 'Select your desired Idle Channel',
- type: 'channel'
- }
- ]
- }, function (sinusbot, config, info) {
- var channel = require('channel');
- var engine = require('engine');
- var backend = require('backend');
- if (typeof engine == 'undefined') {
- sinusbot.log('[ERROR] New Engine needed to run this Plugin!');
- return;
- }
- // check if IdleChannel is not set
- if (config.idleChannel == null) {
- sinusbot.log('[ERROR] Please set IdleChannel');
- return;
- }
- // get Channel Objects
- var currentChannel = backend.getCurrentChannel();
- var curChanId = currentChannel.id();
- var idleChannel = backend.getChannelByID(config.idleChannel);
- var botClient = backend.getBotClient();
- // var currentChannelObj = JSON.stringify(currentChannel);
- // var idleChannelObj = JSON.stringify(idleChannel);
- // var infoObj = JSON.stringify(info);
- // var configObj = JSON.stringify(config);
- // var sinusbotObj = JSON.stringify(sinusbot);
- // OBJECT INFO
- // sinusbot.log('[DEBUG] infoObj "' + infoObj);
- // sinusbot.log('[DEBUG] configObj: "' + configObj);
- // sinusbot.log('[DEBUG] sinusbotObj: "' + sinusbotObj);
- // CHANNEL INFO
- if (typeof currentChannel == 'undefined') {
- sinusbot.log('[ERROR] Current Channel is undef');
- }
- sinusbot.log('[DEBUG] CurrentChannel: "' + currentChannel + '(ID: ' + curChanId + ')');
- // sinusbot.log('[DEBUG] CurrentChannelObj: "' + currentChannelObj);
- // sinusbot.log('[DEBUG] IdleChannel: "' + idleChannel + '" (ID: ' + config.idleChannel + ' / ' + idleChannel.id() +')');
- // sinusbot.log('[DEBUG] IdleChannelObj: "' + idleChannelObj);
- sinusbot.log('[DEBUG] ClientCount: ' + currentChannel.getClientCount());
- if((currentChannel.getClientCount() <= 1) && (currentChannel.id() != config.idleChannel)) {
- sinusbot.log('[DEBUG] Bot Client is alone');
- botClient.moveTo(IdleChannel);
- return;
- } else {
- sinusbot.log('[DEBUG] Bot Client is not alone');
- return;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement