forked from adam/discord-bot-shtik
localizations. command aliases.
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
see #19. see #9.
This commit is contained in:
parent
db5fa4dd7c
commit
92988257b6
21
Behaver.cs
21
Behaver.cs
@ -45,11 +45,21 @@ public class Behaver
|
|||||||
{
|
{
|
||||||
//TODO: this is yet another hit to the database, and a big one. cache them in memory! there needs to be a feasibly-viewable amount, anyway.
|
//TODO: this is yet another hit to the database, and a big one. cache them in memory! there needs to be a feasibly-viewable amount, anyway.
|
||||||
var matchingUACs = Rememberer.MatchUACs(message);
|
var matchingUACs = Rememberer.MatchUACs(message);
|
||||||
|
message.TranslatedContent = message.Content;
|
||||||
|
foreach (var uacMatch in matchingUACs)
|
||||||
|
{
|
||||||
|
uacMatch.Translations ??= [];
|
||||||
|
uacMatch.CommandAlterations ??= [];
|
||||||
|
foreach (var localization in uacMatch.Translations) //honestly, i'm *still* mad that foreach thing in null is an exception. in what world is "if not null then" assumed?
|
||||||
|
{
|
||||||
|
var r = new Regex(localization.Key);
|
||||||
|
message.TranslatedContent = r.Replace(message.TranslatedContent, localization.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
var behaviorsActedOn = new List<string>();
|
var behaviorsActedOn = new List<string>();
|
||||||
foreach (var behavior in Behaviors.ToList())
|
foreach (var behavior in Behaviors.ToList())
|
||||||
{
|
{
|
||||||
//if (!behavior.ShouldAct(message, matchingUACs)) //TODO: this way
|
if (!behavior.ShouldAct(message, matchingUACs))
|
||||||
if (!behavior.ShouldAct(message))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -58,7 +68,7 @@ public class Behaver
|
|||||||
behaviorsActedOn.Add(behavior.ToString());
|
behaviorsActedOn.Add(behavior.ToString());
|
||||||
Console.WriteLine("acted on, moving forward");
|
Console.WriteLine("acted on, moving forward");
|
||||||
}
|
}
|
||||||
if (message.ActedOn == false && message.MentionsMe && message.Content.Contains('?') && !Behaver.Instance.SelfAccounts.Any(acc => acc.Id == message.Author.Id))
|
if (message.ActedOn == false && message.MentionsMe && message.TranslatedContent.Contains('?') && !Behaver.Instance.SelfAccounts.Any(acc => acc.Id == message.Author.Id))
|
||||||
{
|
{
|
||||||
Console.WriteLine("providing bullshit nonanswer / admitting uselessness");
|
Console.WriteLine("providing bullshit nonanswer / admitting uselessness");
|
||||||
var responses = new List<string>(){
|
var responses = new List<string>(){
|
||||||
@ -81,7 +91,8 @@ public class Behaver
|
|||||||
Api_Uri = Shared.API_URL,
|
Api_Uri = Shared.API_URL,
|
||||||
MessageId = message.Id,
|
MessageId = message.Id,
|
||||||
|
|
||||||
MessageContent = message.Content,
|
Content = message.TranslatedContent,
|
||||||
|
RawContent = message.Content,
|
||||||
MentionsMe = message.MentionsMe,
|
MentionsMe = message.MentionsMe,
|
||||||
Timestamp = message.Timestamp,
|
Timestamp = message.Timestamp,
|
||||||
AttachmentCount = (uint)(message.Attachments?.Count() ?? 0),
|
AttachmentCount = (uint)(message.Attachments?.Count() ?? 0),
|
||||||
@ -99,7 +110,9 @@ public class Behaver
|
|||||||
UAC_Matches = matchingUACs.Select(uac => uac.Id).ToList(),
|
UAC_Matches = matchingUACs.Select(uac => uac.Id).ToList(),
|
||||||
BehavedOnBy = actedOnBy
|
BehavedOnBy = actedOnBy
|
||||||
};
|
};
|
||||||
|
Console.WriteLine("producing message");
|
||||||
Telefranz.Instance.ProduceMessage(kafkaesque);
|
Telefranz.Instance.ProduceMessage(kafkaesque);
|
||||||
|
Console.WriteLine("survived producing message");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool IsSelf(Guid AccountId)
|
internal bool IsSelf(Guid AccountId)
|
||||||
|
@ -13,11 +13,19 @@ public abstract class Behavior
|
|||||||
//recommendation: set up your UACs in your constructor.
|
//recommendation: set up your UACs in your constructor.
|
||||||
public abstract Task<bool> ActOn(Message message);
|
public abstract Task<bool> ActOn(Message message);
|
||||||
|
|
||||||
public virtual bool ShouldAct(Message message)
|
public virtual bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if(Behaver.Instance.IsSelf(message.Author.Id))
|
if(Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
return Regex.IsMatch(message.Content, $"{Trigger}\\b", RegexOptions.IgnoreCase);
|
var triggerTarget = Trigger ;
|
||||||
|
foreach(var uacMatch in matchedUACs)
|
||||||
|
{
|
||||||
|
foreach(var substitution in uacMatch.CommandAlterations)
|
||||||
|
{
|
||||||
|
triggerTarget = new Regex(substitution.Key).Replace(triggerTarget, substitution.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Regex.IsMatch(message.TranslatedContent, $"{triggerTarget}\\b", RegexOptions.IgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
|
@ -18,12 +18,12 @@ public class DefinitionSnarkCogDiss : Behavior
|
|||||||
|
|
||||||
public override string Description => "snarkiness about the rampant misuse of the term cognitive dissonance";
|
public override string Description => "snarkiness about the rampant misuse of the term cognitive dissonance";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Medium)
|
if((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Medium)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return base.ShouldAct(message);
|
return base.ShouldAct(message, matchedUACs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
|
@ -18,12 +18,12 @@ public class DefinitionSnarkGaslight : Behavior
|
|||||||
|
|
||||||
public override string Description => "snarkiness about the rampant misuse of the term gaslighting";
|
public override string Description => "snarkiness about the rampant misuse of the term gaslighting";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Unrestricted)
|
if((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Unrestricted)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return base.ShouldAct(message);
|
return base.ShouldAct(message, matchedUACs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
|
@ -24,7 +24,7 @@ public class Detiktokify : Behavior
|
|||||||
ytdl.OutputFolder = "";
|
ytdl.OutputFolder = "";
|
||||||
ytdl.OutputFileTemplate = "tiktokbad.%(ext)s";
|
ytdl.OutputFileTemplate = "tiktokbad.%(ext)s";
|
||||||
}
|
}
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Behaver.Instance.IsSelf(message.Author.Id))
|
if (Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
@ -33,7 +33,7 @@ public class Detiktokify : Behavior
|
|||||||
if (message.Channel.EffectivePermissions.MaxAttachmentBytes == 0)
|
if (message.Channel.EffectivePermissions.MaxAttachmentBytes == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var wordLikes = message.Content.Split(' ', StringSplitOptions.TrimEntries);
|
var wordLikes = message.TranslatedContent.Split(' ', StringSplitOptions.TrimEntries);
|
||||||
var possibleLinks = wordLikes?.Where(wl => Uri.IsWellFormedUriString(wl, UriKind.Absolute)).Select(wl => new Uri(wl));
|
var possibleLinks = wordLikes?.Where(wl => Uri.IsWellFormedUriString(wl, UriKind.Absolute)).Select(wl => new Uri(wl));
|
||||||
if (possibleLinks != null && possibleLinks.Count() > 0)
|
if (possibleLinks != null && possibleLinks.Count() > 0)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ public class Detiktokify : Behavior
|
|||||||
}
|
}
|
||||||
if (tiktokLinks.Any())
|
if (tiktokLinks.Any())
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Should Act on message id {message.ExternalId}; with content {message.Content}");
|
Console.WriteLine($"Should Act on message id {message.ExternalId}; with content {message.TranslatedContent}");
|
||||||
}
|
}
|
||||||
return tiktokLinks.Any();
|
return tiktokLinks.Any();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class FiximageHeic : Behavior
|
|||||||
public override string Description => "convert heic images to jpg";
|
public override string Description => "convert heic images to jpg";
|
||||||
|
|
||||||
private List<Attachment> heics = new List<Attachment>();
|
private List<Attachment> heics = new List<Attachment>();
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if(Behaver.Instance.IsSelf(message.Author.Id))
|
if(Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,7 +17,7 @@ public class GeneralSnarkCloudNative : Behavior
|
|||||||
public override string Name => "general snarkiness: cloud native";
|
public override string Name => "general snarkiness: cloud native";
|
||||||
|
|
||||||
public override string Trigger => "certain tech buzzwords that no human uses in normal conversation";
|
public override string Trigger => "certain tech buzzwords that no human uses in normal conversation";
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if (Behaver.Instance.IsSelf(message.Author.Id))
|
if (Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
@ -28,8 +28,8 @@ public class GeneralSnarkCloudNative : Behavior
|
|||||||
if ((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Medium)
|
if ((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Medium)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Regex.IsMatch(message.Content, "\\bcloud( |-)?native\\b", RegexOptions.IgnoreCase) ||
|
return Regex.IsMatch(message.TranslatedContent, "\\bcloud( |-)?native\\b", RegexOptions.IgnoreCase) ||
|
||||||
Regex.IsMatch(message.Content, "\\benterprise( |-)?(level|solution)\\b", RegexOptions.IgnoreCase);
|
Regex.IsMatch(message.TranslatedContent, "\\benterprise( |-)?(level|solution)\\b", RegexOptions.IgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
|
@ -18,12 +18,12 @@ public class GeneralSnarkGooglit : Behavior
|
|||||||
|
|
||||||
public override string Description => "snarkiness about how research is not a solved problem";
|
public override string Description => "snarkiness about how research is not a solved problem";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if (Behaver.Instance.IsSelf(message.Author.Id))
|
if (Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Regex.IsMatch(message.Content, $"(just )?google( (it|that|things|before))\\b", RegexOptions.IgnoreCase);
|
return Regex.IsMatch(message.TranslatedContent, $"(just )?google( (it|that|things|before))\\b", RegexOptions.IgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
|
@ -32,7 +32,7 @@ public class GeneralSnarkMisspellDefinitely : Behavior
|
|||||||
{"defineatly", "only the gods know"},
|
{"defineatly", "only the gods know"},
|
||||||
{"definitly", "unless someone cute shows up"}
|
{"definitly", "unless someone cute shows up"}
|
||||||
};
|
};
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if(Behaver.Instance.IsSelf(message.Author.Id))
|
if(Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
@ -42,7 +42,7 @@ public class GeneralSnarkMisspellDefinitely : Behavior
|
|||||||
|
|
||||||
foreach(var k in snarkmap.Keys)
|
foreach(var k in snarkmap.Keys)
|
||||||
{
|
{
|
||||||
if( Regex.IsMatch(message.Content?.ToLower(), "\\b"+k+"\\b", RegexOptions.IgnoreCase))
|
if( Regex.IsMatch(message.TranslatedContent?.ToLower(), "\\b"+k+"\\b", RegexOptions.IgnoreCase))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -51,7 +51,7 @@ public class GeneralSnarkMisspellDefinitely : Behavior
|
|||||||
{
|
{
|
||||||
foreach(var k in snarkmap.Keys)
|
foreach(var k in snarkmap.Keys)
|
||||||
{
|
{
|
||||||
if( Regex.IsMatch(message.Content, "\\b"+k+"\\b", RegexOptions.IgnoreCase))
|
if( Regex.IsMatch(message.TranslatedContent, "\\b"+k+"\\b", RegexOptions.IgnoreCase))
|
||||||
{
|
{
|
||||||
Behaver.Instance.Reply(message.Id, k + "? so... " + snarkmap[k] + "?");
|
Behaver.Instance.Reply(message.Id, k + "? so... " + snarkmap[k] + "?");
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,7 +19,7 @@ public class GeneralSnarkPlaying : Behavior
|
|||||||
|
|
||||||
public override string Description => "I didn't think you were playing, but now I do";
|
public override string Description => "I didn't think you were playing, but now I do";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if(Behaver.Instance.IsSelf(message.Author.Id))
|
if(Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
@ -28,7 +28,7 @@ public class GeneralSnarkPlaying : Behavior
|
|||||||
(LewdnessFilterLevel)message.Channel.EffectivePermissions.LewdnessFilterLevel < LewdnessFilterLevel.Moderate)
|
(LewdnessFilterLevel)message.Channel.EffectivePermissions.LewdnessFilterLevel < LewdnessFilterLevel.Moderate)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Regex.IsMatch(message.Content, "^(s?he|(yo)?u|y'?all|they) thinks? i'?m (playin|jokin|kiddin)g?$", RegexOptions.IgnoreCase);
|
return Regex.IsMatch(message.TranslatedContent, "^(s?he|(yo)?u|y'?all|they) thinks? i'?m (playin|jokin|kiddin)g?$", RegexOptions.IgnoreCase);
|
||||||
}
|
}
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
{
|
{
|
||||||
|
@ -16,12 +16,12 @@ public class Gratitude : Behavior
|
|||||||
|
|
||||||
public override string Trigger => "thank me";
|
public override string Trigger => "thank me";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if(Behaver.Instance.IsSelf(message.Author.Id))
|
if(Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Regex.IsMatch(message.Content, "\\bthank (yo)?u\\b", RegexOptions.IgnoreCase) && message.MentionsMe;
|
return Regex.IsMatch(message.TranslatedContent, "\\bthank (yo)?u\\b", RegexOptions.IgnoreCase) && message.MentionsMe;
|
||||||
}
|
}
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
{
|
{
|
||||||
|
@ -65,13 +65,13 @@ public class LaughAtOwnJoke : Behavior
|
|||||||
{
|
{
|
||||||
_punchline = punchline;
|
_punchline = punchline;
|
||||||
}
|
}
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if (Behaver.Instance.IsSelf(message.Author.Id))
|
if (Behaver.Instance.IsSelf(message.Author.Id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Console.WriteLine($"{message.Content} == {_punchline}");
|
Console.WriteLine($"{message.TranslatedContent} == {_punchline}");
|
||||||
return message.Content == _punchline
|
return message.TranslatedContent == _punchline
|
||||||
&& Behaver.Instance.IsSelf(message.Author.Id);
|
&& Behaver.Instance.IsSelf(message.Author.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class LinkClose : Behavior
|
|||||||
_primary = primary;
|
_primary = primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
return message.Content == $"!iam {_pw}";
|
return message.Content == $"!iam {_pw}";
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ public class QRify : Behavior
|
|||||||
|
|
||||||
public override string Description => "generate text QR codes";
|
public override string Description => "generate text QR codes";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if (message.Channel.EffectivePermissions.MaxAttachmentBytes < 1024)
|
if (message.Channel.EffectivePermissions.MaxAttachmentBytes < 1024)
|
||||||
return false;
|
return false;
|
||||||
return base.ShouldAct(message);
|
return base.ShouldAct(message, matchedUACs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
|
@ -36,9 +36,9 @@ public class TwitchSummon : Behavior
|
|||||||
as TwitchInterface.TwitchInterface;
|
as TwitchInterface.TwitchInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if (!base.ShouldAct(message))
|
if (!base.ShouldAct(message, matchedUACs))
|
||||||
return false;
|
return false;
|
||||||
var uacConf = Rememberer.SearchUAC(uac => uac.OwnerId == uacID);
|
var uacConf = Rememberer.SearchUAC(uac => uac.OwnerId == uacID);
|
||||||
if (uacConf == null)
|
if (uacConf == null)
|
||||||
@ -74,7 +74,7 @@ public class TwitchDismiss : Behavior
|
|||||||
|
|
||||||
public override string Trigger => "begone, @[me]";
|
public override string Trigger => "begone, @[me]";
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
var ti = TwitchSummon.getAnyTwitchInterface();
|
var ti = TwitchSummon.getAnyTwitchInterface();
|
||||||
// Console.WriteLine($"TwitchDismiss checking. menions me? {message.MentionsMe}");
|
// Console.WriteLine($"TwitchDismiss checking. menions me? {message.MentionsMe}");
|
||||||
|
@ -15,7 +15,7 @@ public class UnitConvert : Behavior
|
|||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
{
|
{
|
||||||
|
|
||||||
var theseMatches = Regex.Matches(message.Content, "\\s(-?[\\d]+\\.?\\d*) ?([^\\d\\s].*) (in|to|as) ([^\\d\\s].*)$", RegexOptions.IgnoreCase);
|
var theseMatches = Regex.Matches(message.TranslatedContent, "\\s(-?[\\d]+\\.?\\d*) ?([^\\d\\s].*) (in|to|as) ([^\\d\\s].*)$", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
if (theseMatches != null && theseMatches.Count > 0 && theseMatches[0].Groups != null && theseMatches[0].Groups.Count == 5)
|
if (theseMatches != null && theseMatches.Count > 0 && theseMatches[0].Groups != null && theseMatches[0].Groups.Count == 5)
|
||||||
{
|
{
|
||||||
|
@ -67,9 +67,9 @@ public class Webhook : Behavior
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ShouldAct(Message message)
|
public override bool ShouldAct(Message message, List<UAC> matchedUACs)
|
||||||
{
|
{
|
||||||
if (!base.ShouldAct(message))
|
if (!base.ShouldAct(message, matchedUACs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Console.WriteLine("webhook checking");
|
Console.WriteLine("webhook checking");
|
||||||
|
@ -19,6 +19,7 @@ namespace vassago
|
|||||||
TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
|
TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
|
||||||
Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]);
|
Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]);
|
||||||
Telefranz.Configure(aspConfig["KafkaName"], aspConfig["KafkaBootstrap"]);
|
Telefranz.Configure(aspConfig["KafkaName"], aspConfig["KafkaBootstrap"]);
|
||||||
|
Console.WriteLine($"Telefranz.Configure({aspConfig["KafkaName"]}, {aspConfig["KafkaBootstrap"]});");
|
||||||
vassago.Behavior.Webhook.SetupWebhooks(aspConfig.GetSection("Webhooks"));
|
vassago.Behavior.Webhook.SetupWebhooks(aspConfig.GetSection("Webhooks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
391
Migrations/20250620023827_locales.Designer.cs
generated
Normal file
391
Migrations/20250620023827_locales.Designer.cs
generated
Normal file
@ -0,0 +1,391 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using vassago.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace vassago.Migrations
|
||||||
|
{
|
||||||
|
#pragma warning disable CS8981
|
||||||
|
[DbContext(typeof(ChattingContext))]
|
||||||
|
[Migration("20250620023827_locales")]
|
||||||
|
partial class locales
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "hstore");
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountUAC", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("AccountInChannelsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UACsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("AccountInChannelsId", "UACsId");
|
||||||
|
|
||||||
|
b.HasIndex("UACsId");
|
||||||
|
|
||||||
|
b.ToTable("AccountUAC");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ChannelUAC", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("ChannelsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UACsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("ChannelsId", "UACsId");
|
||||||
|
|
||||||
|
b.HasIndex("UACsId");
|
||||||
|
|
||||||
|
b.ToTable("ChannelUAC");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UACUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UACsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UsersId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("UACsId", "UsersId");
|
||||||
|
|
||||||
|
b.HasIndex("UsersId");
|
||||||
|
|
||||||
|
b.ToTable("UACUser");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Account", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsBot")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid?>("IsUserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Protocol")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("SeenInChannelId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IsUserId");
|
||||||
|
|
||||||
|
b.HasIndex("SeenInChannelId");
|
||||||
|
|
||||||
|
b.ToTable("Accounts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Attachment", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<string>("ContentType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<decimal?>("ExternalId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("Filename")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("MessageId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Size")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Attachments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Channel", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("ChannelType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int?>("LewdnessFilterLevel")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool?>("LinksAllowed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<decimal?>("MaxAttachmentBytes")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<long?>("MaxTextChars")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int?>("MeannessFilterLevel")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ParentChannelId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Protocol")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool?>("ReactionsPossible")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ParentChannelId");
|
||||||
|
|
||||||
|
b.ToTable("Channels");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Message", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("ActedOn")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AuthorId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ChannelId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("MentionsMe")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Protocol")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Timestamp")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorId");
|
||||||
|
|
||||||
|
b.HasIndex("ChannelId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.UAC", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Dictionary<string, string>>("CommandAlterations")
|
||||||
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("OwnerId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Dictionary<string, string>>("Translations")
|
||||||
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("UACs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountUAC", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Account", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AccountInChannelsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.UAC", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UACsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ChannelUAC", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Channel", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ChannelsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.UAC", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UACsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UACUser", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.UAC", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UACsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UsersId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Account", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.User", "IsUser")
|
||||||
|
.WithMany("Accounts")
|
||||||
|
.HasForeignKey("IsUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.Channel", "SeenInChannel")
|
||||||
|
.WithMany("Users")
|
||||||
|
.HasForeignKey("SeenInChannelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("IsUser");
|
||||||
|
|
||||||
|
b.Navigation("SeenInChannel");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Attachment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Message", "Message")
|
||||||
|
.WithMany("Attachments")
|
||||||
|
.HasForeignKey("MessageId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("Message");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Channel", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Channel", "ParentChannel")
|
||||||
|
.WithMany("SubChannels")
|
||||||
|
.HasForeignKey("ParentChannelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("ParentChannel");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Message", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Account", "Author")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AuthorId");
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.Channel", "Channel")
|
||||||
|
.WithMany("Messages")
|
||||||
|
.HasForeignKey("ChannelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("Author");
|
||||||
|
|
||||||
|
b.Navigation("Channel");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Channel", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Messages");
|
||||||
|
|
||||||
|
b.Navigation("SubChannels");
|
||||||
|
|
||||||
|
b.Navigation("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Message", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Attachments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Accounts");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore CS8981
|
||||||
|
}
|
40
Migrations/20250620023827_locales.cs
Normal file
40
Migrations/20250620023827_locales.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace vassago.Migrations
|
||||||
|
{
|
||||||
|
#pragma warning disable 8981
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class locales : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Localization",
|
||||||
|
table: "UACs",
|
||||||
|
newName: "Translations");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CommandAliases",
|
||||||
|
table: "UACs",
|
||||||
|
newName: "CommandAlterations");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Translations",
|
||||||
|
table: "UACs",
|
||||||
|
newName: "Localization");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CommandAlterations",
|
||||||
|
table: "UACs",
|
||||||
|
newName: "CommandAliases");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore 8981
|
||||||
|
}
|
392
Migrations/20250620230813_TranslatedMessages.Designer.cs
generated
Normal file
392
Migrations/20250620230813_TranslatedMessages.Designer.cs
generated
Normal file
@ -0,0 +1,392 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using vassago.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace vassago.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ChattingContext))]
|
||||||
|
[Migration("20250620230813_TranslatedMessages")]
|
||||||
|
partial class TranslatedMessages
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "hstore");
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountUAC", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("AccountInChannelsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UACsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("AccountInChannelsId", "UACsId");
|
||||||
|
|
||||||
|
b.HasIndex("UACsId");
|
||||||
|
|
||||||
|
b.ToTable("AccountUAC");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ChannelUAC", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("ChannelsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UACsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("ChannelsId", "UACsId");
|
||||||
|
|
||||||
|
b.HasIndex("UACsId");
|
||||||
|
|
||||||
|
b.ToTable("ChannelUAC");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UACUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UACsId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UsersId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("UACsId", "UsersId");
|
||||||
|
|
||||||
|
b.HasIndex("UsersId");
|
||||||
|
|
||||||
|
b.ToTable("UACUser");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Account", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsBot")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid?>("IsUserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Protocol")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("SeenInChannelId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IsUserId");
|
||||||
|
|
||||||
|
b.HasIndex("SeenInChannelId");
|
||||||
|
|
||||||
|
b.ToTable("Accounts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Attachment", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<string>("ContentType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<decimal?>("ExternalId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("Filename")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("MessageId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Size")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Attachments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Channel", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("ChannelType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int?>("LewdnessFilterLevel")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool?>("LinksAllowed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<decimal?>("MaxAttachmentBytes")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<long?>("MaxTextChars")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int?>("MeannessFilterLevel")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ParentChannelId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Protocol")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool?>("ReactionsPossible")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ParentChannelId");
|
||||||
|
|
||||||
|
b.ToTable("Channels");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Message", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("ActedOn")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AuthorId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ChannelId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("MentionsMe")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Protocol")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Timestamp")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("TranslatedContent")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorId");
|
||||||
|
|
||||||
|
b.HasIndex("ChannelId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.UAC", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Dictionary<string, string>>("CommandAlterations")
|
||||||
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("OwnerId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Dictionary<string, string>>("Translations")
|
||||||
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("UACs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountUAC", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Account", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AccountInChannelsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.UAC", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UACsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ChannelUAC", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Channel", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ChannelsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.UAC", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UACsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UACUser", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.UAC", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UACsId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UsersId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Account", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.User", "IsUser")
|
||||||
|
.WithMany("Accounts")
|
||||||
|
.HasForeignKey("IsUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.Channel", "SeenInChannel")
|
||||||
|
.WithMany("Users")
|
||||||
|
.HasForeignKey("SeenInChannelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("IsUser");
|
||||||
|
|
||||||
|
b.Navigation("SeenInChannel");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Attachment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Message", "Message")
|
||||||
|
.WithMany("Attachments")
|
||||||
|
.HasForeignKey("MessageId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("Message");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Channel", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Channel", "ParentChannel")
|
||||||
|
.WithMany("SubChannels")
|
||||||
|
.HasForeignKey("ParentChannelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("ParentChannel");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Message", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("vassago.Models.Account", "Author")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AuthorId");
|
||||||
|
|
||||||
|
b.HasOne("vassago.Models.Channel", "Channel")
|
||||||
|
.WithMany("Messages")
|
||||||
|
.HasForeignKey("ChannelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("Author");
|
||||||
|
|
||||||
|
b.Navigation("Channel");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Channel", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Messages");
|
||||||
|
|
||||||
|
b.Navigation("SubChannels");
|
||||||
|
|
||||||
|
b.Navigation("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.Message", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Attachments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("vassago.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Accounts");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
Migrations/20250620230813_TranslatedMessages.cs
Normal file
28
Migrations/20250620230813_TranslatedMessages.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace vassago.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class TranslatedMessages : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "TranslatedContent",
|
||||||
|
table: "Messages",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TranslatedContent",
|
||||||
|
table: "Messages");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -218,6 +218,9 @@ namespace vassago.Migrations
|
|||||||
b.Property<DateTimeOffset>("Timestamp")
|
b.Property<DateTimeOffset>("Timestamp")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("TranslatedContent")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("AuthorId");
|
b.HasIndex("AuthorId");
|
||||||
@ -233,7 +236,7 @@ namespace vassago.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Dictionary<string, string>>("CommandAliases")
|
b.Property<Dictionary<string, string>>("CommandAlterations")
|
||||||
.HasColumnType("hstore");
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
@ -242,12 +245,12 @@ namespace vassago.Migrations
|
|||||||
b.Property<string>("DisplayName")
|
b.Property<string>("DisplayName")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Dictionary<string, string>>("Localization")
|
|
||||||
.HasColumnType("hstore");
|
|
||||||
|
|
||||||
b.Property<Guid>("OwnerId")
|
b.Property<Guid>("OwnerId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Dictionary<string, string>>("Translations")
|
||||||
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("UACs");
|
b.ToTable("UACs");
|
||||||
|
@ -3,14 +3,16 @@ using System.Collections.Generic;
|
|||||||
using franz;
|
using franz;
|
||||||
using gray_messages;
|
using gray_messages;
|
||||||
|
|
||||||
|
//psst, future adam: that means we're gray_messages.chat.chat_message.
|
||||||
namespace gray_messages.chat
|
namespace gray_messages.chat
|
||||||
{
|
{
|
||||||
public class chat_message : gray_messages.message
|
public class chat_message : gray_messages.message
|
||||||
{
|
{
|
||||||
//expect this to be the same every time
|
//expect this to be the same every time. and, "localhost". but importantly, it'll remind me of the port.
|
||||||
public Uri Api_Uri { get; set; }
|
public Uri Api_Uri { get; set; }
|
||||||
public Guid MessageId { get; set; }
|
public Guid MessageId { get; set; }
|
||||||
public string MessageContent { get; set; }
|
public string Content { get; set; }
|
||||||
|
public string RawContent { get; set; }
|
||||||
public bool MentionsMe { get; set; }
|
public bool MentionsMe { get; set; }
|
||||||
public DateTimeOffset Timestamp { get; set; }
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
public uint AttachmentCount { get; set; }
|
public uint AttachmentCount { get; set; }
|
||||||
|
@ -15,6 +15,7 @@ public class Message
|
|||||||
public string Protocol { get; set; }
|
public string Protocol { get; set; }
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
|
public string TranslatedContent { get; set; }
|
||||||
public bool MentionsMe { get; set; }
|
public bool MentionsMe { get; set; }
|
||||||
public DateTimeOffset Timestamp { get; set; }
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
public bool ActedOn { get; set; }
|
public bool ActedOn { get; set; }
|
||||||
|
@ -32,6 +32,6 @@ public class UAC
|
|||||||
///</summary>
|
///</summary>
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, string> CommandAliases {get; set;}
|
public Dictionary<string, string> CommandAlterations {get; set;}
|
||||||
public Dictionary<string, string> Localization {get; set;}
|
public Dictionary<string, string> Translations {get; set;}
|
||||||
}
|
}
|
||||||
|
@ -229,4 +229,39 @@ public class UACController : ControllerBase
|
|||||||
Rememberer.RememberChannel(targetChannel);
|
Rememberer.RememberChannel(targetChannel);
|
||||||
return Ok(newUAC.Id);
|
return Ok(newUAC.Id);
|
||||||
}
|
}
|
||||||
|
[HttpPut]
|
||||||
|
[Route("AddTranslation/{Id}")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public IActionResult AddTranslation(Guid Id)
|
||||||
|
{
|
||||||
|
_logger.LogDebug($"made it to controller. creating translation for uac {Id}");
|
||||||
|
var uacFromDb = Rememberer.SearchUAC(uac => uac.Id == Id);
|
||||||
|
if (uacFromDb == null)
|
||||||
|
{
|
||||||
|
_logger.LogError($"attempt to create translation for uac {Id}, not found");
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
uacFromDb.Translations ??= [];
|
||||||
|
uacFromDb.Translations.Add(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||||
|
Rememberer.RememberUAC(uacFromDb);
|
||||||
|
return Ok(uacFromDb.Translations.Count);
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
[Route("AddCommandAlteration/{Id}")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public IActionResult AddCommandAlteration(Guid Id)
|
||||||
|
{
|
||||||
|
_logger.LogDebug($"made it to controller. creating command alteration for uac {Id}");
|
||||||
|
var uacFromDb = Rememberer.SearchUAC(uac => uac.Id == Id);
|
||||||
|
if (uacFromDb == null)
|
||||||
|
{
|
||||||
|
_logger.LogError($"attempt to create command alteration for uac {Id}, not found");
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
uacFromDb.CommandAlterations ??= [];
|
||||||
|
uacFromDb.CommandAlterations.Add(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||||
|
Rememberer.RememberUAC(uacFromDb);
|
||||||
|
return Ok(uacFromDb.CommandAlterations.Count);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Display Name</th>
|
<th scope="row">Display Name</th>
|
||||||
<td>@Model.DisplayName</td>
|
<td><input class="form-control" type="text" value="@Model.DisplayName" id="displayName"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Description</th>
|
<th scope="row">Description</th>
|
||||||
@ -19,30 +19,99 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Channels</th>
|
<th scope="row">Channels</th>
|
||||||
<td>
|
<td>
|
||||||
@Html.Raw("<div id=\"channelsTree\"></div>")
|
<div id="channelsTree"></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Users</th>
|
<th scope="row">Users</th>
|
||||||
<td>
|
<td>
|
||||||
@Html.Raw("<div id=\"usersTree\"></div>")
|
<div id="usersTree"></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">AccountInChannels</th>
|
<th scope="row">AccountInChannels</th>
|
||||||
<td>
|
<td>
|
||||||
@Html.Raw("<div id=\"accountsTree\"></div>")
|
<div id="accountsTree"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<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.
|
||||||
|
<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>");
|
||||||
|
}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="addUAC_Translation()">add translation</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Command Alterations (@Model.CommandAlterations?.Count)</th>
|
||||||
|
<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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="addUAC_CommandAlteration()">add alteration</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><button class="btn btn-success">asdf</button></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div id="add-modal" class="modal" tabindex="-1" role="dialog">
|
"adam", you may say, "why are there both translations and command alterations?"<br />
|
||||||
|
translations are like.. if someone says "addicting", you can safely guess that they don't know they should be saying "addictive".<br />
|
||||||
|
so if you say "this game is addicting", that comes in, we just pretend you said "this game is addictive".<br />
|
||||||
|
Command alterations, I have to acknowledge that you *did* say !freedomunits, but I'm changing my behavior and not converting. <br />
|
||||||
|
I guess theoretically you could "translate" freedomunits to nothing, then freeerdumberunits to freedomunits? but if we're doing that it becomes necessary to care about order, and get that right.<br />
|
||||||
|
so let's say, "translations" are "i'll pretend you said", and "command alterations" are "i'll pretend I expected".
|
||||||
|
|
||||||
|
<div id="link-modal" class="modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">Insert GUID</h5>
|
<h5 class="modal-title">Insert GUID</h5>
|
||||||
<button type="button" class="btn btn-close" data-dismiss="add-modal" aria-label="Close">
|
<button type="button" class="btn btn-close" data-dismiss="link-modal" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -58,7 +127,33 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="modalsubmit" type="button" class="btn btn-primary">Save changes</button>
|
<button id="modalsubmit" type="button" class="btn btn-primary">Save changes</button>
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="add-modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="link-modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="unlink-modal" class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Confirm</h5>
|
||||||
|
<button type="button" class="btn-close" data-dismiss="unlink-modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>
|
||||||
|
are you sure you want to unlink
|
||||||
|
<input id="unlinkModalText" enabled="false" type="text" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
to be clear; this is going to "unlink", not like.. delete.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button id="modalsubmit" type="button" class="btn btn-danger">unlink</button>
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="unlink-modal">Close</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -75,88 +170,55 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>
|
<p>
|
||||||
are you sure you wnat to unlink
|
are you sure you want to delete
|
||||||
<input id="removeModalText" enabled="false" type="text" />
|
<input id="removeModalText" enabled="false" type="text" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
|
||||||
to be clear; this is going to "unlink", not like.. delete.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="modalsubmit" type="button" class="btn btn-danger">unlink</button>
|
<button id="modalsubmit" type="button" class="btn btn-danger">delete</button>
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="remove-modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="remove-modal">Close</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function addChannel(){
|
function linkModal(submitFn)
|
||||||
let modalbutton = document.querySelector("#add-modal button#modalsubmit");
|
{
|
||||||
modalbutton.onclick = addChannelSubmit;
|
let modalbutton = document.querySelector("#link-modal button#modalsubmit");
|
||||||
$("#add-modal").modal("show");
|
modalbutton.onclick = () => { linkSubmitModal(submitFn); };
|
||||||
|
$("#link-modal").modal("show");
|
||||||
}
|
}
|
||||||
function addChannelSubmit(){
|
function linkSubmitModal(submitFn)
|
||||||
let guid = document.querySelector("#add-modal #addmodaltext").value;
|
{
|
||||||
linkUAC_Channel(guid, () => { window.location.reload(); });
|
let guid = document.querySelector("#link-modal #addmodaltext").value;
|
||||||
$("#add-modal").modal("hide");
|
submitFn(guid, () => { window.location.reload(); });
|
||||||
console.log(guid);
|
$("#link-modal").modal("hide");
|
||||||
|
console.log(submitFn + "(guid)");
|
||||||
}
|
}
|
||||||
function addUser(){
|
function unlinkModal(submitFn, target)
|
||||||
let modalbutton = document.querySelector("#add-modal button#modalsubmit");
|
{
|
||||||
modalbutton.onclick = addUserSubmit;
|
document.querySelector("#unlink-modal #removeModalText").value = target;
|
||||||
$("#add-modal").modal("show");
|
let modalbutton = document.querySelector("#unlink-modal button#modalsubmit");
|
||||||
}
|
modalbutton.onclick = () => { unlinkModalSubmit(submitFn, target); };
|
||||||
function addUserSubmit(){
|
|
||||||
let guid = document.querySelector("#add-modal #addmodaltext").value;
|
|
||||||
linkUAC_User(guid, () => {window.location.reload(); });
|
|
||||||
$("#add-modal").modal("hide");
|
|
||||||
console.log(guid);
|
|
||||||
}
|
|
||||||
function addAccount(){
|
|
||||||
let modalbutton = document.querySelector("#add-modal button#modalsubmit");
|
|
||||||
modalbutton.onclick = addAccountSubmit;
|
|
||||||
$("#add-modal").modal("show");
|
|
||||||
}
|
|
||||||
function addAccountSubmit(){
|
|
||||||
let guid = document.querySelector("#add-modal #addmodaltext").value;
|
|
||||||
linkUAC_Account(guid, () => { window.location.reload(); });
|
|
||||||
$("#add-modal").modal("hide");
|
|
||||||
console.log(guid);
|
|
||||||
}
|
|
||||||
function removeUser(guid){
|
|
||||||
document.querySelector("#remove-modal #removeModalText").value = guid;
|
|
||||||
let modalbutton = document.querySelector("#remove-modal button#modalsubmit");
|
|
||||||
modalbutton.onclick = removeUserSubmit;
|
|
||||||
$("#remove-modal").modal("show");
|
$("#remove-modal").modal("show");
|
||||||
}
|
}
|
||||||
function removeUserSubmit(){
|
function unlinkModalSubmit(submitFn, target)
|
||||||
let guid = document.querySelector("#remove-modal #removeModalText").value;
|
{
|
||||||
unlinkUAC_User(guid, () => { window.location.reload(); });
|
submitFn(target, () => { window.location.reload(); });
|
||||||
$("#remove-modal").modal("hide");
|
$("#unlink-modal").modal("hide");
|
||||||
}
|
}
|
||||||
function removeChannel(guid){
|
function removeModal(submitFn, idx)
|
||||||
document.querySelector("#remove-modal #removeModalText").value = guid;
|
{
|
||||||
|
document.querySelector("#remove-modal #removeModalText").value = target;
|
||||||
let modalbutton = document.querySelector("#remove-modal button#modalsubmit");
|
let modalbutton = document.querySelector("#remove-modal button#modalsubmit");
|
||||||
modalbutton.onclick = removeChannelSubmit;
|
modalbutton.onclick = () => { removeModalSubmit(submitFn, idx); };
|
||||||
$("#remove-modal").modal("show");
|
$("#remove-modal").modal("show");
|
||||||
}
|
}
|
||||||
function removeChannelSubmit(){
|
function removeModalSubmit(submitFn, idx)
|
||||||
let guid = document.querySelector("#remove-modal #removeModalText").value;
|
{
|
||||||
unlinkUAC_Channel(guid, () => { window.location.reload(); });
|
submitFn(idx, () => { window.location.reload(); });
|
||||||
$("#remove-modal").modal("hide");
|
|
||||||
}
|
|
||||||
function removeAccount(guid){
|
|
||||||
document.querySelector("#remove-modal #removeModalText").value = guid;
|
|
||||||
let modalbutton = document.querySelector("#remove-modal button#modalsubmit");
|
|
||||||
modalbutton.onclick = removeAccountSubmit;
|
|
||||||
$("#remove-modal").modal("show");
|
|
||||||
}
|
|
||||||
function removeAccountSubmit(){
|
|
||||||
let guid = document.querySelector("#remove-modal #removeModalText").value;
|
|
||||||
unlinkUAC_Account(guid , () => { window.location.reload(); });
|
|
||||||
$("#remove-modal").modal("hide");
|
$("#remove-modal").modal("hide");
|
||||||
}
|
}
|
||||||
function channelsTree() {
|
function channelsTree() {
|
||||||
@ -164,11 +226,11 @@
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.Append("[{text: \"Channels\", \"expanded\":true, nodes: [");
|
sb.Append("[{text: \"Channels\", \"expanded\":true, nodes: [");
|
||||||
|
|
||||||
sb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"addChannel()\\\">add channel</button>\"}}");
|
sb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"linkModal(linkUAC_Channel)\\\">add channel</button>\"}}");
|
||||||
foreach (var acc in Model.Channels?.OrderBy(a => a.DisplayName))
|
foreach (var acc in Model.Channels?.OrderBy(a => a.DisplayName))
|
||||||
{
|
{
|
||||||
sb.Append(',');
|
sb.Append(',');
|
||||||
sb.Append($"{{text: \"<a href=\\\"/Channels/Details/{acc.Id}\\\">{acc.DisplayName}</a> - <button type=\\\"button\\\" class=\\\"btn btn-danger\\\" onclick=\\\"removeChannel('{acc.Id}')\\\">remove</button>\"}}");
|
sb.Append($"{{text: \"<a href=\\\"/Channels/Details/{acc.Id}\\\">{acc.DisplayName}</a> - <button type=\\\"button\\\" class=\\\"btn btn-danger\\\" onclick=\\\"unlinkModal(unlinkUAC_Channel, '{acc.Id}')\\\">remove</button>\"}}");
|
||||||
}
|
}
|
||||||
sb.Append("]}]");
|
sb.Append("]}]");
|
||||||
}
|
}
|
||||||
@ -180,11 +242,11 @@
|
|||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
sb.Append("[{text: \"Users\", \"expanded\":true, nodes: [");
|
sb.Append("[{text: \"Users\", \"expanded\":true, nodes: [");
|
||||||
|
|
||||||
sb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"addUser()\\\">add user</button>\"}}");
|
sb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"linkModal(linkUAC_User)\\\">add user</button>\"}}");
|
||||||
foreach (var acc in Model.Users?.OrderBy(a => a.DisplayName))
|
foreach (var acc in Model.Users?.OrderBy(a => a.DisplayName))
|
||||||
{
|
{
|
||||||
sb.Append(',');
|
sb.Append(',');
|
||||||
sb.Append($"{{text: \"<a href=\\\"/Users/Details/{acc.Id}\\\">{acc.DisplayName}</a> - <button type=\\\"button\\\" class=\\\"btn btn-danger\\\" onclick=\\\"removeUser('{acc.Id}')\\\">remove</button>\"}}");
|
sb.Append($"{{text: \"<a href=\\\"/Users/Details/{acc.Id}\\\">{acc.DisplayName}</a> - <button type=\\\"button\\\" class=\\\"btn btn-danger\\\" onclick=\\\"unlinkModal(unlinkUAC_User, '{acc.Id}')\\\">remove</button>\"}}");
|
||||||
}
|
}
|
||||||
sb.Append("]}]");
|
sb.Append("]}]");
|
||||||
}
|
}
|
||||||
@ -196,17 +258,18 @@
|
|||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
sb.Append("[{text: \"Accounts\", \"expanded\":true, nodes: [");
|
sb.Append("[{text: \"Accounts\", \"expanded\":true, nodes: [");
|
||||||
|
|
||||||
sb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"addAccount()\\\">add account</button>\"}}");
|
sb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"linkModal(linkUAC_Account)\\\">add account</button>\"}}");
|
||||||
foreach (var acc in Model.AccountInChannels?.OrderBy(a => a.DisplayName))
|
foreach (var acc in Model.AccountInChannels?.OrderBy(a => a.DisplayName))
|
||||||
{
|
{
|
||||||
sb.Append(',');
|
sb.Append(',');
|
||||||
sb.Append($"{{text: \"<a href=\\\"/Accounts/Details/{acc.Id}\\\">{acc.DisplayName}</a> - <button type=\\\"button\\\" class=\\\"btn btn-danger\\\" onclick=\\\"removeAccount('{acc.Id}')\\\">remove</button>\"}}");
|
sb.Append($"{{text: \"<a href=\\\"/Accounts/Details/{acc.Id}\\\">{acc.DisplayName}</a> - <button type=\\\"button\\\" class=\\\"btn btn-danger\\\" onclick=\\\"unlinkModal(unlinkUAC_Acocunt, '{acc.Id}')\\\">remove</button>\"}}");
|
||||||
}
|
}
|
||||||
sb.Append("]}]");
|
sb.Append("]}]");
|
||||||
}
|
}
|
||||||
var tree = @Html.Raw(sb.ToString());
|
var tree = @Html.Raw(sb.ToString());
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#channelsTree').bstreeview({ data: channelsTree() });
|
$('#channelsTree').bstreeview({ data: channelsTree() });
|
||||||
$('#usersTree').bstreeview({ data: usersTree() });
|
$('#usersTree').bstreeview({ data: usersTree() });
|
||||||
$('#accountsTree').bstreeview({ data: accountsTree() });
|
$('#accountsTree').bstreeview({ data: accountsTree() });
|
||||||
|
@ -269,6 +269,56 @@ function unlinkUAC_Channel(user_guid, callback)
|
|||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function addUAC_Translation(callback)
|
||||||
|
{
|
||||||
|
var components = window.location.pathname.split('/');
|
||||||
|
var id=components[3];
|
||||||
|
fetch(apiUrl + "UAC/AddTranslation/" + id, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not "ok". which is not ok.');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(returnedSuccessdata => {
|
||||||
|
// perhaps a success callback
|
||||||
|
console.log('returnedSuccessdata:', returnedSuccessdata);
|
||||||
|
if(callback !== null) { callback(); }
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function addUAC_CommandAlteration(callback)
|
||||||
|
{
|
||||||
|
var components = window.location.pathname.split('/');
|
||||||
|
var id=components[3];
|
||||||
|
fetch(apiUrl + "UAC/AddCommandAlteration/" + id, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not "ok". which is not ok.');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(returnedSuccessdata => {
|
||||||
|
// perhaps a success callback
|
||||||
|
console.log('returnedSuccessdata:', returnedSuccessdata);
|
||||||
|
if(callback !== null) { callback(); }
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
//give me account, we'll tear it off from user.
|
//give me account, we'll tear it off from user.
|
||||||
function unlinkAccountUser(callback)
|
function unlinkAccountUser(callback)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user