mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Renamed the bot from KickBot -> ChatBot and removed the reference to Kick in the project name
This commit is contained in:
63
KfChatDotNetBot/Commands/HowlggCommands.cs
Normal file
63
KfChatDotNetBot/Commands/HowlggCommands.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace KfChatDotNetBot.Commands;
|
||||
|
||||
public class HowlggStatsCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex(@"^howl stats (?<window>\d+)$")
|
||||
];
|
||||
public string HelpText => "Get betting statistics in the given window";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var window = Convert.ToInt32(arguments["window"].Value);
|
||||
var start = DateTimeOffset.UtcNow.AddHours(-window);
|
||||
var division = (await Helpers.GetValue(BuiltIn.Keys.HowlggDivisionAmount)).ToType<float>();
|
||||
await using var db = new ApplicationDbContext();
|
||||
// EF SQLite doesn't support filtering on dates :(
|
||||
var bets = (await db.HowlggBets.ToListAsync(ctx)).Where(b => b.Date.UtcDateTime > start).ToList();
|
||||
if (bets.Count == 0)
|
||||
{
|
||||
botInstance.SendChatMessage("No bets captured during this window", true);
|
||||
return;
|
||||
}
|
||||
var output = $"Howl.gg stats for the last {window} hours:[br]" +
|
||||
$"Bets: {bets.Count:N0}; Profit: {bets.Sum(b => b.Profit) / division:C}; Wagered: {bets.Sum(b => b.Bet) / division:C}";
|
||||
botInstance.SendChatMessage(output, true);
|
||||
}
|
||||
}
|
||||
|
||||
public class HowlggRecentBetCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex(@"^howl recent$")
|
||||
];
|
||||
public string HelpText => "Get the most recent 3 bets";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings = await Helpers.GetMultipleValues([
|
||||
BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor, BuiltIn.Keys.HowlggDivisionAmount
|
||||
]);
|
||||
var division = settings[BuiltIn.Keys.HowlggDivisionAmount].ToType<float>();
|
||||
await using var db = new ApplicationDbContext();
|
||||
// EF SQLite doesn't support filtering on dates :(
|
||||
var bets = (await db.HowlggBets.ToListAsync(ctx)).OrderByDescending(j => j.Date).Take(3).ToList();
|
||||
var output = "Most recent 3 bets on Howl.gg:";
|
||||
foreach (var bet in bets)
|
||||
{
|
||||
var color = settings[BuiltIn.Keys.KiwiFarmsGreenColor].Value;
|
||||
if (bet.Profit < 0) color = settings[BuiltIn.Keys.KiwiFarmsRedColor].Value;
|
||||
output += $"[br]Bet: {bet.Bet / division:C}; Profit: [color={color}]{bet.Profit / division:C}[/color]; Game: {bet.Game.Humanize()}; {(DateTimeOffset.UtcNow - bet.Date).Humanize(precision: 1)} ago";
|
||||
}
|
||||
botInstance.SendChatMessage(output, true);
|
||||
}
|
||||
}
|
||||
15
KfChatDotNetBot/Commands/ICommand.cs
Normal file
15
KfChatDotNetBot/Commands/ICommand.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetBot.Commands;
|
||||
|
||||
internal interface ICommand
|
||||
{
|
||||
List<Regex> Patterns { get; }
|
||||
string HelpText { get; }
|
||||
bool HideFromHelp { get; }
|
||||
UserRight RequiredRight { get; }
|
||||
|
||||
Task RunCommand(ChatBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx);
|
||||
}
|
||||
46
KfChatDotNetBot/Commands/JuiceCommand.cs
Normal file
46
KfChatDotNetBot/Commands/JuiceCommand.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace KfChatDotNetBot.Commands;
|
||||
|
||||
public class JuiceCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^juiceme")];
|
||||
public string HelpText => "Get juice!";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public async Task RunCommand(ChatBot 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
KfChatDotNetBot/Commands/MemeCommands.cs
Normal file
61
KfChatDotNetBot/Commands/MemeCommands.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetBot.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(ChatBot 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(ChatBot 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(ChatBot 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(ChatBot 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
KfChatDotNetBot/Commands/TimeCommand.cs
Normal file
20
KfChatDotNetBot/Commands/TimeCommand.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetBot.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(ChatBot 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
KfChatDotNetBot/Commands/WhoisCommand.cs
Normal file
30
KfChatDotNetBot/Commands/WhoisCommand.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace KfChatDotNetBot.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(ChatBot 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