essential-actions

Clone or download

Implement Twitch chat unhost action

Modified Files

M README.md
+3 −3
# Stream-Pi Essential Actions
# Stream-Pi Essential Actions
Set of trusted, pre-bundled actions and integrations for Stream-Pi using the [Stream-Pi Action API](https://github.com/stream-pi/actionapi).
Set of trusted, pre-bundled actions and integrations for Stream-Pi using the [Stream-Pi Action API](https://github.com/stream-pi/actionapi).
## Prerequisites
## Prerequisites
- Java >= 11
- Java >= 11
- Maven >= 3.6.3
- Maven >= 3.6.3
## List of Actions
## List of Actions
- Hotkey
- Hotkey
- Website
- Website
- Twitter
- Twitter
- OBS Actions
- OBS Actions
- Run Command
- Run Command
- Text Block
- Text Block
- Media File
- Media File
- Media Key
- Media Key
- Twitch
- Twitch
## Actions Help Guide
## Actions Help Guide
### Twitch Chat Integration
### Twitch Chat Integration
The first step is to acquire an OAuth token from https://twitchapps.com/tmi/, the generated OAuth token should look something like `oauth:xxxxx`.
The first step is to acquire an OAuth token from https://twitchapps.com/tmi/, the generated OAuth token should look something like `oauth:xxxxx`.
In the Stream-Pi Server's Plugin page enter your Twitch username, and the generated token then click on `Save Twitch chat credentials` button. You should then be able to use the pre-bundled Twitch chat actions.
In the Stream-Pi Server's Plugin page enter your Twitch username, and the generated token then click on `Save Twitch Chat credentials` button. You should then be able to use the pre-bundled Twitch chat actions.
### Supported actions (see [Chat Commands](https://help.twitch.tv/s/article/chat-commands?language=en_US) for full documentation)
### Supported actions (see [Chat Commands](https://help.twitch.tv/s/article/chat-commands?language=en_US) for full documentation)
#### All Users
#### All Users
- Set username color
- Set username color
- Normal users can choose between Blue, Coral, DodgerBlue, SpringGreen, YellowGreen, Green, OrangeRed, Red, GoldenRod, HotPink, CadetBlue, SeaGreen, Chocolate, BlueViolet, and Firebrick. Twitch Turbo users can use any Hex value (i.e: #000000).
- Normal users can choose between Blue, Coral, DodgerBlue, SpringGreen, YellowGreen, Green, OrangeRed, Red, GoldenRod, HotPink, CadetBlue, SeaGreen, Chocolate, BlueViolet, and Firebrick. Twitch Turbo users can use any Hex value (i.e: #000000).
- Send channel message
- Send channel message
- Whisper (send user message)
- Whisper (send user message)
#### Broadcaster and Mods
#### Broadcaster and Mods
- Clear chat
- Clear chat
- Toggle slow mode (TBA - pending toggle-button functionality)
- Toggle slow mode (TBA - pending toggle-button functionality)
- Toggle followers-only mode (TBA - pending toggle-button functionality)
- Toggle followers-only mode (TBA - pending toggle-button functionality)
- Toggle subs-only mode (TBA - pending toggle-button functionality)
- Toggle subs-only mode (TBA - pending toggle-button functionality)
- Toggle emotes-only mode (TBA - pending toggle-button functionality)
- Toggle emotes-only mode (TBA - pending toggle-button functionality)
#### Broadcaster and channel editors
#### Broadcaster and channel editors
- Run commercial (TBA)
- Run commercial (TBA)
- Host (TBA)
- Host (TBA)
- Unhost (TBA)
- Unhost
- Raid (TBA)
- Raid (TBA)
- Unraid (TBA)
- Unraid
- Add stream marker (TBA)
- Add stream marker (TBA)
### Running locally
### Running locally
Copy the `twitch-chat-connect`, `twitch-send-channel-msg`, and `Java-Twirk` jar files from the `PreBuiltPlugins` directory to your Stream-Pi server plugins' directory.
Copy the `twitch-chat-connect`, `twitch-send-channel-msg`, and `Java-Twirk` jar files from the `PreBuiltPlugins` directory to your Stream-Pi server plugins' directory.
---
---
## Quick Start
## Quick Start
Build all actions by executing `make build-all` from the command line or specific actions i.e. `make build-twitch-chat-action`, see [Makefile](Makefile) for complete list.
Build all actions by executing `make build-all` from the command line or specific actions i.e. `make build-twitch-chat-action`, see [Makefile](Makefile) for complete list.
To test these actions out in your local environment you'll need to run the [Stream-Pi Server](https://github.com/stream-pi/server) and copy the contents of `PreBuiltPlugins/` to the server's
To test these actions out in your local environment you'll need to run the [Stream-Pi Server](https://github.com/stream-pi/server) and copy the contents of `PreBuiltPlugins/` to the server's
Plugins directory (`data/Plugins` by default), especially if you're writing your own custom action / integration.
Plugins directory (`data/Plugins` by default), especially if you're writing your own custom action / integration.
M build.sh
+3 −0
#!/bin/bash
#!/bin/bash
FOLD=../PreBuiltPlugins
FOLD=../PreBuiltPlugins
hotkey() {
hotkey() {
pushd . || exit
pushd . || exit
cd hotkeyaction && mvn clean package
cd hotkeyaction && mvn clean package
mv target/hotkeyaction-1.0.0.jar $FOLD/hotkeyaction.jar
mv target/hotkeyaction-1.0.0.jar $FOLD/hotkeyaction.jar
popd || exit
popd || exit
}
}
mediakey() {
mediakey() {
pushd . || exit
pushd . || exit
cd mediakeyaction && mvn clean package
cd mediakeyaction && mvn clean package
mv target/mediakeyaction-1.0.0.jar $FOLD/mediakeyaction.jar
mv target/mediakeyaction-1.0.0.jar $FOLD/mediakeyaction.jar
popd || exit
popd || exit
}
}
obssuite() {
obssuite() {
pushd . || exit
pushd . || exit
cd obssuite/mother && mvn clean install package
cd obssuite/mother && mvn clean install package
mv target/obssuite_motheraction-1.0.0.jar ../$FOLD/obssuite_motheraction.jar
mv target/obssuite_motheraction-1.0.0.jar ../$FOLD/obssuite_motheraction.jar
cd ../setcurrentprofile && mvn clean package
cd ../setcurrentprofile && mvn clean package
mv target/obssuite_setcurrentprofileaction-1.0.0.jar ../$FOLD/obssuite_setcurrentprofileaction.jar
mv target/obssuite_setcurrentprofileaction-1.0.0.jar ../$FOLD/obssuite_setcurrentprofileaction.jar
cd ../setcurrentscene && mvn clean package
cd ../setcurrentscene && mvn clean package
mv target/obssuite_setcurrentsceneaction-1.0.0.jar ../$FOLD/obssuite_setcurrentsceneaction.jar
mv target/obssuite_setcurrentsceneaction-1.0.0.jar ../$FOLD/obssuite_setcurrentsceneaction.jar
cd ../setcurrenttransition && mvn clean package
cd ../setcurrenttransition && mvn clean package
mv target/obssuite_setcurrenttransitionaction-1.0.0.jar ../$FOLD/obssuite_setcurrenttransitionaction.jar
mv target/obssuite_setcurrenttransitionaction-1.0.0.jar ../$FOLD/obssuite_setcurrenttransitionaction.jar
cd ../setmute && mvn clean package
cd ../setmute && mvn clean package
mv target/obssuite_setmuteaction-1.0.0.jar ../$FOLD/obssuite_setmuteaction.jar
mv target/obssuite_setmuteaction-1.0.0.jar ../$FOLD/obssuite_setmuteaction.jar
cd ../setcurrentprofile && mvn clean package
cd ../setcurrentprofile && mvn clean package
mv target/obssuite_setcurrentprofileaction-1.0.0.jar ../$FOLD/obssuite_setcurrentprofileaction.jar
mv target/obssuite_setcurrentprofileaction-1.0.0.jar ../$FOLD/obssuite_setcurrentprofileaction.jar
cd ../setpreviewscene && mvn clean package
cd ../setpreviewscene && mvn clean package
mv target/obssuite_setpreviewsceneaction-1.0.0.jar ../$FOLD/obssuite_setpreviewsceneaction.jar
mv target/obssuite_setpreviewsceneaction-1.0.0.jar ../$FOLD/obssuite_setpreviewsceneaction.jar
cd ../setrecording && mvn clean package
cd ../setrecording && mvn clean package
mv target/obssuite_setrecordingaction-1.0.0.jar ../$FOLD/obssuite_setrecordingaction.jar
mv target/obssuite_setrecordingaction-1.0.0.jar ../$FOLD/obssuite_setrecordingaction.jar
cd ../setreplaybuffer && mvn clean package
cd ../setreplaybuffer && mvn clean package
mv target/obssuite_setreplaybufferaction-1.0.0.jar ../$FOLD/obssuite_setreplaybufferaction.jar
mv target/obssuite_setreplaybufferaction-1.0.0.jar ../$FOLD/obssuite_setreplaybufferaction.jar
cd ../setstreaming && mvn clean package
cd ../setstreaming && mvn clean package
mv target/obssuite_setstreamingaction-1.0.0.jar ../$FOLD/obssuite_setstreamingaction.jar
mv target/obssuite_setstreamingaction-1.0.0.jar ../$FOLD/obssuite_setstreamingaction.jar
cd ../setstudiomode && mvn clean package
cd ../setstudiomode && mvn clean package
mv target/obssuite_setstudiomodeaction-1.0.0.jar ../$FOLD/obssuite_setstudiomodeaction.jar
mv target/obssuite_setstudiomodeaction-1.0.0.jar ../$FOLD/obssuite_setstudiomodeaction.jar
cd ../setvolume && mvn clean package
cd ../setvolume && mvn clean package
mv target/obssuite_setvolumeaction-1.0.0.jar ../$FOLD/obssuite_setvolumeaction.jar
mv target/obssuite_setvolumeaction-1.0.0.jar ../$FOLD/obssuite_setvolumeaction.jar
popd || exit
popd || exit
}
}
playaudioclip() {
playaudioclip() {
pushd . || exit
pushd . || exit
cd playaudioclipaction && mvn clean package
cd playaudioclipaction && mvn clean package
mv target/playaudioclipaction-1.0.0.jar $FOLD/playaudioclipaction.jar
mv target/playaudioclipaction-1.0.0.jar $FOLD/playaudioclipaction.jar
popd || exit
popd || exit
}
}
runcommand() {
runcommand() {
pushd . || exit
pushd . || exit
cd runcommandaction && mvn clean package
cd runcommandaction && mvn clean package
mv target/runcommandaction-1.0.0.jar $FOLD/runcommandaction.jar
mv target/runcommandaction-1.0.0.jar $FOLD/runcommandaction.jar
popd || exit
popd || exit
}
}
textblock() {
textblock() {
pushd . || exit
pushd . || exit
cd textblockaction && mvn clean package
cd textblockaction && mvn clean package
mv target/textblockaction-1.0.0.jar $FOLD/textblockaction.jar
mv target/textblockaction-1.0.0.jar $FOLD/textblockaction.jar
popd || exit
popd || exit
}
}
twitter() {
twitter() {
pushd . || exit
pushd . || exit
cd twitteraction && mvn clean package
cd twitteraction && mvn clean package
mv target/twitteraction-1.0.0.jar $FOLD/twitteraction.jar
mv target/twitteraction-1.0.0.jar $FOLD/twitteraction.jar
popd || exit
popd || exit
}
}
twitchchat() {
twitchchat() {
pushd . || exit
pushd . || exit
cd twitch/twitch-chat-connect && mvn clean install package
cd twitch/twitch-chat-connect && mvn clean install package
mv target/twitch-chat-connect-1.0.0.jar ../$FOLD/twitch-chat-connect.jar
mv target/twitch-chat-connect-1.0.0.jar ../$FOLD/twitch-chat-connect.jar
cd ../send-channel-msg && mvn clean install package
cd ../send-channel-msg && mvn clean install package
mv target/twitch-send-channel-msg-1.0.0.jar ../$FOLD/twitch-send-channel-msg.jar
mv target/twitch-send-channel-msg-1.0.0.jar ../$FOLD/twitch-send-channel-msg.jar
cd ../clear-chat && mvn clean install package
cd ../clear-chat && mvn clean install package
mv target/twitch-clear-chat-1.0.0.jar ../$FOLD/twitch-clear-chat.jar
mv target/twitch-clear-chat-1.0.0.jar ../$FOLD/twitch-clear-chat.jar
cd ../set-color && mvn clean install package
cd ../set-color && mvn clean install package
mv target/twitch-set-color-1.0.0.jar ../$FOLD/twitch-set-color.jar
mv target/twitch-set-color-1.0.0.jar ../$FOLD/twitch-set-color.jar
cd ../whisper && mvn clean install package
cd ../whisper && mvn clean install package
mv target/twitch-whisper-1.0.0.jar ../$FOLD/twitch-whisper.jar
mv target/twitch-whisper-1.0.0.jar ../$FOLD/twitch-whisper.jar
cd ../unraid && mvn clean install package
cd ../unraid && mvn clean install package
mv target/twitch-unraid-1.0.0.jar ../$FOLD/twitch-unraid.jar
mv target/twitch-unraid-1.0.0.jar ../$FOLD/twitch-unraid.jar
cd ../unhost && mvn clean install package
mv target/twitch-unhost-1.0.0.jar ../$FOLD/twitch-unhost.jar
popd || exit
popd || exit
}
}
websiteaction() {
websiteaction() {
pushd . || exit
pushd . || exit
cd websiteaction && mvn clean package
cd websiteaction && mvn clean package
mv target/websiteaction-1.0.0.jar $FOLD/websiteaction.jar
mv target/websiteaction-1.0.0.jar $FOLD/websiteaction.jar
popd || exit
popd || exit
}
}
case "$1" in
case "$1" in
hotkey)
hotkey)
hotkey
hotkey
;;
;;
mediakey)
mediakey)
mediakey
mediakey
;;
;;
playaudioclip)
playaudioclip)
playaudioclip
playaudioclip
;;
;;
runcommand)
runcommand)
runcommand
runcommand
;;
;;
textblock)
textblock)
textblock
textblock
;;
;;
twitter)
twitter)
twitter
twitter
;;
;;
website)
website)
website
website
;;
;;
obssuite)
obssuite)
obssuite
obssuite
;;
;;
twitchchat)
twitchchat)
twitchchat
twitchchat
;;
;;
*)
*)
# build all actions as default
# build all actions as default
hotkey
hotkey
mediakey
mediakey
obssuite
obssuite
playaudioclip
playaudioclip
runcommand
runcommand
textblock
textblock
twitter
twitter
twitchchat
twitchchat
website
website
;;
;;
esac
esac
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stream-pi</groupId>
<artifactId>twitch-unhost</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<streamPiActionApiVersion>1.0.0</streamPiActionApiVersion>
<streamPiUtilVersion>1.0.0</streamPiUtilVersion>
<streamPiTwitchChatConnectVersion>1.0.0</streamPiTwitchChatConnectVersion>
<javaTwirkVersion>0.6.3</javaTwirkVersion>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>test-jar</id>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
<version>${streamPiUtilVersion}</version>
</dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<artifactId>action-api</artifactId>
<version>${streamPiActionApiVersion}</version>
</dependency>
<dependency>
<groupId>com.github.gikkman</groupId>
<artifactId>Java-Twirk</artifactId>
<version>${javaTwirkVersion}</version>
</dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<artifactId>twitch-chat-connect</artifactId>
<version>${streamPiTwitchChatConnectVersion}</version>
</dependency>
</dependencies>
</project>
module com.stream_pi.twitch.unhostaction {
requires com.stream_pi.util;
requires com.stream_pi.action_api;
requires com.stream_pi.twitchchatconnectaction;
requires Java.Twirk;
provides com.stream_pi.action_api.normalaction.NormalAction with unhost.UnhostAction;
}
package unhost;
import com.gikk.twirk.Twirk;
import com.gikk.twirk.TwirkBuilder;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.util.exception.StreamPiException;
import com.stream_pi.util.version.Version;
import connect.chat.TwitchChatCredentials;
public class UnhostAction extends NormalAction
{
private final String channelNameKey = "channel_name_ua";
private Twirk twirk;
public UnhostAction()
{
setName("Unhost");
setCategory("Twitch Chat");
setVisibilityInServerSettingsPane(false);
setAuthor("j4ckofalltrades");
setVersion(new Version(1, 0, 0));
setHelpLink("https://github.com/stream-pi/essentialactions#twitch-chat-integration");
}
@Override
public void initProperties() throws Exception
{
Property channel = new Property(channelNameKey, Type.STRING);
channel.setDisplayName("Channel");
channel.setDefaultValueStr("channel_name");
channel.setCanBeBlank(false);
addClientProperties(channel);
}
@Override
public void initAction() throws Exception
{
}
@Override
public void onActionClicked() throws Exception
{
final TwitchChatCredentials.ChatCredentials credentials = TwitchChatCredentials.getCredentials();
credentials.ensureCredentialsInitialized();
final String channel = getClientProperties().getSingleProperty(channelNameKey).getStringValue();
try
{
twirk = new TwirkBuilder(channel, credentials.getNickname(), credentials.getOauthToken()).build();
twirk.connect();
twirk.channelMessage("/unhost");
} catch (Exception ex)
{
throw new StreamPiException(
"Failed to cancel channel raid",
"Could not send cancel channel raid, please try again.");
}
}
@Override
public void onShutDown() throws Exception
{
if (twirk != null) {
try
{
twirk.disconnect();
} catch (Exception ex) {
throw new StreamPiException("Twitch connection error", "Please try again.");
}
}
}
}