This file contains 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
import com.github.twitch4j.chat.TwitchChat; | |
import com.github.twitch4j.chat.TwitchChatBuilder; | |
import com.github.twitch4j.chat.events.AbstractChannelEvent; | |
import com.github.twitch4j.chat.events.channel.GiftSubscriptionsEvent; | |
import com.github.twitch4j.chat.events.channel.SubscriptionEvent; | |
import com.github.twitch4j.common.events.domain.EventChannel; | |
import com.github.twitch4j.common.events.domain.EventUser; | |
import com.github.twitch4j.common.util.TwitchUtils; | |
import java.util.Collection; |
This file contains 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
import com.github.philippheuer.events4j.core.EventManager; | |
import com.github.philippheuer.events4j.simple.SimpleEventHandler; | |
import com.github.twitch4j.common.util.EventManagerUtils; | |
import com.github.twitch4j.common.util.TypeConvert; | |
import com.github.twitch4j.eventsub.EventSubNotification; | |
import com.github.twitch4j.eventsub.EventSubSubscriptionStatus; | |
import com.github.twitch4j.eventsub.EventSubTransport; | |
import com.github.twitch4j.eventsub.EventSubTransportMethod; | |
import com.github.twitch4j.eventsub.events.ChannelFollowEvent; | |
import com.github.twitch4j.eventsub.subscriptions.SubscriptionTypes; |
This file contains 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
package com.github.twitch4j; | |
import com.github.philippheuer.credentialmanager.domain.OAuth2Credential; | |
import com.github.twitch4j.auth.providers.TwitchIdentityProvider; | |
import com.github.twitch4j.common.util.ThreadUtils; | |
import java.util.Collections; | |
import java.util.concurrent.ScheduledThreadPoolExecutor; | |
import java.util.concurrent.TimeUnit; |
This file contains 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
final String clientId = "***", clientSecret = "***", redirectUrl = null; | |
final TwitchIdentityProvider tip = new TwitchIdentityProvider(clientId, clientSecret, redirectUrl); | |
Supplier<OAuth2Credential> readCredentialFromFile = () -> { | |
final String initialAccessToken = "***", initialRefreshToken = "***"; // TODO: must be read from file | |
final OAuth2Credential cred = new OAuth2Credential("twitch", initialAccessToken); | |
cred.setRefreshToken(initialRefreshToken); | |
return cred; | |
}; |
This file contains 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
import com.github.twitch4j.helix.TwitchHelixBuilder | |
import com.github.twitch4j.helix.domain.Clip | |
import com.github.twitch4j.util.PaginationUtil | |
import org.apache.commons.lang.StringEscapeUtils | |
import java.nio.file.Files | |
import java.nio.file.Paths | |
import java.time.Instant | |
import java.time.temporal.ChronoUnit | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.Executors |
This file contains 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
private static final double INV_SQRT_TWO = 1 / Math.sqrt(2.0); | |
public static double cdf(double mu, double sigma, double z) { | |
return cdf((z - mu) / sigma); | |
} | |
public static double cdf(double z) { | |
if (z < -6 || z > 6) return 0; | |
return 0.5 * (1 + erf(Math.abs(z) * INV_SQRT_TWO) * (z > 0 ? 1 : -1)); | |
} |