Started work on #1
This commit is contained in:
48
TwitchDesktopNotifications/Core/NotifyManager.cs
Normal file
48
TwitchDesktopNotifications/Core/NotifyManager.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TwitchDesktopNotifications.JsonStructure.Helix;
|
||||||
|
|
||||||
|
namespace TwitchDesktopNotifications.Core
|
||||||
|
{
|
||||||
|
internal class NotifyManager
|
||||||
|
{
|
||||||
|
|
||||||
|
public Boolean shouldNotify(String streamerName)
|
||||||
|
{
|
||||||
|
return notifyAll || !DataStore.GetInstance().Store.SteamersToNotify.Streamers.Contains(streamerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddStreamerToNotifyList(String streamerName)
|
||||||
|
{
|
||||||
|
DataStore.GetInstance().Store.SteamersToNotify.Streamers.Add(streamerName);
|
||||||
|
DataStore.GetInstance().Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveStreamerToNotifyList(String streamerName)
|
||||||
|
{
|
||||||
|
DataStore.GetInstance().Store.SteamersToNotify.Streamers.Remove(streamerName);
|
||||||
|
DataStore.GetInstance().Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearListOfEnabled()
|
||||||
|
{
|
||||||
|
DataStore.GetInstance().Store.SteamersToNotify.Streamers = new List<string>();
|
||||||
|
DataStore.GetInstance().Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool notifyAll
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DataStore.GetInstance().Store.SteamersToNotify.notifyAll;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
DataStore.GetInstance().Store.SteamersToNotify.notifyAll = value;
|
||||||
|
DataStore.GetInstance().Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -126,7 +126,14 @@ namespace TwitchDesktopNotifications.Core
|
|||||||
currentlyLive = following.Data;
|
currentlyLive = following.Data;
|
||||||
}catch(System.Exception ex)
|
}catch(System.Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Twitch Connection not authenticated you need to Reconnect it.", "Twitch Notify");
|
if (!ex.Message.Contains("Notification"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Twitch Connection not authenticated you need to Reconnect it.", "Twitch Notify");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Unable to use Windows Notifications.", "Twitch Notify");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
TwitchDesktopNotifications/JsonStructure/SteamersToNotify.cs
Normal file
13
TwitchDesktopNotifications/JsonStructure/SteamersToNotify.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace TwitchDesktopNotifications.JsonStructure
|
||||||
|
{
|
||||||
|
internal class SteamersToNotify
|
||||||
|
{
|
||||||
|
[JsonPropertyName("notifyAll")]
|
||||||
|
public Boolean notifyAll = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("notify")]
|
||||||
|
public List<String> Streamers { get; set; } = new List<String>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,5 +17,8 @@ namespace TwitchDesktopNotifications.JsonStructure
|
|||||||
|
|
||||||
[JsonPropertyName("user_data")]
|
[JsonPropertyName("user_data")]
|
||||||
public UserData UserData { get; set; }
|
public UserData UserData { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("notifications_for")]
|
||||||
|
public SteamersToNotify SteamersToNotify { get; set; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user