Squiso is a free, powerful automation tool that lets you customize your Twitch stream using simple scripts.

How to Auto-Create Clips Based on Number of LOLs Spammed in Chat

This is a slightly more advanced example. It counts up the number of LOLs in chat, but decreases the number automatically every 5 seconds. If the number of LOLs is higher than a threshold value, it creates a clip. Then it waits 30 seconds until it gets the MP4 video of it and then sends it to a Discord channel.

Script Example

import com.squiso.*; import com.squiso.exception.*; import com.squiso.scripting.*; import com.squiso.scripting.data.*; import com.squiso.keyboard.*; import com.squiso.twitch.*; import com.squiso.datatypes.*; import com.squiso.utils.*; // Important - Please do not change the row below - otherwise you will get a compilation error! public class Script_Example extends SquisoScript { // Create an "atomic" number variable that is "thread safe" SquisoInteger lolMeter = new SquisoInteger(0); @Override public void onEverySecond(OnEverySecondData data, API api) throws SquisoException { // Do this every 5 seconds if (data.is(5)) { // If the LOL meter is above 0, then decrease it by 1, then log the current value if (lolMeter.get() > 0) { lolMeter.decrement(); // Print out the current LOL meter api.log("LOL meter got decreased and is now " + lolMeter); } } } @Override public void onTwitchChatMessage(OnTwitchChatMessageData data, API api) throws SquisoException { // Create a list of words that should increase the LOL meter SquisoList<String> triggeredWords = new SquisoList<>(); triggeredWords.add("LUL"); triggeredWords.add("LOL"); triggeredWords.add("KEKW"); // If the chat message contains one of the words, increase the LOL meter by 1 for (String triggeredWord : triggeredWords) { if (data.getMessageText().contains(triggeredWord)) { lolMeter.increment(); break; } } // Specify the max number of LOLs until we automatically create a clip int maxLolMeter = 10; // Log that we are going to check the current value with max value api.log("Checking if current LOL meter " + lolMeter + " is more than " + maxLolMeter + "."); // If the current LOL meter is more than max if (lolMeter.get() > maxLolMeter) { // Print out that the meter is above our max api.log("LOL counter is above " + maxLolMeter + "!"); // Reset the LOL meter by setting it down to 0 again lolMeter.set(0); // Create a clip CreateTwitchClipResult createData = api.createTwitchClip(); // Specify 30 seconds (30*1000=30000 milliseconds) SquisoInteger waitTime = new SquisoInteger(10 * 1000); // Do this 30 seconds later (we wait 30 seconds to give Twitch time to generate an MP4 video out of the clip) api.doLater(waitTime, () -> { // Extract the clip ID to its own variable SquisoString clipID = createData.getClipID(); // Get additional data from the clip TwitchClip clip = api.getTwitchClip(clipID); // Specify the Discord webhook URL SquisoString discordWebhook = new SquisoString("https://discord.com/api/webhooks/abc/123"); // Create the message that we will send to Discord SquisoString discordMessage = new SquisoString(""); discordMessage.append("A new clip was created!"); discordMessage.append("\n"); discordMessage.append(clip.getURL()); // Send the message to the Discord channel api.sendSimpleDiscordMessage(discordWebhook, discordMessage); }); } } }