mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 20:42:04 -04:00
Big update introducing ghetto command interface, settings, database and howl.gg bet feed scraping
This commit is contained in:
15
KfChatDotNetKickBot/Commands/ICommand.cs
Normal file
15
KfChatDotNetKickBot/Commands/ICommand.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetKickBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetKickBot.Commands;
|
||||
|
||||
internal interface ICommand
|
||||
{
|
||||
List<Regex> Patterns { get; }
|
||||
string HelpText { get; }
|
||||
bool HideFromHelp { get; }
|
||||
UserRight RequiredRight { get; }
|
||||
|
||||
Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx);
|
||||
}
|
||||
46
KfChatDotNetKickBot/Commands/JuiceCommand.cs
Normal file
46
KfChatDotNetKickBot/Commands/JuiceCommand.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetKickBot.Models.DbModels;
|
||||
using KfChatDotNetKickBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace KfChatDotNetKickBot.Commands;
|
||||
|
||||
public class JuiceCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns { get; } = [new Regex("^juiceme$")];
|
||||
public string HelpText => "Get juice!";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
var user = await db.Users.FirstOrDefaultAsync(u => u.KfId == message.Author.Id, cancellationToken: ctx);
|
||||
if (user == null) return;
|
||||
var juicerSettings = await Helpers.GetMultipleValues([BuiltIn.Keys.JuiceAmount, BuiltIn.Keys.JuiceCooldown]);
|
||||
var cooldown = juicerSettings[BuiltIn.Keys.JuiceCooldown].ToType<int>();
|
||||
var amount = juicerSettings[BuiltIn.Keys.JuiceAmount].ToType<int>();
|
||||
var lastJuicer = (await db.Juicers.Where(j => j.User == user).ToListAsync(ctx)).OrderByDescending(j => j.JuicedAt).Take(1).ToList();
|
||||
if (lastJuicer.Count == 0)
|
||||
{
|
||||
botInstance.SendChatMessage($"!juice {message.Author.Id} {amount}", true);
|
||||
await db.Juicers.AddAsync(new JuicerDbModel
|
||||
{ Amount = amount, User = user, JuicedAt = DateTimeOffset.UtcNow }, ctx);
|
||||
await db.SaveChangesAsync(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
var secondsRemaining = lastJuicer[0].JuicedAt.AddSeconds(cooldown) - DateTimeOffset.UtcNow;
|
||||
if (secondsRemaining.TotalSeconds <= 0)
|
||||
{
|
||||
botInstance.SendChatMessage($"!juice {message.Author.Id} {amount}", true);
|
||||
await db.Juicers.AddAsync(new JuicerDbModel
|
||||
{ Amount = amount, User = user, JuicedAt = DateTimeOffset.UtcNow }, ctx);
|
||||
await db.SaveChangesAsync(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
botInstance.SendChatMessage($"You gotta wait {secondsRemaining.Humanize(precision: 2)} for another juicer", true);
|
||||
}
|
||||
}
|
||||
61
KfChatDotNetKickBot/Commands/MemeCommands.cs
Normal file
61
KfChatDotNetKickBot/Commands/MemeCommands.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetKickBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetKickBot.Commands;
|
||||
|
||||
public class InsanityCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^insanity")];
|
||||
public string HelpText => "Insanity";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
botInstance.SendChatMessage("definition of insanity = doing the same thing over and over and over excecting a different result, and heres my dumbass trying to get rich every day and losing everythign i fucking touch every fucking time FUCK this bullshit FUCK MY LIEFdefinition of insanity = doing the same thing over and over and over excecting a different result, and heres my dumbass trying to get rich every day and losing everythign i fucking touch every fucking time FUCK this bullshit FUCK MY LIEF");
|
||||
}
|
||||
}
|
||||
|
||||
public class TwistedCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^twisted")];
|
||||
public string HelpText => "Get it twisted";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
botInstance.SendChatMessage("🦍 🗣 GET IT TWISTED 🌪 , GAMBLE ✅ . PLEASE START GAMBLING 👍 . GAMBLING IS AN INVESTMENT 🎰 AND AN INVESTMENT ONLY 👍 . YOU WILL PROFIT 💰 , YOU WILL WIN ❗ ️. YOU WILL DO ALL OF THAT 💯 , YOU UNDERSTAND ⁉ ️ YOU WILL BECOME A BILLIONAIRE 💵 📈 AND REBUILD YOUR FUCKING LIFE 🤯");
|
||||
}
|
||||
}
|
||||
|
||||
public class HelpMeCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^helpme")];
|
||||
public string HelpText => "Somebody please help me";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
botInstance.SendChatMessage("[img]https://i.postimg.cc/fTw6tGWZ/ineedmoneydumbfuck.png[/img]", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class SentCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^sent$")];
|
||||
public string HelpText => "Sent love";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
botInstance.SendChatMessage("[img]https://i.ibb.co/GHq7hb1/4373-g-N5-HEH2-Hkc.png[/img]", true);
|
||||
}
|
||||
}
|
||||
20
KfChatDotNetKickBot/Commands/TimeCommand.cs
Normal file
20
KfChatDotNetKickBot/Commands/TimeCommand.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetKickBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetKickBot.Commands;
|
||||
|
||||
public class TimeCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^time")];
|
||||
public string HelpText => "Get current time in BMT";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var bmt = new DateTimeOffset(TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow,
|
||||
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")), TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").BaseUtcOffset);
|
||||
botInstance.SendChatMessage($"It's currently {bmt:h:mm:ss tt} BMT");
|
||||
}
|
||||
}
|
||||
30
KfChatDotNetKickBot/Commands/WhoisCommand.cs
Normal file
30
KfChatDotNetKickBot/Commands/WhoisCommand.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetKickBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace KfChatDotNetKickBot.Commands;
|
||||
|
||||
public class WhoisCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^whois (?<user>.+)")
|
||||
];
|
||||
|
||||
public string HelpText => "Lookup user IDs by username";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
|
||||
public async Task RunCommand(KickBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
var query = arguments["user"].Value.TrimStart('@').TrimEnd(',').TrimEnd();
|
||||
var user = await db.Users.FirstOrDefaultAsync(u => u.KfUsername == query, cancellationToken: ctx);
|
||||
if (user == null)
|
||||
{
|
||||
botInstance.SendChatMessage($"Requested user '{query}' does not exist. (Note this is case-sensitive)", true);
|
||||
return;
|
||||
}
|
||||
botInstance.SendChatMessage($"@{message.Author.Username}, {user.KfUsername}'s ID is {user.KfId}", true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user