Advertisement
Guest User

ZTSupport

a guest
Feb 25th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. //
  2. //Copyright (C) 2015 Zento <zento@own-salvation.de>
  3. //
  4. //This program is free software: you can redistribute it and/or modify
  5. //it under the terms of the GNU General Public License as published by
  6. //the Free Software Foundation, either version 3 of the License, or
  7. //(at your option) any later version.
  8. //*
  9. //This program is distributed in the hope that it will be useful,
  10. //but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. //GNU General Public License for more details.
  13. //
  14. //You should have received a copy of the GNU General Public License
  15. //along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. //
  17. //Author of Script: Zento <zento@own-salvation.de>
  18. //
  19. registerPlugin(
  20. {
  21. name: 'ZTSupport',
  22. version: '0.9.4',
  23. description: 'Message to ServerGroup when User joins specified Channel',
  24. author: 'Zento',
  25. vars: {
  26. ZTchannelID: { title: 'Supportchannel', type: 'channel' },
  27. ZTgrpID: { title: 'Supporter - GroupID - Comma seperated list', type: 'string' },
  28. ZTIgnoreGrpID: { title: 'Ignore when joining Support Channel - GroupID - Comma seperated list', type: 'string' },
  29. ZTUserMessage: {title: "Message to user - %u for Username", type: 'string', placeholder: "Hello %u! A Supporter will hellp you soon!"},
  30. ZTSupporterMessage: {title: "Message to supporter - %u for Username", type: 'string', placeholder: "User %u has joined the support waitingroom!"},
  31. ZTmsgType: {title: "Supporter message type", type: 'select', options: ['Chat','Poke']}
  32. }
  33. },
  34. function(sinusbot, config, info)
  35. {
  36. sinusbot.log('Loading ' + info.name + ' v' + info.version + ' - by ' + info.author);
  37. sinusbot.log('Settings:');
  38. sinusbot.log('Support ChannelID: ' + config.ZTchannelID);
  39. sinusbot.log('Support GroupID:' + config.ZTgrpID);
  40. sinusbot.log('GroupIDs to ignore:' + config.ZTIgnoreGrpID);
  41.  
  42.  
  43. var ZTIgnoreGrpID = config.ZTIgnoreGrpID.split(',');
  44. var ZTUserMessage = config.ZTUserMessage.split('%u');
  45. var ZTSupporterMessage = config.ZTSupporterMessage.split('%u');
  46.  
  47. sinusbot.setVar(config.ZTSupporter, []);
  48.  
  49. var ZTgrpID = config.ZTgrpID.split(',');
  50.  
  51. sinusbot.on('clientMove', function(e)
  52. {
  53.  
  54. var ZTisSupporter = false;
  55. e.clientServerGroups.forEach(function(group)
  56. {
  57. ZTgrpID.forEach(function(group2)
  58. {
  59. if (group.i == group2)
  60. ZTisSupporter = true;
  61. });
  62. });
  63. ZTSupporter = sinusbot.getVar(config.ZTSupporter);
  64. if (ZTisSupporter == true)
  65. {
  66. if (e.newChannel == 0)
  67. {
  68. var ZTSupporter_new = [];
  69. ZTSupporter.forEach(function(id)
  70. {
  71. if (id != e.clientId)
  72. {
  73. ZTSupporter_new.push(id);
  74. }
  75. });
  76. sinusbot.setVar(config.ZTSupporter, ZTSupporter_new);
  77. }
  78. else if (ZTSupporter.indexOf(e.clientId) == -1)
  79. {
  80. ZTSupporter.push(e.clientId);
  81. sinusbot.setVar(config.ZTSupporter, ZTSupporter);
  82. }
  83. }
  84. else if(ZTSupporter.indexOf(e.clientId) >= 0)
  85. {
  86. var ZTSupporter_new = [];
  87. ZTSupporter.forEach(function(id)
  88. {
  89. if (id != e.clientId)
  90. {
  91. ZTSupporter_new.push(id);
  92. }
  93. });
  94. sinusbot.setVar(config.ZTSupporter, ZTSupporter_new);
  95. }
  96.  
  97.  
  98. var ignore = false;
  99. ZTIgnoreGrpID.forEach(function(key,i ,o)
  100. {
  101. e.clientServerGroups.forEach(function(group)
  102. {
  103. if (group.i == key)
  104. ignore = true;
  105. });
  106. });
  107. if (e.newChannel == config.ZTchannelID && ignore == false)
  108. {
  109. if (ZTUserMessage.length == 2)
  110. ZTUserMessage_temp = ZTUserMessage[0] + '[b]' + e.clientNick + '[/b]' + ZTUserMessage[1];
  111. else
  112. ZTUserMessage_temp = ZTUserMessage[0];
  113.  
  114. if (ZTSupporterMessage.length == 2)
  115. ZTSupporterMessage_temp = ZTSupporterMessage[0] + '[b]' + e.clientNick + '[/b]' + ZTSupporterMessage[1];
  116. else
  117. ZTSupporterMessage_temp = ZTSupporterMessage[0];
  118. sinusbot.getVar(config.ZTSupporter).forEach(function(ZTClientID)
  119. {
  120. if (config.ZTmsgType == 0)
  121. chatPrivate(ZTClientID, ZTSupporterMessage_temp);
  122. else if (config.ZTmsgType == 1)
  123. poke(ZTClientID, ZTSupporterMessage_temp);
  124. else
  125. chatPrivate(ZTClientID, ZTSupporterMessage_temp);
  126. });
  127. chatPrivate(e.clientId, ZTUserMessage_temp);
  128. }
  129. });
  130. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement