Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. registerPlugin({
  2. name: 'KLT Back to Default Channel',
  3. version: '1.0.0',
  4. description: 'Moves Client back to Default Channel if ClientCount 1',
  5. author: 'Klaus Thieme <kl_aus@msn.com>',
  6. engine: '>= 0.9.18',
  7. vars: [
  8. {
  9. name: 'idleChannel',
  10. title: 'Select your desired Idle Channel',
  11. type: 'channel'
  12. }
  13. ]
  14. }, function (sinusbot, config, info) {
  15.  
  16. var channel = require('channel');
  17. var engine = require('engine');
  18. var backend = require('backend');
  19.  
  20. if (typeof engine == 'undefined') {
  21. sinusbot.log('[ERROR] New Engine needed to run this Plugin!');
  22. return;
  23. }
  24.  
  25. // check if IdleChannel is not set
  26. if (config.idleChannel == null) {
  27. sinusbot.log('[ERROR] Please set IdleChannel');
  28. return;
  29. }
  30.  
  31. // get Channel Objects
  32. var currentChannel = backend.getCurrentChannel();
  33. var curChanId = currentChannel.id();
  34. var idleChannel = backend.getChannelByID(config.idleChannel);
  35. var botClient = backend.getBotClient();
  36. // var currentChannelObj = JSON.stringify(currentChannel);
  37. // var idleChannelObj = JSON.stringify(idleChannel);
  38. // var infoObj = JSON.stringify(info);
  39. // var configObj = JSON.stringify(config);
  40. // var sinusbotObj = JSON.stringify(sinusbot);
  41.  
  42. // OBJECT INFO
  43. // sinusbot.log('[DEBUG] infoObj "' + infoObj);
  44. // sinusbot.log('[DEBUG] configObj: "' + configObj);
  45. // sinusbot.log('[DEBUG] sinusbotObj: "' + sinusbotObj);
  46.  
  47. // CHANNEL INFO
  48. if (typeof currentChannel == 'undefined') {
  49. sinusbot.log('[ERROR] Current Channel is undef');
  50. }
  51. sinusbot.log('[DEBUG] CurrentChannel: "' + currentChannel + '(ID: ' + curChanId + ')');
  52. // sinusbot.log('[DEBUG] CurrentChannelObj: "' + currentChannelObj);
  53. // sinusbot.log('[DEBUG] IdleChannel: "' + idleChannel + '" (ID: ' + config.idleChannel + ' / ' + idleChannel.id() +')');
  54. // sinusbot.log('[DEBUG] IdleChannelObj: "' + idleChannelObj);
  55. sinusbot.log('[DEBUG] ClientCount: ' + currentChannel.getClientCount());
  56.  
  57. if((currentChannel.getClientCount() <= 1) && (currentChannel.id() != config.idleChannel)) {
  58. sinusbot.log('[DEBUG] Bot Client is alone');
  59. botClient.moveTo(IdleChannel);
  60. return;
  61. } else {
  62. sinusbot.log('[DEBUG] Bot Client is not alone');
  63. return;
  64. }
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement