Skip to content

Commit

Permalink
refactor(tsl): change "isGifted" with "gifted"
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoodie committed Dec 8, 2019
1 parent 1b0c203 commit 93514f4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.programmer.igoodie.twitchspawn.tslanguage.keyword.TSLEventKeyword;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -96,7 +95,7 @@ public void execute(ICommandSender commandSender, String[] moduleArgs) throws Co
simulatedEvent.raiderCount = nbt.getInteger("raiders");
simulatedEvent.viewerCount = nbt.getInteger("viewers");
simulatedEvent.subscriptionTier = nbt.hasKey("tier", 3) ? nbt.getInteger("tier") : -1;
simulatedEvent.isGifted = nbt.getBoolean("isGifted");
simulatedEvent.gifted = nbt.getBoolean("gifted");
}

ConfigManager.RULESET_COLLECTION.handleEvent(simulatedEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void onLiveEvent(Socket socket, CredentialsConfig.Streamer streamer, O
// eventArguments.raiderCount = JSONUtils.extractNumberFrom(message, "raiders", 0).intValue(); // Raids aren't supported (?)
eventArguments.viewerCount = JSONUtils.extractNumberFrom(data, "amount ", 0).intValue();
eventArguments.subscriptionTier = extractTier(data, "tier");
// TODO: add isGifted
// TODO: add gifted

// Pass the model to the handler
ConfigManager.RULESET_COLLECTION.handleEvent(eventArguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import scala.util.parsing.json.JSON;

import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

public class StreamlabsSocketTracer extends SocketIOTracer {

Expand Down Expand Up @@ -83,7 +78,7 @@ protected void onLiveEvent(Socket socket, CredentialsConfig.Streamer streamer, O
eventArguments.raiderCount = JSONUtils.extractNumberFrom(message, "raiders", 0).intValue();
eventArguments.viewerCount = JSONUtils.extractNumberFrom(message, "viewers", 0).intValue();
eventArguments.subscriptionTier = extractTier(message, "sub_plan");
eventArguments.isGifted = JSONUtils.extractFrom(message, "gifter_twitch_id", String.class, null) != null;
eventArguments.gifted = JSONUtils.extractFrom(message, "gifter_twitch_id", String.class, null) != null;

// Pass the model to the handler
ConfigManager.RULESET_COLLECTION.handleEvent(eventArguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static EventArguments createRandom(String streamerNickname) {

public int subscriptionMonths;
public int subscriptionTier = -1; // 0=Prime, 1=T1, 2=T2, 3=T3
public boolean isGifted;
public boolean gifted;

public int viewerCount;
public int raiderCount;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void randomize(String actorNickname, String message) {
this.donationCurrency = new String[]{"USD", "TRY", "EUR"}[random.nextInt(3)];
this.subscriptionMonths = random.nextInt(100 - 1) + 1;
this.subscriptionTier = random.nextInt(3 + 1);
this.isGifted = random.nextBoolean();
this.gifted = random.nextBoolean();
this.viewerCount = random.nextInt(100 - 1) + 1;
this.raiderCount = random.nextInt(100 - 1) + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public enum TSLPredicateProperty {
"subscriptionTier",
"tier", "subscription_tier"
),
IS_GIFTER(
"isGifted",
"is_gifted"
GIFTED(
"gifted",
"gifted"
),
VIEWERS(
"viewerCount",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static String fromArgs(String expression, EventArguments args) {
return args.subscriptionTier == 0 ? "Prime" : String.valueOf(args.subscriptionTier);

if (expression.equals("is_gifted"))
return String.valueOf(args.isGifted);
return String.valueOf(args.gifted);

if (expression.equals("viewers") && args.viewerCount != 0)
return String.valueOf(args.viewerCount);
Expand Down

0 comments on commit 93514f4

Please sign in to comment.