forked from adam/discord-bot-shtik
see #55
This commit is contained in:
parent
323d6fa521
commit
736fc3643b
44
Behavior/Ripcord.cs
Normal file
44
Behavior/Ripcord.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -40,15 +40,10 @@ public class TwitchSummon : Behavior
|
|||||||
{
|
{
|
||||||
if (!base.ShouldAct(message, matchedUACs))
|
if (!base.ShouldAct(message, matchedUACs))
|
||||||
return false;
|
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($"myUAC: {myUAC} users: {myUAC?.Users?.Count()}. message author: {message?.Author}. has an IsUser: {message?.Author?.IsUser}.");
|
||||||
Console.WriteLine($"and therefore: {uacConf.Users.Contains(message.Author.IsUser)}");
|
Console.WriteLine($"and therefore: {myUAC.Users.Contains(message.Author.IsUser)}");
|
||||||
return uacConf.Users.Contains(message.Author.IsUser);
|
return myUAC.Users.Contains(message.Author.IsUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
|
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
|
||||||
|
using vassago;
|
||||||
using vassago.Models;
|
using vassago.Models;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@ -45,4 +46,6 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shared.App = app;
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
@ -13,4 +13,5 @@ public static class Shared
|
|||||||
public static bool SetupSlashCommands { get; set; }
|
public static bool SetupSlashCommands { get; set; }
|
||||||
public static Uri API_URL { get; set; }
|
public static Uri API_URL { get; set; }
|
||||||
public static List<ProtocolInterface> ProtocolList { get; set; } = new();
|
public static List<ProtocolInterface> ProtocolList { get; set; } = new();
|
||||||
|
public static WebApplication App { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -37,24 +37,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Translations (@Model.Translations?.Count)</th>
|
<th scope="row">Translations (@Model.Translations?.Count)</th>
|
||||||
<td>
|
<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">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
@{ var i = 0; }
|
@Html.Raw("<tr>");
|
||||||
@foreach(var kvp in Model.Translations)
|
@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>");
|
||||||
i++;
|
@Html.Raw("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"removeTranslation()\">delete</button></td>");
|
||||||
if(String.IsNullOrWhiteSpace(kvp.Key) || String.IsNullOrWhiteSpace(kvp.Value))
|
@Html.Raw("</tr>");
|
||||||
{
|
|
||||||
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>");
|
|
||||||
}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<button type="button" class="btn btn-primary" onclick="addUAC_Translation()">add translation</button>
|
<button type="button" class="btn btn-primary" onclick="addUAC_Translation()">add translation</button>
|
||||||
@ -69,21 +59,13 @@
|
|||||||
<td>
|
<td>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
@{
|
@Html.Raw("<tr><td colspan=\"3\">o_O</td></tr>");
|
||||||
var j = 0;
|
@Html.Raw("<tr>");
|
||||||
foreach(var kvp in Model.CommandAlterations.ToList())
|
@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>");
|
||||||
j++;
|
@Html.Raw("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"removeCommandAlteration()\">delete</button></td>");
|
||||||
Html.Raw(j);
|
@Html.Raw("</tr>");
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<button type="button" class="btn btn-primary" onclick="addUAC_CommandAlteration()">add alteration</button>
|
<button type="button" class="btn btn-primary" onclick="addUAC_CommandAlteration()">add alteration</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user