Last active
January 27, 2018 18:20
-
-
Save TapGhoul/46022b4bc9945dbe7a25383e45212183 to your computer and use it in GitHub Desktop.
Userscript for ScreampunkArts to simulate a basic chat bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Picarto.TV Bot | |
| // @namespace https://picarto.tv/ | |
| // @version 1.6 | |
| // @description Adds bot-like functionality to picarto chat (only works in your channel) | |
| // @author Andrew Silver https://keybase.io/silvea12 | |
| // @match https://picarto.tv/site/dashboard | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| /* | |
| * Command list | |
| * | |
| * Make sure that your commands are all lowercase (or else they won't register) | |
| * Also make sure the end " has a , after it or the entire script may not work! | |
| * | |
| * If you need to have a " symbol as part of it, make sure it is typed as \" | |
| * Example: "The pig says: \"oink\"" | |
| * | |
| * If you wish to have someone's name in there, add $name - example: | |
| * "Welcome, $name!" | |
| * | |
| * If you want a mention, do "@$name" - example: | |
| * "Welcome, @$name!" | |
| * | |
| * To use arguments, do $arg# - example | |
| * Template: "/me licks $arg1" | |
| * Input: !lick icecream | |
| * Output: "/me licks icecream" | |
| * NOTE: If one is to do !lick on its own it will print out "/me licks $arg1" as a literal | |
| * | |
| * text is the text to send | |
| * users is if anyone can run it | |
| * subs is if subscribers can run it | |
| * mods is if mods can run it | |
| * Note: Streamers can run any command regardless of flags | |
| */ | |
| // Commands that can be used | |
| var commands = { | |
| "backflip": { | |
| text: "/me backflips onto @$arg1", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "flail": { | |
| text: "/me flails $arg1 around", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "glomp": { | |
| text: "/me glomps $arg1!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "hug": { | |
| text: "/me hugs $arg1!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "commands": { | |
| text: "Check below the stream for a list of chat commands!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "faq": { | |
| text: "Check below the stream for a list of Frequently Asked Questions!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "schedule": { | |
| text: "Rin streams privately for Patreon during the week, and publicly on weekends, usually around 10pm-3am GMT!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "ticklish": { | |
| text: "@$name is feeling ticklish~", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tkfeet": { | |
| text: "@$name tickles $arg1's feet!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tkarms": { | |
| text: "@$name tickles $arg1's underarms!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tkhips": { | |
| text: "@$name tickles $arg1's hips!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tkwaist": { | |
| text: "@$name tickles $arg1's waist!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tkneck": { | |
| text: "@$name tickles $arg1's neck!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tkbelly": { | |
| text: "@$name tickles $arg1's navel!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "chloro": { | |
| text: "@$name chloroforms $arg1!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tickle": { | |
| text: "Tickle tickle~<3", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "gag": { | |
| text: "@$name gags $arg1!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "tie": { | |
| text: "@$name ties up $arg1!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "trap": { | |
| text: ":ptv-nope: IT'S A TRAP! :ptv-nope:", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "nuzzle": { | |
| text: "@$name nuzzles $arg1~", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "dickpunch": { | |
| text: "@$name punches $arg1 in the dick!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "cuntpunch": { | |
| text: "@$name punches $arg1 in the cunt!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "socks": { | |
| text: "STOP SOCKBLOCKING ME! BURN THEM!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "yuri": { | |
| text: ":ptv-hearts: Yuri is the solution to all problems. Yuri is love. Yuri is life. Yuri can save the world. Yuri cures cancer & poverty. :ptv-excited:", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "poke": { | |
| text: "/me pokes $arg1", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "kidnap": { | |
| text: "@$name kidnaps $sarg1!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "plan": { | |
| text: "Rin is currently spending a few months clearing out all the art she owes people, before beginning work on an actual game!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "credit": { | |
| text: "This mini chatbot was made by the awesome user @Pikachu on Picarto.TV!", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "daz": { | |
| text: "WOOF BARK BORK SNIFF GRUMBLE WOOF BARK CARROT", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "bondage": { | |
| text: ":cscreampunkarts-RebCheeky:", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "ban": { | |
| text: "$argi is banned for acting the mickey. :cscreampunkarts-RebAngry:", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "discord": { | |
| text: "NO I WILL NOT JOIN YOUR FUCKING DISCORD.", | |
| users: true, | |
| subs: true, | |
| mods: true | |
| }, | |
| "welcome": { | |
| text: "Thanks for watching, everyone! Feel free to chat, I don't bite~<3 Also, have fun with the commands!", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "donate": { | |
| text: "If you'd like to donate to support me, and have a cute little GIF play next to your name in the stream, you can find my Patreon or StreamLabs links below the stream! Thank you so much~<3", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "subscribe": { | |
| text: "Subscribers receive access to a list of unique emotes, plus your own stream command!", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "follower": { | |
| text: "Hey Sole Sister! Thanks for following! Remember to refresh the page to join the chat!", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "donation": { | |
| text: ":ptv-laugh::ptv-hearts::ptv-laugh::ptv-hearts::ptv-laugh::ptv-hearts:" + | |
| " ======ALL ABOARD THE TICKLE TRAIN!======" + | |
| ":ptv-laugh::ptv-hearts::ptv-laugh::ptv-hearts::ptv-laugh::ptv-hearts:" + | |
| "Thank you for the donation~πππ :ptv-ohmy:", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "pledge1": { | |
| text: "Hey Sole Sister! Thank you so much for pledging via Patreon~π", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "pledge5": { | |
| text: "That's-a-spicy foot rub! Thank you so much for pledging via Patreon~π", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| "pledge10": { | |
| text: "ALL ABOARD THE TICKLE TRAIN! Thank you so much for pledging via Patreon~π", | |
| users: false, | |
| subs: false, | |
| mods: false | |
| }, | |
| }; | |
| // Things run on a schedule (said in order) | |
| var scheduledMessages = [ | |
| "[ScreamBot]: Thanks for watching! Please remember to check out the FAQ and follow the Global Rules!", | |
| "[ScreamBot]: The chat commands are there for you to amuse yourselves during those awkward silences~ Don't be afraid, give 'em a try!", | |
| "[ScreamBot]: You can get a huge pile of great rewards each month by supporting me on Patreon! https://www.patreon.com/ScreampunkArts", | |
| "[ScreamBot]: If you'd like to donate to support me, and have a cute little GIF pop up with your name in the stream, my StreamLabs link is: https://streamlabs.com/ScreampunkArts! $5+ Donations even get your own message read out in the stream! Thank you so much~<3", | |
| "[ScreamBot]: Picarto.TV subscribers receive access to a list of unique emotes, plus your own stream command!", | |
| ]; | |
| // Used internally to keep track of which scheduled message to send next | |
| var scheduledMessageBag = []; | |
| // Sends a message to the chat | |
| function sendMsg(msg, isStreamer) { | |
| if (isStreamer) { | |
| // Bypass rate limit (we assume that you are always a streamer) | |
| return setTimeout(function() { sendMsg(msg, false); }, 600); | |
| } | |
| socket.Emit('NewMessage', new proto.NewMessage([msg])); | |
| } | |
| // Shorthand to send a whisper | |
| function sendWhisper(user, msg, isStreamer) {sendMsg("/w " + user + " " + msg, isStreamer);} | |
| // Handles messages sent | |
| socket.On('ChatMessage', function(data) { | |
| if (data.message[0] !== '!') return; | |
| var commandParts = data.message.substr(1).split(" "); | |
| var commandText = commandParts.shift().toLowerCase(); | |
| var command = commands[commandText]; | |
| if (!command) { | |
| return; | |
| } | |
| if (!data.streamer && // User is a streamer (bypass) | |
| !command.users && // Command can be used by all | |
| !(command.subs && data.subscriber) && // User is a subscriber | |
| !(command.mods && data.moderator)) { // User is a moderator | |
| // User cannot run this command | |
| return; | |
| } | |
| var cmd = command.text; | |
| var commandError = ""; | |
| cmd = cmd.replace(/\$name/g, data.displayName); | |
| cmd = cmd.replace(/\$arg(\d+)/g, function(input, arg1) { | |
| var argID = parseInt(arg1) - 1; | |
| if (argID < commandParts.length) { | |
| return commandParts[argID]; | |
| } else { | |
| commandError = "You need at least " + commandParts.length + " arguments for this command"; | |
| return input; | |
| } | |
| }); | |
| if (commandError !== "") { | |
| return sendWhisper(data.displayName, commandError, data.streamer); | |
| } | |
| sendMsg(cmd, data.streamer); | |
| }); | |
| // Fills + shuffles the scheduled message bag | |
| function fillScheduledMessageBag() { | |
| scheduledMessageBag = scheduledMessages.slice(); | |
| scheduledMessageBag.sort(function() { | |
| return Math.random() < 0.5 ? -1 : 1; | |
| }); | |
| } | |
| // Says things on a schedule | |
| if (scheduledMessages.length !== 0) { // Prevents it giving errors if we have no messages set | |
| setInterval(function() { | |
| if (scheduledMessageBag.length === 0) { | |
| fillScheduledMessageBag(); | |
| } | |
| sendMsg(scheduledMessageBag.shift()); | |
| }, 1000*60*30); // 30 minutes | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment