Advertisement
Guest User

Untitled

a guest
May 10th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. var tmi = require('tmi.js');
  2.  
  3. const TWITTER = 'https://twitter.com/BlserfaceStream';
  4. const CHANNEL = 'evantjuh';
  5. const COMMAND_LIMITER = "!";
  6.  
  7.  
  8.  
  9. var options = {
  10.  
  11. options: {
  12. debug : true
  13. },
  14.  
  15. connection: {
  16. cluster: "aws",
  17. reconnect: true
  18. },
  19.  
  20. identity: {
  21. username: "BrutalPSBot",
  22. password : "oauth:xxx"
  23.  
  24. },
  25.  
  26. channels: ["evantjuh"]
  27. };
  28.  
  29.  
  30. var client = new tmi.client(options);
  31.  
  32. client.connect();
  33.  
  34.  
  35. client.on('chat', function(channel, user, message, self) {
  36.  
  37. msg = message.toLowerCase();
  38. cmd = '';
  39.  
  40.  
  41. if(msg.startsWith(COMMAND_LIMITER)) {
  42. if(msg.includes(" ")) {
  43.  
  44. cmd = msg.split(COMMAND_LIMITER)[1].split(" ")[0];
  45. arg = msg.split(" ")[1];
  46.  
  47.  
  48.  
  49. switch(cmd) {
  50. case "resolve":
  51. sendMessage(CHANNEL, "You are resolving: " + arg);
  52. break;
  53.  
  54. case "timeout":
  55. if(isMod(user)) {
  56.  
  57. if(!msg.split(" ")[2] || ! msg.split(" ")[3])
  58. sendMessage(CHANNEL, "You need atleast 3 parameters to time a user out! [Username, Timeout in ms, Reason]");
  59. else {
  60.  
  61. if(arg !== user['display-name']) {
  62. client.timeout(CHANNEL, arg, parseInt(msg.split(" ")[2]), msg.split(" ")[3]);
  63. sendMessage(CHANNEL, "Succesfully timed out " + arg + " for " + msg.split(" ")[3]);
  64.  
  65. }
  66. else
  67. sendMessage(CHANNEL, "You cannot time yourself out!");
  68. }
  69.  
  70. } else {
  71. sendMessage(CHANNEL, "You don't have the privileges to do that!");
  72. }
  73.  
  74. break;
  75.  
  76. case "ban":
  77.  
  78. if(isMod(user)) {
  79.  
  80. if(arg !== user['display-name']) {
  81. reason = msg.split(" ")[2];
  82.  
  83. if(!reason)
  84. sendMessage(CHANNEL, "You need atleast 2 parameters to ban a user! [Username, Reason]");
  85. else {
  86. client.ban(CHANNEL, arg, reason);
  87. sendMessage(CHANNEL, "Succesfully banned " + arg + " for " + reason);
  88. }
  89.  
  90. } else {
  91. sendMessage(CHANNEL, "You cannot ban yourself!");
  92. }
  93.  
  94. } else {
  95. sendMessage(CHANNEL, "You don't have the privileges to do that!");
  96. }
  97.  
  98. break;
  99. case "color":
  100.  
  101.  
  102. client.color(arg).then(function(data) {
  103. sendMessage(CHANNEL, "Succesfully changed your color to " + arg);
  104. }).catch(function(err) {
  105. sendMessage(CHANNEL, "Failed to change color to " + arg);
  106. sendMessage(CHANNEL, "Please choose one of the following: \n"
  107. + "Blue, BlueViolet, CadetBlue, Chocolate, Coral, DodgerBlue"
  108. + "Firebrick, GoldenRod, Green, HotPink, OrangeRed, Red"
  109. + "SeaGreen, SpringGreen, YellowGreen"
  110. + ' \nNOTE: if you are a turbo-user you can also use hexadecimal color!');
  111. });
  112.  
  113.  
  114.  
  115. default:
  116. break;
  117. }
  118.  
  119.  
  120.  
  121. } else {
  122.  
  123. cmd = msg.split(COMMAND_LIMITER)[1];
  124.  
  125. switch(cmd) {
  126. case "help":
  127. sendMessage(CHANNEL, "Commands \n Help - Shows commands.");
  128. break;
  129.  
  130. case "twitter":
  131. sendMessage(CHANNEL, TWITTER);
  132. break;
  133.  
  134. case "clear":
  135.  
  136. if(isMod(user)) {
  137.  
  138. client.clear(CHANNEL);
  139. sendMessage(CHANNEL, "Succesfully cleared the chat!");
  140.  
  141.  
  142. } else {
  143. sendMessage(CHANNEL, "You don't have the priviliges to do that!");
  144. }
  145.  
  146.  
  147. break;
  148.  
  149. case "subscribers":
  150.  
  151.  
  152. if(isMod(user)) {
  153. client.subscribers(CHANNEL);
  154. sendMessage(CHANNEL, "This channel is now in subscribers-only mode!");
  155. } else
  156. sendMessage(CHANNEL, "You don't have the priviliges to do that!");
  157.  
  158. break;
  159.  
  160. case "subscribersoff":
  161.  
  162.  
  163. if(isMod(user)) {
  164. client.subscribersoff(CHANNEL);
  165. sendMessage(CHANNEL, "This channel is now in normal mode!");
  166. } else
  167. sendMessage(CHANNEL, "You don't have the priviliges to do that!");
  168.  
  169. break;
  170.  
  171.  
  172. default:
  173. sendMessage(CHANNEL, "Invalid command.");
  174. break;
  175. }
  176. }
  177. }
  178.  
  179.  
  180. //client.action('bequiin', user['display-name'] + ' hails evantjuh.');
  181.  
  182. });
  183.  
  184.  
  185. client.on('connected', function(address, port) {
  186. sendMessage(CHANNEL, "Hello, I'm a bot created by evantjuh.");
  187. });
  188.  
  189. client.on("part", function (channel, username, self) {
  190. sendMessage(CHANNEL, user['display-name'] + ' has left the channel!');
  191. });
  192.  
  193.  
  194.  
  195. function sendMessage(channel, message) {
  196. client.action(channel, message);
  197.  
  198. }
  199.  
  200. function isMod(user) {
  201. if(user['mod'] || user['display-name'] === 'evantjuh')
  202. return true;
  203.  
  204. return false;
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement