Big update introducing ghetto command interface, settings, database and howl.gg bet feed scraping

This commit is contained in:
barelyprofessional
2024-07-18 01:37:15 +10:00
parent 936bf743a5
commit d61a171e54
46 changed files with 2198 additions and 218 deletions

View File

@@ -0,0 +1,13 @@
namespace KfChatDotNetKickBot.Models;
public class BuiltInSettingsModel
{
// Model here largely maps to what's in SettingDbModel, the idea is that there's a set of built-in settings that get
// populated when migrating old JSON configs and updated on start if there's a schema change (e.g. regex changed)
public required string Key { get; set; }
public required string Regex { get; set; }
public required string Description { get; set; }
public string? Default { get; set; }
public required bool IsSecret { get; set; }
}

View File

@@ -1,5 +1,6 @@
namespace KfChatDotNetKickBot.Models;
[Obsolete]
public class ConfigModel
{
public Uri PusherEndpoint { get; set; } =

View File

@@ -0,0 +1,17 @@
namespace KfChatDotNetKickBot.Models.DbModels;
public class HowlggBetsDbModel
{
public int Id { get; set; }
public required int UserId { get; set; }
// Per-user bet ID, counts up based on total # of bets
public required int BetId { get; set; }
// Global bet ID
public required long GameId { get; set; }
// Cents
public required long Bet { get; set; }
// Cents
public required long Profit { get; set; }
public required DateTimeOffset Date { get; set; }
public required string Game { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace KfChatDotNetKickBot.Models.DbModels;
public class JuicerDbModel
{
public int Id { get; set; }
public required UserDbModel User { get; set; }
public float Amount { get; set; }
public DateTimeOffset JuicedAt { get; set; }
}

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace KfChatDotNetKickBot.Models.DbModels;
public class SettingDbModel
{
public int Id { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public required string Key { get; set; }
public string? Value { get; set; }
// For validation
public required string Regex { get; set; } = @"\S+";
// Friendly descriptor for the setting, e.g. "BossmanJack's howl.gg ID"
public required string Description { get; set; }
// Default to use when constructing the setting and nothing is supplied
public string? Default { get; set; } = null;
// Prevents the value from being revealed to Sneedchat when queried by an admin
public bool IsSecret { get; set; } = false;
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel;
namespace KfChatDotNetKickBot.Models.DbModels;
public class UserDbModel
{
public int Id { get; set; }
public required string KfUsername { get; set; }
public int KfId { get; set; }
public UserRight UserRight { get; set; } = UserRight.Guest;
public bool Ignored { get; set; } = false;
}
public enum UserRight
{
Admin = 1000,
[Description("True and Honest")]
TrueAndHonest = 100,
Guest = 10,
Loser = 0
}

View File

@@ -0,0 +1,50 @@
using System.Text.Json.Serialization;
namespace KfChatDotNetKickBot.Models;
public class HowlggBetHistoryResponseModel
{
[JsonPropertyName("user")]
public required HowlggUserModel User { get; set; }
[JsonPropertyName("history")]
public required HowlggHistoryModel History { get; set; }
}
public class HowlggUserModel
{
[JsonPropertyName("id")]
public required int Id { get; set; }
[JsonPropertyName("name")]
public required string Name { get; set; }
[JsonPropertyName("createdAt")]
public required DateTimeOffset CreatedAt { get; set; }
[JsonPropertyName("netProfit")]
public long NetProfit { get; set; }
}
public class HowlggHistoryModel
{
[JsonPropertyName("profit")]
public required long Profit { get; set; }
[JsonPropertyName("cumulative")]
public required long Cumulative { get; set; }
[JsonPropertyName("data")]
public required List<HowlggHistoryDataModel> Data { get; set; }
}
public class HowlggHistoryDataModel
{
[JsonPropertyName("id")]
public required int Id { get; set; }
[JsonPropertyName("bet")]
public required long Bet { get; set; }
[JsonPropertyName("date")]
// For some reason it has a +2 offset
public required DateTimeOffset Date { get; set; }
[JsonPropertyName("game")]
public required string Game { get; set; }
[JsonPropertyName("gameId")]
public required long GameId { get; set; }
[JsonPropertyName("profit")]
public required long Profit { get; set; }
}

View File

@@ -0,0 +1,26 @@
namespace KfChatDotNetKickBot.Models;
public class PocketWatchModel
{
public required string Network { get; set; }
public required string Address { get; set; }
public required string Label { get; set; }
public required bool BypassGambaSeshPresenceDetection { get; set; }
public required int CheckIntervalSec { get; set; }
// Used internally to detect new transactions
public required DateTime LastChecked { get; set; } = DateTime.Now;
}
public class PocketWatchEventModel
{
public required string TransactionHash { get; set; }
public required DateTimeOffset Time { get; set; }
public required string Currency { get; set; }
public required string Effect { get; set; }
public required string Network { get; set; }
public required string Address { get; set; }
public required long Balance { get; set; }
public required float UsdRate { get; set; }
public required bool IsMempool { get; set; }
public required PocketWatchModel PocketWatch { get; set; }
}

View File

@@ -0,0 +1,48 @@
using System.Text.Json.Serialization;
namespace KfChatDotNetKickBot.Models;
public class ThreeXplEventModel
{
[JsonPropertyName("block")]
public int? Block { get; set; }
[JsonPropertyName("transaction")]
public required string TransactionHash { get; set; }
[JsonPropertyName("sort_key")]
public int? SortKey { get; set; }
[JsonPropertyName("time")]
public DateTimeOffset? Time { get; set; }
[JsonPropertyName("currency")]
public required string Currency { get; set; }
[JsonPropertyName("effect")]
public required string Effect { get; set; }
[JsonPropertyName("failed")]
public bool? Failed { get; set; }
[JsonPropertyName("extra")]
public string? Extra { get; set; }
}
public class ThreeXplCurrencyModel
{
[JsonPropertyName("name")]
public required string Name { get; set; }
[JsonPropertyName("type")]
public string? Type { get; set; }
[JsonPropertyName("symbol")]
public required string Symbol { get; set; }
[JsonPropertyName("decimals")]
public required int Decimals { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
}
public class ThreeXplAddressModel
{
[JsonPropertyName("address")]
public required string Address { get; set; }
[JsonPropertyName("balances")]
public required Dictionary<string, int?> Balances { get; set; }
[JsonPropertyName("events")]
public required Dictionary<string, int?> Events { get; set; }
}