stop button
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good

see #55
This commit is contained in:
adam 2025-06-22 14:13:22 -04:00
parent 323d6fa521
commit 736fc3643b
5 changed files with 65 additions and 40 deletions

44
Behavior/Ripcord.cs Normal file
View File

@ -0,0 +1,44 @@
namespace vassago.Behavior;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using vassago.Models;
[StaticPlz]
public class Ripcord: Behavior
{
public override string Name => "Stop Button";
public override string Trigger => "!ripcord";
private static Guid uacID = new Guid("e00b0522-5ac1-46f2-b5e8-8b791692a746");
private static UAC myUAC;
public Ripcord()
{
myUAC = Rememberer.SearchUAC(uac => uac.OwnerId == uacID);
if (myUAC == null)
{
myUAC = new()
{
OwnerId = uacID,
DisplayName = Name,
Description = @"matching this means you can tell the bot to shutdown, now"
};
}
Rememberer.RememberUAC(myUAC);
}
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
{
if (!base.ShouldAct(message, matchedUACs))
return false;
return myUAC.Users.Contains(message.Author.IsUser);
}
public override async Task<bool> ActOn(Message message)
{
Behaver.Instance.SendMessage(message.Channel.Id, "daisy, dai.. sy....");
Shared.App.StopAsync();
return true;
}
}

View File

@ -40,15 +40,10 @@ public class TwitchSummon : Behavior
{
if (!base.ShouldAct(message, matchedUACs))
return false;
var uacConf = Rememberer.SearchUAC(uac => uac.OwnerId == uacID);
if (uacConf == null)
{
Console.Error.WriteLine("no UAC conf for TwitchSummon! Set one up!");
}
Console.WriteLine($"uacConf: {uacConf} users: {uacConf?.Users?.Count()}. message author: {message?.Author}. has an IsUser: {message?.Author?.IsUser}.");
Console.WriteLine($"and therefore: {uacConf.Users.Contains(message.Author.IsUser)}");
return uacConf.Users.Contains(message.Author.IsUser);
Console.WriteLine($"myUAC: {myUAC} users: {myUAC?.Users?.Count()}. message author: {message?.Author}. has an IsUser: {message?.Author?.IsUser}.");
Console.WriteLine($"and therefore: {myUAC.Users.Contains(message.Author.IsUser)}");
return myUAC.Users.Contains(message.Author.IsUser);
}
public override async Task<bool> ActOn(Message message)

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
using vassago;
using vassago.Models;
var builder = WebApplication.CreateBuilder(args);
@ -45,4 +46,6 @@ if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
}
Shared.App = app;
app.Run();

View File

@ -13,4 +13,5 @@ public static class Shared
public static bool SetupSlashCommands { get; set; }
public static Uri API_URL { get; set; }
public static List<ProtocolInterface> ProtocolList { get; set; } = new();
public static WebApplication App { get; set; }
}

View File

@ -37,24 +37,14 @@
<tr>
<th scope="row">Translations (@Model.Translations?.Count)</th>
<td>
next will be iterating over a dictionary. All reference on the internet implies this should work. And I'm sick of trying to figure out why it doens't.
next would be iterating over a dictionary. All reference on the internet implies this should work. I'm sick of trying to figure out why it doesn't. razor says to me, so i say to you: go fuck yourself; edit the db manually.
<table class="table">
<tbody>
@{ var i = 0; }
@foreach(var kvp in Model.Translations)
{
i++;
if(String.IsNullOrWhiteSpace(kvp.Key) || String.IsNullOrWhiteSpace(kvp.Value))
{
continue;
}
Html.Raw("<tr><td colspan=\"3\">o_O</td></tr>");
Html.Raw("<tr>");
Html.Raw("<td><input type=\"text\" name=\"Model.Translations[{i}].Key\" value=\"{Model.Translations.ElementAt(i).Key}\" /></td>");
Html.Raw("<td><input type=\"text\" name=\"Model.Translations[{i}].Value\" value=\"{Model.Translations.ElementAt(i).Value}\" /></td>");
Html.Raw("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"removeTranslation()\">delete</button></td>");
Html.Raw("</tr>");
}
@Html.Raw("<tr>");
@Html.Raw("<td><input type=\"text\" name=\"Model.Translations[{i}].Key\" value=\"{Model.Translations.ElementAt(i).Key}\" /></td>");
@Html.Raw("<td><input type=\"text\" name=\"Model.Translations[{i}].Value\" value=\"{Model.Translations.ElementAt(i).Value}\" /></td>");
@Html.Raw("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"removeTranslation()\">delete</button></td>");
@Html.Raw("</tr>");
<tr>
<td colspan="3">
<button type="button" class="btn btn-primary" onclick="addUAC_Translation()">add translation</button>
@ -69,21 +59,13 @@
<td>
<table class="table">
<tbody>
@{
var j = 0;
foreach(var kvp in Model.CommandAlterations.ToList())
{
j++;
Html.Raw(j);
Html.Raw("<tr><td colspan=\"3\">o_O</td></tr>");
Html.Raw("<tr>");
Html.Raw("<td><input type=\"text\" name=\"Model.CommandAlterations[{j}].Key\" value=\"{Model.CommandAlterations.ElementAt(j).Key}\" /></td>");
Html.Raw("<td><input type=\"text\" name=\"Model.CommandAlterations[{j}].Value\" value=\"{Model.CommandAlterations.ElementAt(j).Value}\" /></td>");
Html.Raw("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"removeCommandAlteration()\">delete</button></td>");
Html.Raw("</tr>");
j++;
}
}
@Html.Raw("<tr><td colspan=\"3\">o_O</td></tr>");
@Html.Raw("<tr>");
@Html.Raw("<td><input type=\"text\" name=\"Model.CommandAlterations[{j}].Key\" value=\"{Model.CommandAlterations.ElementAt(j).Key}\" /></td>");
@Html.Raw("<td><input type=\"text\" name=\"Model.CommandAlterations[{j}].Value\" value=\"{Model.CommandAlterations.ElementAt(j).Value}\" /></td>");
@Html.Raw("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"removeCommandAlteration()\">delete</button></td>");
@Html.Raw("</tr>");
<tr>
<td colspan="3">
<button type="button" class="btn btn-primary" onclick="addUAC_CommandAlteration()">add alteration</button>