Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tmi = require('tmi.js');
- const TWITTER = 'https://twitter.com/BlserfaceStream';
- const CHANNEL = 'evantjuh';
- const COMMAND_LIMITER = "!";
- var options = {
- options: {
- debug : true
- },
- connection: {
- cluster: "aws",
- reconnect: true
- },
- identity: {
- username: "BrutalPSBot",
- password : "oauth:xxx"
- },
- channels: ["evantjuh"]
- };
- var client = new tmi.client(options);
- client.connect();
- client.on('chat', function(channel, user, message, self) {
- msg = message.toLowerCase();
- cmd = '';
- if(msg.startsWith(COMMAND_LIMITER)) {
- if(msg.includes(" ")) {
- cmd = msg.split(COMMAND_LIMITER)[1].split(" ")[0];
- arg = msg.split(" ")[1];
- switch(cmd) {
- case "resolve":
- sendMessage(CHANNEL, "You are resolving: " + arg);
- break;
- case "timeout":
- if(isMod(user)) {
- if(!msg.split(" ")[2] || ! msg.split(" ")[3])
- sendMessage(CHANNEL, "You need atleast 3 parameters to time a user out! [Username, Timeout in ms, Reason]");
- else {
- if(arg !== user['display-name']) {
- client.timeout(CHANNEL, arg, parseInt(msg.split(" ")[2]), msg.split(" ")[3]);
- sendMessage(CHANNEL, "Succesfully timed out " + arg + " for " + msg.split(" ")[3]);
- }
- else
- sendMessage(CHANNEL, "You cannot time yourself out!");
- }
- } else {
- sendMessage(CHANNEL, "You don't have the privileges to do that!");
- }
- break;
- case "ban":
- if(isMod(user)) {
- if(arg !== user['display-name']) {
- reason = msg.split(" ")[2];
- if(!reason)
- sendMessage(CHANNEL, "You need atleast 2 parameters to ban a user! [Username, Reason]");
- else {
- client.ban(CHANNEL, arg, reason);
- sendMessage(CHANNEL, "Succesfully banned " + arg + " for " + reason);
- }
- } else {
- sendMessage(CHANNEL, "You cannot ban yourself!");
- }
- } else {
- sendMessage(CHANNEL, "You don't have the privileges to do that!");
- }
- break;
- case "color":
- client.color(arg).then(function(data) {
- sendMessage(CHANNEL, "Succesfully changed your color to " + arg);
- }).catch(function(err) {
- sendMessage(CHANNEL, "Failed to change color to " + arg);
- sendMessage(CHANNEL, "Please choose one of the following: \n"
- + "Blue, BlueViolet, CadetBlue, Chocolate, Coral, DodgerBlue"
- + "Firebrick, GoldenRod, Green, HotPink, OrangeRed, Red"
- + "SeaGreen, SpringGreen, YellowGreen"
- + ' \nNOTE: if you are a turbo-user you can also use hexadecimal color!');
- });
- default:
- break;
- }
- } else {
- cmd = msg.split(COMMAND_LIMITER)[1];
- switch(cmd) {
- case "help":
- sendMessage(CHANNEL, "Commands \n Help - Shows commands.");
- break;
- case "twitter":
- sendMessage(CHANNEL, TWITTER);
- break;
- case "clear":
- if(isMod(user)) {
- client.clear(CHANNEL);
- sendMessage(CHANNEL, "Succesfully cleared the chat!");
- } else {
- sendMessage(CHANNEL, "You don't have the priviliges to do that!");
- }
- break;
- case "subscribers":
- if(isMod(user)) {
- client.subscribers(CHANNEL);
- sendMessage(CHANNEL, "This channel is now in subscribers-only mode!");
- } else
- sendMessage(CHANNEL, "You don't have the priviliges to do that!");
- break;
- case "subscribersoff":
- if(isMod(user)) {
- client.subscribersoff(CHANNEL);
- sendMessage(CHANNEL, "This channel is now in normal mode!");
- } else
- sendMessage(CHANNEL, "You don't have the priviliges to do that!");
- break;
- default:
- sendMessage(CHANNEL, "Invalid command.");
- break;
- }
- }
- }
- //client.action('bequiin', user['display-name'] + ' hails evantjuh.');
- });
- client.on('connected', function(address, port) {
- sendMessage(CHANNEL, "Hello, I'm a bot created by evantjuh.");
- });
- client.on("part", function (channel, username, self) {
- sendMessage(CHANNEL, user['display-name'] + ' has left the channel!');
- });
- function sendMessage(channel, message) {
- client.action(channel, message);
- }
- function isMod(user) {
- if(user['mod'] || user['display-name'] === 'evantjuh')
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement