-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds support for hypetrain events Progression and LevelUp
- Loading branch information
1 parent
f833b1a
commit ce3b174
Showing
12 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Enums | ||
{ | ||
public enum HypeTrainEventType | ||
{ | ||
Progression, | ||
LevelUp | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using TwitchLib.PubSub.Models.Responses.Messages.HypeTrain; | ||
|
||
namespace TwitchLib.PubSub.Events | ||
{ | ||
public class OnHypeTrainLevelUp | ||
{ | ||
/// <summary> | ||
/// Details about the hype train level up event. | ||
/// </summary> | ||
public HypeTrainLevelUp LevelUp; | ||
/// <summary> | ||
/// The ID of the channel that this event fired from. | ||
/// </summary> | ||
public string ChannelId; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using TwitchLib.PubSub.Models.Responses.Messages.HypeTrain; | ||
|
||
namespace TwitchLib.PubSub.Events | ||
{ | ||
public class OnHypeTrainProgressionArgs | ||
{ | ||
/// <summary> | ||
/// Details about the hype train. | ||
/// </summary> | ||
public HypeTrainProgression Progression; | ||
/// <summary> | ||
/// The ID of the channel that this event fired from. | ||
/// </summary> | ||
public string ChannelId; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/HypeTrainEvent.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using TwitchLib.PubSub.Enums; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public class HypeTrainEvent : MessageData | ||
{ | ||
public HypeTrainEventType Type { get; protected set; } | ||
public HypeTrainEventData Data { get; protected set; } | ||
|
||
|
||
public HypeTrainEvent(string jsonStr) | ||
{ | ||
JToken json = JObject.Parse(jsonStr); | ||
switch (json.SelectToken("type").ToString()) | ||
{ | ||
case "hype-train-progression": | ||
Type = HypeTrainEventType.Progression; | ||
Data = json["data"].ToObject<HypeTrainProgression>(); | ||
break; | ||
case "hype-train-level-up": | ||
Type = HypeTrainEventType.LevelUp; | ||
Data = json["data"].ToObject<HypeTrainLevelUp>(); | ||
break; | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/HypeTrainEventData.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public abstract class HypeTrainEventData | ||
{ | ||
// Leave empty for now | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/HypeTrainLevelUp.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public class HypeTrainLevelUp : HypeTrainEventData | ||
{ | ||
[JsonProperty(PropertyName = "time_to_expire")] | ||
public long TimeToExpire { get; protected set; } | ||
[JsonProperty(PropertyName = "progress")] | ||
public Progress Progress { get; protected set; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/HypeTrainProgression.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public class HypeTrainProgression : HypeTrainEventData | ||
{ | ||
[JsonProperty(PropertyName = "user_id")] | ||
public string UserId { get; protected set; } | ||
[JsonProperty(PropertyName = "sequence_id")] | ||
public int SequenceId { get; protected set; } | ||
[JsonProperty(PropertyName = "action")] | ||
public string Action { get; protected set; } | ||
[JsonProperty(PropertyName = "source")] | ||
public string Source { get; protected set; } | ||
[JsonProperty(PropertyName = "quantity")] | ||
public int Quantity { get; protected set; } | ||
[JsonProperty(PropertyName = "progress")] | ||
public Progress Progress { get; protected set; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/Level.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public class Level | ||
{ | ||
[JsonProperty(PropertyName = "value")] | ||
public int Value { get; protected set; } | ||
[JsonProperty(PropertyName = "goal")] | ||
public int Goal { get; protected set; } | ||
[JsonProperty(PropertyName = "rewards")] | ||
public Reward[] Rewards { get; protected set; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/Progress.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public class Progress | ||
{ | ||
[JsonProperty(PropertyName = "level")] | ||
public Level Level { get; protected set; } | ||
[JsonProperty(PropertyName = "value")] | ||
public int Value { get; protected set; } | ||
[JsonProperty(PropertyName = "goal")] | ||
public int Goal { get; protected set; } | ||
[JsonProperty(PropertyName = "total")] | ||
public int Total { get; protected set; } | ||
[JsonProperty(PropertyName = "remaining_seconds")] | ||
public int RemainingSeconds { get; protected set; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
TwitchLib.PubSub/Models/Responses/Messages/HypeTrain/Reward.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace TwitchLib.PubSub.Models.Responses.Messages.HypeTrain | ||
{ | ||
public class Reward | ||
{ | ||
[JsonProperty(PropertyName = "id")] | ||
public string Id { get; protected set; } | ||
[JsonProperty(PropertyName = "type")] | ||
public string Type { get; protected set; } | ||
[JsonProperty(PropertyName = "group_id")] | ||
public string GroupId { get; protected set; } | ||
[JsonProperty(PropertyName = "reward_level")] | ||
public int RewardLevel { get; protected set; } | ||
} | ||
} |
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