essential-actions

Clone or download

Use latest action-api in twitch host channel

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-host-channel</artifactId>
<artifactId>twitch-host-channel</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 hostchannel;
package hostchannel;
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 HostChannelAction extends NormalAction
public class HostChannelAction extends NormalAction
{
{
private final String channelKey = "channel_hc";
private final String channelKey = "channel_hc";
private final String channelToHostKey = "channel_to_host_hc";
private final String channelToHostKey = "channel_to_host_hc";
private Twirk twirk;
private Twirk twirk;
public HostChannelAction()
public HostChannelAction()
{
{
setName("Host Channel");
setName("Host Channel");
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 channel = new Property(channelKey, Type.STRING);
Property channel = new Property(channelKey, Type.STRING);
channel.setDisplayName("Channel");
channel.setDisplayName("Channel");
channel.setDefaultValueStr("channel");
channel.setDefaultValueStr("channel");
channel.setCanBeBlank(false);
channel.setCanBeBlank(false);
Property channelToHost = new Property(channelToHostKey, Type.STRING);
Property channelToHost = new Property(channelToHostKey, Type.STRING);
channelToHost.setDisplayName("Channel to host");
channelToHost.setDisplayName("Channel to host");
channelToHost.setDefaultValueStr("channel_to_host");
channelToHost.setDefaultValueStr("channel_to_host");
channelToHost.setCanBeBlank(false);
channelToHost.setCanBeBlank(false);
addClientProperties(channel, channelToHost);
addClientProperties(channel, channelToHost);
}
}
@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(channelKey).getStringValue();
final String channel = getClientProperties().getSingleProperty(channelKey).getStringValue();
final String channelToHost = getClientProperties().getSingleProperty(channelToHostKey).getStringValue();
final String channelToHost = getClientProperties().getSingleProperty(channelToHostKey).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();
twirk.channelMessage(String.format("/host %s", channelToHost));
twirk.channelMessage(String.format("/host %s", channelToHost));
} catch (Exception ex)
} catch (Exception ex)
{
{
throw new StreamPiException(
throw new StreamPiException(
"Failed to host channel",
"Failed to host channel",
String.format("Could not host channel '%s', please try again.", channelToHost));
String.format("Could not host channel '%s', please try again.", channelToHost));
}
}
}
}
@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.hostchannelaction {
module com.stream_pi.twitch.hostchannelaction {
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 hostchannel.HostChannelAction;
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with hostchannel.HostChannelAction;
}
}