essential-actions

Clone or download

Use latest action-api on twitch add stream marker

Modified Files

<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>twitch-add-stream-marker</artifactId>
<artifactId>twitch-add-stream-marker</artifactId>
<version>1.0.0</version>
<version>1.0.0</version>
<properties>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.target>11</maven.compiler.target>
<streamPiActionApiVersion>1.0.0</streamPiActionApiVersion>
<streamPiActionApiVersion>1.0.0-SNAPSHOT</streamPiActionApiVersion>
<streamPiUtilVersion>1.0.0</streamPiUtilVersion>
<streamPiUtilVersion>1.0.0-SNAPSHOT</streamPiUtilVersion>
<streamPiTwitchChatConnectVersion>1.0.0</streamPiTwitchChatConnectVersion>
<streamPiTwitchChatConnectVersion>1.0.0</streamPiTwitchChatConnectVersion>
<javaTwirkVersion>0.6.3</javaTwirkVersion>
<javaTwirkVersion>0.6.3</javaTwirkVersion>
</properties>
</properties>
<repositories>
<repositories>
<repository>
<repository>
<id>jitpack.io</id>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<url>https://jitpack.io</url>
</repository>
</repository>
</repositories>
</repositories>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.0</version>
<executions>
<executions>
<execution>
<execution>
<id>test-jar</id>
<id>test-jar</id>
<phase>package</phase>
<phase>package</phase>
<goals>
<goals>
<goal>test-jar</goal>
<goal>test-jar</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.8.1</version>
<configuration>
<configuration>
<release>11</release>
<release>11</release>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
<artifactId>util</artifactId>
<version>${streamPiUtilVersion}</version>
<version>${streamPiUtilVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>action-api</artifactId>
<artifactId>action-api</artifactId>
<version>${streamPiActionApiVersion}</version>
<version>${streamPiActionApiVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.github.gikkman</groupId>
<groupId>com.github.gikkman</groupId>
<artifactId>Java-Twirk</artifactId>
<artifactId>Java-Twirk</artifactId>
<version>${javaTwirkVersion}</version>
<version>${javaTwirkVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>twitch-chat-connect</artifactId>
<artifactId>twitch-chat-connect</artifactId>
<version>${streamPiTwitchChatConnectVersion}</version>
<version>${streamPiTwitchChatConnectVersion}</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
package addstreammarker;
package addstreammarker;
import com.gikk.twirk.Twirk;
import com.gikk.twirk.Twirk;
import com.gikk.twirk.TwirkBuilder;
import com.gikk.twirk.TwirkBuilder;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.util.exception.StreamPiException;
import com.stream_pi.util.exception.StreamPiException;
import com.stream_pi.util.version.Version;
import com.stream_pi.util.version.Version;
import connect.chat.TwitchChatCredentials;
import connect.chat.TwitchChatCredentials;
public class AddStreamMarkerAction extends NormalAction
public class AddStreamMarkerAction extends NormalAction
{
{
private final String channelNameKey = "channel_name_asm";
private final String channelNameKey = "channel_name_asm";
private final String descriptionKey = "description_asm";
private final String descriptionKey = "description_asm";
private Twirk twirk;
private Twirk twirk;
public AddStreamMarkerAction()
public AddStreamMarkerAction()
{
{
setName("Add stream marker");
setName("Add stream marker");
setCategory("Twitch Chat");
setCategory("Twitch Chat");
setVisibilityInServerSettingsPane(false);
setVisibilityInServerSettingsPane(false);
setAuthor("j4ckofalltrades");
setAuthor("j4ckofalltrades");
setVersion(new Version(1, 0, 0));
setVersion(new Version(1, 0, 0));
setHelpLink("https://github.com/stream-pi/essentialactions#twitch-chat-integration");
setHelpLink("https://github.com/stream-pi/essentialactions#twitch-chat-integration");
}
}
@Override
@Override
public void initProperties() throws Exception
public void initProperties() throws Exception
{
{
Property channelName = new Property(channelNameKey, Type.STRING);
Property channelName = new Property(channelNameKey, Type.STRING);
channelName.setDisplayName("Channel Name");
channelName.setDisplayName("Channel Name");
channelName.setDefaultValueStr("channel_name");
channelName.setDefaultValueStr("channel_name");
channelName.setCanBeBlank(false);
channelName.setCanBeBlank(false);
Property description = new Property(descriptionKey, Type.STRING);
Property description = new Property(descriptionKey, Type.STRING);
description.setDisplayName("Description (Optional, max 140 chars)");
description.setDisplayName("Description (Optional, max 140 chars)");
addClientProperties(channelName, description);
addClientProperties(channelName, description);
}
}
@Override
@Override
public void initAction() throws Exception
public void initAction() throws Exception
{
{
}
}
@Override
@Override
public void onActionClicked() throws Exception
public void onActionClicked() throws Exception
{
{
final TwitchChatCredentials.ChatCredentials credentials = TwitchChatCredentials.getCredentials();
final TwitchChatCredentials.ChatCredentials credentials = TwitchChatCredentials.getCredentials();
credentials.ensureCredentialsInitialized();
credentials.ensureCredentialsInitialized();
final String channel = getClientProperties().getSingleProperty(channelNameKey).getStringValue();
final String channel = getClientProperties().getSingleProperty(channelNameKey).getStringValue();
final String description = getClientProperties().getSingleProperty(descriptionKey).getStringValue();
final String description = getClientProperties().getSingleProperty(descriptionKey).getStringValue();
try
try
{
{
twirk = new TwirkBuilder(channel, credentials.getNickname(), credentials.getOauthToken()).build();
twirk = new TwirkBuilder(channel, credentials.getNickname(), credentials.getOauthToken()).build();
twirk.connect();
twirk.connect();
if (description != null && !description.isEmpty()) {
if (description != null && !description.isEmpty()) {
twirk.channelMessage(String.format("/marker %s", description));
twirk.channelMessage(String.format("/marker %s", description));
} else {
} else {
twirk.channelMessage("/marker");
twirk.channelMessage("/marker");
}
}
} catch (Exception ex)
} catch (Exception ex)
{
{
throw new StreamPiException(
throw new StreamPiException(
"Failed to add marker to stream", "Could not add stream marker, please try again."
"Failed to add marker to stream", "Could not add stream marker, please try again."
);
);
}
}
}
}
@Override
@Override
public void onShutDown() throws Exception
public void onShutDown() throws Exception
{
{
if (twirk != null) {
if (twirk != null) {
try
try
{
{
twirk.disconnect();
twirk.disconnect();
} catch (Exception ex) {
} catch (Exception ex) {
throw new StreamPiException("Twitch connection error", "Please try again.");
throw new StreamPiException("Twitch connection error", "Please try again.");
}
}
}
}
}
}
}
}
module com.stream_pi.twitch.addstreammarkeraction {
module com.stream_pi.twitch.addstreammarkeraction {
requires com.stream_pi.util;
requires com.stream_pi.util;
requires com.stream_pi.action_api;
requires com.stream_pi.action_api;
requires com.stream_pi.twitchchatconnectaction;
requires com.stream_pi.twitchchatconnectaction;
requires Java.Twirk;
requires Java.Twirk;
provides com.stream_pi.action_api.normalaction.NormalAction with addstreammarker.AddStreamMarkerAction;
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with addstreammarker.AddStreamMarkerAction;
}
}