Squiso는 간단한 스크립트를 사용하여 Twitch 스트림을 사용자 정의할 수 있는 무료의 강력한 자동화 도구입니다.

새로운 Twitch 클립을 Discord에 자동으로 게시하는 방법

이 예시에서는 10분마다 새로운 클립이 있는지 확인하고, 특정 사용자가 만든 새로운 클립이 있으면 이를 Discord 서버에 게시합니다.

스크립트 예제

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 { @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); } } } } }