Squiso er et gratis, kraftfuldt automatiseringsværktøj, der lader dig tilpasse din Twitch-stream ved hjælp af simple scripts.
Sådan sender du automatisk nye Twitch-klip til Discord
Dette eksempel tjekker for nye klip hvert 10. minut, og hvis der er nye klip oprettet af en bestemt bruger, så send det til en Discord-server.
Eksempel på script
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.*;
import com.squiso.sysinfo.*;
// Important - Please do not change the row below - otherwise you will get a compilation error!
public class Script_Example extends SquisoScript {
    
    @Override
    public void onEveryMinute(OnEveryMinuteData data, API api) throws SquisoException {
        // Do this every 10 minutes
        if (data.is(10)) {
            // Save the time right now
            SquisoDate now = SquisoDate.nowUTC();
            api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Time now is: " + now.toYYYYMMDDHHMMSS());
            // Get all the 100 latest clips
            SquisoList<TwitchClip> allClips = api.getTwitchClips();
            api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Found " + allClips.size() + " clips");
            for (TwitchClip clip : allClips) {
                // If the creator is not "Squiso", then skip and continue to the next clip
                if (!clip.getCreator().equalsIgnoreCase("Squiso")) {
                    continue;
                }
                // Get the number of seconds since the clip was created from now
                SquisoInteger secondsSinceCreated = clip.getCreated().getSecondsSince(now);
                api.log("[Example_AutomaticallyPostTwitchClipsDiscord] The clip \"" + clip.getTitle() + "\" was created " + secondsSinceCreated + " seconds ago (" + clip.getCreated().toYYYYMMDDHHMMSS() + ") by \"" + clip.getCreator() + "\".");
                // 10 minutes is 10*60=600 seconds
                SquisoInteger threshold = new SquisoInteger(60 * 10);
                // Just log the check
                api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Checking if clip is below the threshold (" + secondsSinceCreated + " < " + threshold + ")....");
                // If the clip was created in the last 10 minutes
                if (secondsSinceCreated.isLessThan(threshold.get())) {
                    api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Posting clip \"" + clip.getTitle() + "\" to Discord");
                    // Compose a Discord message
                    SquisoString discordMessage = new SquisoString("");
                    discordMessage.append("A new clip was created by " + clip.getCreator() + "!");
                    discordMessage.append("\n");
                    discordMessage.append(clip.getURL());
                    // Send the message to the Discord channel
                    SquisoString discordWebhook = new SquisoString("https://discord.com/api/webhooks/abc/123");
                    api.sendSimpleDiscordMessage(discordWebhook, discordMessage);
                }
            }
        }
    }
}
    