First commit with progress so far

This commit is contained in:
Tom
2023-12-30 09:27:31 +00:00
commit 72be20594d
575 changed files with 23496 additions and 0 deletions

View File

@ -0,0 +1,9 @@
using System.Diagnostics.CodeAnalysis;
[Serializable]
public class Account {
[AllowNull]
public string id { get; set; }
[AllowNull]
public string username { get; set; }
}

View File

@ -0,0 +1,37 @@
using System;
public class HermesClient {
private Account account;
private string key;
public string Id { get => account?.id; }
public string Username { get => account?.username; }
public HermesClient() {
// Read API Key from file.
if (!File.Exists(".token")) {
throw new Exception("Ensure you have written your API key in \".token\" file, in the same folder as this application.");
}
key = File.ReadAllText(".token")?.Trim();
WebHelper.AddHeader("x-api-key", key);
}
public async Task UpdateHermesAccount() {
account = await WebHelper.GetJson<Account>("https://hermes.goblincaves.com/api/account");
}
public async Task<TwitchBotToken> FetchTwitchBotToken() {
if (string.IsNullOrWhiteSpace(key)) {
throw new InvalidOperationException("Hermes API key not provided.");
}
var token = await WebHelper.GetJson<TwitchBotToken>("https://hermes.goblincaves.com/api/token/bot");
if (token == null) {
throw new Exception("Failed to fetch Twitch API token from Hermes.");
}
return token;
}
}

View File

@ -0,0 +1,8 @@
[Serializable]
public class TwitchBotToken {
public string client_id { get; set; }
public string client_secret { get; set; }
public string access_token { get; set; }
public string refresh_token { get; set; }
public string broadcaster_id { get; set; }
}

View File

@ -0,0 +1,8 @@
[Serializable]
public class TwitchConnection {
public string id { get; set; }
public string secret { get; set; }
public string broadcasterId { get; set; }
public string username { get; set; }
public string userId { get; set; }
}