Advertisement
dadragon84

chaturbate bot

Apr 29th, 2015
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. // No anonymous viewers bot
  2. // Author: Severino
  3.  
  4. var noAnon = {
  5. // Commands the room owner and moderators can use
  6. startShowCommand: '/startshow',
  7. stopShowCommand: '/stopshow',
  8.  
  9. // Commands that everyone can use
  10. helpCommand: '/help',
  11.  
  12. // Useful globals
  13. wordBoundary: "(\\s|\\b)",
  14.  
  15. showStarted: false,
  16. showmessage: 'Anonymous viewers blocked, log in to view cam.'
  17. }
  18. ;
  19.  
  20. // CB app settings
  21. cb.settings_choices = [
  22. {name: 'showmessage', label: 'Message for blocked users', type: 'str', minLength: 1, maxLength: 99, required: true, defaultValue: 'Anonymous viewers blocked, log in to view cam.'}
  23. ];
  24.  
  25. noAnon.usage = function (msg) {
  26. var u = msg['user'];
  27. cb.chatNotice('Available commands:', u);
  28. if (this.canControlBot(msg)) {
  29. cb.chatNotice(this.startShowCommand + ' start blocking anonymous users', u);
  30. cb.chatNotice(this.stopShowCommand + ' stop the bot', u);
  31. }
  32. cb.chatNotice(this.helpCommand + ' - show this help message', u);
  33. };
  34.  
  35. cb.onMessage(function (msg) {
  36. return noAnon.onMessage(msg);
  37. });
  38.  
  39. cb.onEnter(function (user) {
  40. return noAnon.onEnter(user);
  41. });
  42.  
  43. cb.onTip(function (tip) {
  44. noAnon.onTip(tip);
  45. });
  46.  
  47. noAnon.isPatron = function (username) {
  48. return cb.limitCam_userHasAccess(username);
  49. };
  50.  
  51. noAnon.addPatron = function (username) {
  52. if (this.isPatron(username)) {
  53. return false;
  54. } else {
  55. cb.limitCam_addUsers([username]);
  56. return true;
  57. }
  58. };
  59.  
  60. noAnon.onTip = function (tip) {
  61. var amountTipped = parseInt(tip['amount']);
  62. var tippingUser = tip['from_user'];
  63. noAnon.addPatron(tippingUser);
  64. };
  65.  
  66. noAnon.getPatronList = function () {
  67. var userlist = cb.limitCam_allUsersWithAccess();
  68. if (userlist.length > 0) {
  69. return "" + userlist.length + (userlist.length > 1 ? " users" : " user") + " in show: " + cbjs.arrayJoin(userlist, ", ");
  70. }
  71. else {
  72. return "No users in show.";
  73. }
  74. }
  75.  
  76. // Main on message callback function
  77. noAnon.onMessage = function (msg) {
  78. // vars for ease of use
  79. var m = msg['m'];
  80. var u = msg['user'];
  81.  
  82. // check for action
  83. if (m[0] === '/') {
  84. // don't print commands
  85. msg['X-Spam'] = true;
  86.  
  87. // Remove trailing spaces
  88. m = m.replace(/\s+$/, '');
  89.  
  90. // Find command parameters
  91. var commandParts = m.split(/\s+/);
  92.  
  93. var commandName = commandParts[0];
  94. cb.log(u + ' issued command: ' + commandName);
  95.  
  96. // check if controller
  97. if (!this.canControlBot(msg)) {
  98. // Not owner
  99. noAnon.addPatron(u);
  100. }
  101. else {
  102. // Owner
  103. if (commandParts[0] === this.helpCommand) // help
  104. {
  105. this.usage(msg);
  106. }
  107. else if (commandParts[0] === this.startShowCommand) {
  108. cb.limitCam_start(noAnon.showmessage);
  109. noAnon.showStarted = true;
  110.  
  111. }
  112. else if (commandParts[0] === this.stopShowCommand) {
  113. cb.limitCam_stop();
  114. noAnon.showStarted = false;
  115. cb.chatNotice("Anonymous viewers unblocked");
  116. }
  117. }
  118. }
  119. msg['m'] = m;
  120. return msg;
  121. }
  122. ;
  123.  
  124. noAnon.onEnter = function (user) {
  125. noAnon.addPatron(user.user);
  126. }
  127.  
  128. noAnon.canControlBot = function (msg) {
  129. return (msg['user'] === cb.room_slug);
  130. };
  131.  
  132. noAnon.wrapText = function (item, pre, suf) {
  133. return pre + item + suf;
  134. };
  135.  
  136. noAnon.init = function () {
  137. cb.chatNotice('CookieCake Trap Prevents Anonymous Lurking. If you are logged in and cannot see the cam, please refresh the page');
  138. cb.chatNotice('If you are not logged in you will have to log in to see the cam.');
  139. if (cb.settings.showmessage) {
  140. noAnon.showmessage = cb.settings.showmessage;
  141. }
  142. cb.limitCam_start(noAnon.showmessage);
  143. noAnon.showStarted = true;
  144. };
  145.  
  146. noAnon.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement