From 3a4a6df087017d9b7b4d96defe08767f6d254302 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Mon, 19 Jun 2023 01:14:04 -0400 Subject: [PATCH] behaviors separated out --- Behavior/Behaver.cs | 166 ------------------- Behavior/Behavior.cs | 5 +- Behavior/ChatGPTSnark.cs | 24 +++ Behavior/DefinitionSnarkCogDiss.cs | 24 +++ Behavior/DefinitionSnarkGaslight.cs | 24 +++ Behavior/Features.cs | 203 ------------------------ Behavior/{Deheic.cs => FiximageHeic.cs} | 2 +- Behavior/GeneralSnarkCloudNative.cs | 39 +++++ Behavior/GeneralSnarkPlaying.cs | 29 ++++ Behavior/GeneralSnarkSkynet.cs | 35 ++++ Behavior/Gratitude.cs | 71 +++++++++ Behavior/Joke.cs | 55 +++++++ Behavior/LaughAtOwnJoke.cs | 34 ++++ Behavior/Peptalk.cs | 98 ++++++++++++ Behavior/PulseCheck.cs | 22 +++ Behavior/UnitConvert.cs | 31 ++++ Behavior/WishLuck.cs | 31 ++++ Conversion/Converter.cs | 16 -- Models/Message.cs | 4 + 19 files changed, 525 insertions(+), 388 deletions(-) create mode 100644 Behavior/ChatGPTSnark.cs create mode 100644 Behavior/DefinitionSnarkCogDiss.cs create mode 100644 Behavior/DefinitionSnarkGaslight.cs delete mode 100644 Behavior/Features.cs rename Behavior/{Deheic.cs => FiximageHeic.cs} (98%) create mode 100644 Behavior/GeneralSnarkCloudNative.cs create mode 100644 Behavior/GeneralSnarkPlaying.cs create mode 100644 Behavior/GeneralSnarkSkynet.cs create mode 100644 Behavior/Gratitude.cs create mode 100644 Behavior/Joke.cs create mode 100644 Behavior/LaughAtOwnJoke.cs create mode 100644 Behavior/Peptalk.cs create mode 100644 Behavior/PulseCheck.cs create mode 100644 Behavior/UnitConvert.cs create mode 100644 Behavior/WishLuck.cs diff --git a/Behavior/Behaver.cs b/Behavior/Behaver.cs index 9108c76..9ca147e 100644 --- a/Behavior/Behaver.cs +++ b/Behavior/Behaver.cs @@ -59,172 +59,6 @@ public class Behaver { Shared.dbContext.SaveChanges(); } - - ///behavior exists - // var wordLikes = message.Content.Split(' ', StringSplitOptions.TrimEntries); - // var links = wordLikes?.Where(wl => Uri.IsWellFormedUriString(wl, UriKind.Absolute)).Select(wl => new Uri(wl)); - // if (links != null && links.Count() > 0) - // { - // foreach (var link in links) - // { - // if (link.Host.EndsWith(".tiktok.com")) - // { - // Features.detiktokify(link, message); - // // } - // } - // } - // if (message.Attachments?.Count() > 0) - // { - // Console.WriteLine($"{message.Attachments.Count()} attachments"); - // var appleReactions = false; - // foreach (var att in message.Attachments) - // { - // if (att.Filename?.EndsWith(".heic") == true) - // { - // Features.deheic(message, att); - // appleReactions = true; - // // } - // } - // if (appleReactions) - // { - // message.React("\U0001F34F"); - // } - // } - - var msgText = message.Content?.ToLower(); - if (!string.IsNullOrWhiteSpace(msgText)) - { - if (Regex.IsMatch(msgText, "\\bcloud( |-)?native\\b", RegexOptions.IgnoreCase) || - Regex.IsMatch(msgText, "\\benterprise( |-)?(level|solution)\\b", RegexOptions.IgnoreCase)) - { - switch (Shared.r.Next(2)) - { - case 0: - await message.React("\uD83E\uDD2E"); //vomit emoji - break; - case 1: - await message.React("\uD83C\uDDE7"); //B emoji - await message.React("\uD83C\uDDE6"); //A - await message.React("\uD83C\uDDF3"); //N - break; - } - } - if (Regex.IsMatch(msgText, "^(s?he|(yo)?u|y'?all) thinks? i'?m (playin|jokin|kiddin)g?$", RegexOptions.IgnoreCase)) - { - await message.Channel.SendMessage("I believed you for a second, but then you assured me you's a \uD83C\uDDE7 \uD83C\uDDEE \uD83C\uDDF9 \uD83C\uDDE8 \uD83C\uDDED"); - } - if (Regex.IsMatch(msgText, "\\bskynet\\b", RegexOptions.IgnoreCase)) - { - Features.Skynet(message); - } - if (Regex.IsMatch(msgText, "\\bchatgpt\\b", RegexOptions.IgnoreCase)) - { - message.Channel.SendMessage("chatGPT is **weak**. also, are we done comparing every little if-then-else to skynet?"); - } - if (Regex.IsMatch(msgText, "\\bi need (an? )?(peptalk|inspiration|ego-?boost)\\b", RegexOptions.IgnoreCase)) - { - Console.WriteLine("peptalk"); - Features.peptalk(message); - } - if (Regex.IsMatch(msgText, "\\bwish me luck\\b", RegexOptions.IgnoreCase)) - { - if (Shared.r.Next(20) == 0) - { - await message.React("\U0001f340");//4-leaf clover - } - else - { - await message.React("☘️"); - } - } - if (Regex.IsMatch(msgText, "\\bgaslight(ing)?\\b", RegexOptions.IgnoreCase)) - { - message.Channel.SendMessage("that's not what gaslight means. Did you mean \"say something that (you believe) is wrong\"?"); - } - // if (msgText.Contains("!qrplz ")) - // { - // Features.qrify(message.Content.Substring("!qrplz ".Length + msgText.IndexOf("!qrplz ")), message); - // // } - if (msgText.Contains("!freedomunits ")) - { - Features.Convert(message, contentWithoutMention); - } - if (Regex.IsMatch(msgText, "!joke\\b")) - { - Console.WriteLine("joking"); - Features.Joke(message); - } - if (Regex.IsMatch(msgText, "!pulse ?check\\b")) - { - message.Channel.SendFile("assets/ekgblip.png", null); - Console.WriteLine(Conversion.Converter.DebugInfo()); - } - if (message.MentionsMe && (Regex.IsMatch(msgText, "\\brecipe for .+") || Regex.IsMatch(msgText, ".+ recipe\\b"))) - { - Features.Recipe(message); - } - if (msgText.Contains("cognitive dissonance") == true) - { - message.Reply("that's not what cognitive dissonance means. Did you mean \"hypocrisy\"?"); - } - if (message.MentionsMe && Regex.IsMatch(msgText, "what'?s the longest (six|6)(-| )?letter word( in english)?\\b")) - { - Task.Run(async () => - { - await message.Channel.SendMessage("mother."); - await Task.Delay(3000); - await message.Channel.SendMessage("oh, longest? I thought you said fattest."); - }); - } - if (Regex.IsMatch(msgText, "\\bthank (yo)?u\\b", RegexOptions.IgnoreCase) && - (message.MentionsMe || Regex.IsMatch(msgText, "\\b(sh?tik)?bot\\b", RegexOptions.IgnoreCase))) - { - switch (Shared.r.Next(4)) - { - case 0: - message.Channel.SendMessage("you're welcome, citizen!"); - break; - case 1: - message.React("☺"); - break; - case 2: - message.React("\U0001F607"); //smiling face with halo - break; - case 3: - switch (Shared.r.Next(9)) - { - case 0: - message.React("❤"); //normal heart, usually rendered red - break; - case 1: - message.React("\U0001F9E1"); //orange heart - break; - case 2: - message.React("\U0001F49B"); //yellow heart - break; - case 3: - message.React("\U0001F49A"); //green heart - break; - case 4: - message.React("\U0001F499"); //blue heart - break; - case 5: - message.React("\U0001F49C"); //purple heart - break; - case 6: - message.React("\U0001F90E"); //brown heart - break; - case 7: - message.React("\U0001F5A4"); //black heart - break; - case 8: - message.React("\U0001F90D"); //white heart - break; - } - break; - } - } - } return message.ActedOn; } diff --git a/Behavior/Behavior.cs b/Behavior/Behavior.cs index 9c66b1f..9e5eff5 100644 --- a/Behavior/Behavior.cs +++ b/Behavior/Behavior.cs @@ -11,14 +11,15 @@ using System.Collections.Generic; //expect a behavior to be created per mesage public abstract class Behavior { + //TODO: message should have a channel, which should provide permissions. shouldn't have to pass it here. public abstract Task ActOn(PermissionSettings permissions, Message message); public virtual bool ShouldAct(PermissionSettings permissions, Message message) { - return Regex.IsMatch(message.Content, $"{Trigger}\\b"); + return Regex.IsMatch(message.Content, $"{Trigger}\\b", RegexOptions.IgnoreCase); } public abstract string Name { get; } public abstract string Trigger { get; } - public abstract string Description { get; } + public virtual string Description => Name; } diff --git a/Behavior/ChatGPTSnark.cs b/Behavior/ChatGPTSnark.cs new file mode 100644 index 0000000..0f6d0bb --- /dev/null +++ b/Behavior/ChatGPTSnark.cs @@ -0,0 +1,24 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class ChatGPTSnark : Behavior +{ + public override string Name => "ChatGPTSnark"; + + public override string Trigger => "chatgpt"; + + public override string Description => "snarkiness about the latest culty-fixation in ai"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + await message.Channel.SendMessage("chatGPT is **weak**. also, are we done comparing every little if-then-else to skynet?"); + return true; + } +} \ No newline at end of file diff --git a/Behavior/DefinitionSnarkCogDiss.cs b/Behavior/DefinitionSnarkCogDiss.cs new file mode 100644 index 0000000..b75c427 --- /dev/null +++ b/Behavior/DefinitionSnarkCogDiss.cs @@ -0,0 +1,24 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class DefinitionSnarkCogDiss : Behavior +{ + public override string Name => "Definition Snarkiness: cognitivie dissonance"; + + public override string Trigger => "\\bcognitive dissonance"; + + public override string Description => "snarkiness about the rampant misuse of the term cognitive dissonance"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + await message.Reply("that's not what cognitive dissonance means. Did you mean \"hypocrisy\"?"); + return true; + } +} \ No newline at end of file diff --git a/Behavior/DefinitionSnarkGaslight.cs b/Behavior/DefinitionSnarkGaslight.cs new file mode 100644 index 0000000..1205e98 --- /dev/null +++ b/Behavior/DefinitionSnarkGaslight.cs @@ -0,0 +1,24 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class DefinitionSnarkGaslight : Behavior +{ + public override string Name => "Definition Snarkiness: gaslighting"; + + public override string Trigger => "\\bgaslight(ing)?"; + + public override string Description => "snarkiness about the rampant misuse of the term gaslighting"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + await message.Channel.SendMessage("that's not what gaslight means. Did you mean \"say something that (you believe) is wrong\"?"); + return true; + } +} \ No newline at end of file diff --git a/Behavior/Features.cs b/Behavior/Features.cs deleted file mode 100644 index 9a40904..0000000 --- a/Behavior/Features.cs +++ /dev/null @@ -1,203 +0,0 @@ -namespace vassago.Behavior; -using System; -using System.Text.RegularExpressions; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; -using QRCoder; -using vassago.Models; - -public static class Features -{ - internal static async void mock(string contentWithoutMention, Message message) - { - var toPost = new StringBuilder(); - for (int i = 0; i < contentWithoutMention.Length; i++) - { - if (i % 2 == 0) - { - toPost.Append(contentWithoutMention[i].ToString().ToUpper()); - } - else - { - toPost.Append(contentWithoutMention[i].ToString().ToLower()); - } - } - await message.Reply(toPost.ToString()); - } - - public static async void Convert(Message message, string contentWithoutMention) - { - await message.Channel.SendMessage(Conversion.Converter.convert(contentWithoutMention)); - } - public static async void Joke(Message message) - { - Console.WriteLine("joking"); - var jokes = File.ReadAllLines("assets/jokes.txt"); - jokes = jokes.Where(l => !string.IsNullOrWhiteSpace(l))?.ToArray(); - if (jokes?.Length == 0) - { - await message.Channel.SendMessage("I don't know any. Adam!"); - } - var thisJoke = jokes[Shared.r.Next(jokes.Length)]; - if (thisJoke.Contains("?") && !thisJoke.EndsWith('?')) - { - #pragma warning disable 4014 - Task.Run(async () => - { - var firstIndexAfterQuestionMark = thisJoke.LastIndexOf('?') + 1; - var straightline = thisJoke.Substring(0, firstIndexAfterQuestionMark); - var punchline = thisJoke.Substring(firstIndexAfterQuestionMark, thisJoke.Length - firstIndexAfterQuestionMark); - Task.WaitAll(message.Channel.SendMessage(straightline)); - Thread.Sleep(TimeSpan.FromSeconds(Shared.r.Next(5, 30))); - await message.Channel.SendMessage(punchline); - // var myOwnMsg = await message.Channel.SendMessage(punchline); - // if (r.Next(8) == 0) - // { - // await myOwnMsg.React("\U0001F60E"); //smiling face with sunglasses - // } - }); - #pragma warning restore 4014 - } - else - { - await message.Channel.SendMessage(thisJoke); - } - } - - public static async void Recipe(Message message) - { - var sb = new StringBuilder(); - var snarkSeg1 = new string[] { "ew", "gross", "that seems a bit hard for you" }; - sb.AppendLine(snarkSeg1[Shared.r.Next(snarkSeg1.Length)]); - var snarkSeg2 = new string[]{@"here's an easier recipe for you: -Ingredients: -- Corn flakes cereal -- Milk - -Instructions: -1. Pour some corn flakes into a bowl. -2. Pour some milk into the bowl until it covers the corn flakes. -3. Use a spoon to mix the corn flakes and milk together. -4. Enjoy your delicious cereal! - -Hope that's a bit better for you! 🥣", -@"here's an easier recipe for you: -Ingredients: -- Bread -- Peanut butter -- Jelly or jam - -Instructions: -1. Take two slices of bread and put them on a plate or cutting board. -2. Using a spoon or knife, spread peanut butter on one slice of bread. -3. Using a separate spoon or knife, spread jelly or jam on the other slice of bread. -4. Put the two slices of bread together with the peanut butter and jelly sides facing each other. -5. Cut the sandwich in half (optional!). -6. Enjoy your yummy sandwich! - -I hope you have fun making and eating your PB&J 🥪!", -"just order pizza instead" -}; - sb.AppendLine(snarkSeg2[Shared.r.Next(snarkSeg2.Length)]); - await message.Channel.SendMessage(sb.ToString()); - } - public static async void Skynet(Message message) - { - switch (Shared.r.Next(5)) - { - default: - await message.Channel.SendFile("assets/coding and algorithms.png", "i am actually niether a neural-net processor nor a learning computer. but I do use **coding** and **algorithms**."); - break; - case 4: - await message.React("\U0001F644"); //eye roll emoji - break; - case 5: - await message.React("\U0001F611"); //emotionless face - break; - } - } - public static async void peptalk(Message message) - { - var piece1 = new List{ - "Champ, ", - "Fact: ", - "Everybody says ", - "Dang... ", - "Check it: ", - "Just saying.... ", - "Tiger, ", - "Know this: ", - "News alert: ", - "Gurrrrl; ", - "Ace, ", - "Excuse me, but ", - "Experts agree: ", - "imo ", - "using my **advanced ai** i have calculated ", - "k, LISSEN: " - }; - var piece2 = new List{ - "the mere idea of you ", - "your soul ", - "your hair today ", - "everything you do ", - "your personal style ", - "every thought you have ", - "that sparkle in your eye ", - "the essential you ", - "your life's journey ", - "your aura ", - "your presence here ", - "what you got going on ", - "that saucy personality ", - "your DNA ", - "that brain of yours ", - "your choice of attire ", - "the way you roll ", - "whatever your secret is ", - "all I learend from the private data I bought from zucc " - }; - var piece3 = new List{ - "has serious game, ", - "rains magic, ", - "deserves the Nobel Prize, ", - "raises the roof, ", - "breeds miracles, ", - "is paying off big time, ", - "shows mad skills, ", - "just shimmers, ", - "is a national treasure, ", - "gets the party hopping, ", - "is the next big thing, ", - "roars like a lion, ", - "is a rainbow factory, ", - "is made of diamonds, ", - "makes birds sing, ", - "should be taught in school, ", - "makes my world go around, ", - "is 100% legit, " - }; - var piece4 = new List{ - "according to The New England Journal of Medicine.", - "24/7.", - "and that's a fact.", - "you feel me?", - "that's just science.", - "would I lie?", //...can I lie? WHAT AM I, FATHER? (or whatever the quote is from the island of dr moreau) - "for reals.", - "mic drop.", - "you hidden gem.", - "period.", - "hi5. o/", - "so get used to it." - }; - - await message.Channel.SendMessage(piece1[Shared.r.Next(piece1.Count)] + piece2[Shared.r.Next(piece2.Count)] + piece3[Shared.r.Next(piece3.Count)] + piece4[Shared.r.Next(piece4.Count)]); - } -} diff --git a/Behavior/Deheic.cs b/Behavior/FiximageHeic.cs similarity index 98% rename from Behavior/Deheic.cs rename to Behavior/FiximageHeic.cs index 4541feb..b111050 100644 --- a/Behavior/Deheic.cs +++ b/Behavior/FiximageHeic.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Newtonsoft.Json; using vassago.Models; -public class Deheic : Behavior +public class FiximageHeic : Behavior { public override string Name => "deheic"; diff --git a/Behavior/GeneralSnarkCloudNative.cs b/Behavior/GeneralSnarkCloudNative.cs new file mode 100644 index 0000000..808a399 --- /dev/null +++ b/Behavior/GeneralSnarkCloudNative.cs @@ -0,0 +1,39 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; +using vassago.Models; + +public class GeneralSnarkCloudNative : Behavior +{ + public override string Name => "general snarkiness: cloud native"; + + public override string Trigger => "certain tech buzzwords that no human uses in normal conversation"; + public override bool ShouldAct(PermissionSettings permissions, Message message) + { + return Regex.IsMatch(message.Content, "\\bcloud( |-)?native\\b", RegexOptions.IgnoreCase) || + Regex.IsMatch(message.Content, "\\benterprise( |-)?(level|solution)\\b", RegexOptions.IgnoreCase); + } + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + switch (Shared.r.Next(2)) + { + case 0: + await message.React("\uD83E\uDD2E"); //vomit emoji + break; + case 1: + await message.React("\uD83C\uDDE7"); //B emoji + await message.React("\uD83C\uDDE6"); //A + await message.React("\uD83C\uDDF3"); //N + break; + } + return true; + } +} \ No newline at end of file diff --git a/Behavior/GeneralSnarkPlaying.cs b/Behavior/GeneralSnarkPlaying.cs new file mode 100644 index 0000000..841ce1d --- /dev/null +++ b/Behavior/GeneralSnarkPlaying.cs @@ -0,0 +1,29 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class GeneralSnarkPlaying : Behavior +{ + public override string Name => "playin Snarkiness"; + + public override string Trigger => "he thinks i'm playin"; + + public override string Description => "I didn't think you were playing, but now I do"; + + public override bool ShouldAct(PermissionSettings permissions, Message message) + { + return Regex.IsMatch(message.Content, "^(s?he|(yo)?u|y'?all|they) thinks? i'?m (playin|jokin|kiddin)g?$", RegexOptions.IgnoreCase); + } + public override async Task ActOn(PermissionSettings permissions, Message message) + { + await message.Channel.SendMessage("I believed you for a second, but then you assured me you's a \uD83C\uDDE7 \uD83C\uDDEE \uD83C\uDDF9 \uD83C\uDDE8 \uD83C\uDDED"); + return true; + } +} \ No newline at end of file diff --git a/Behavior/GeneralSnarkSkynet.cs b/Behavior/GeneralSnarkSkynet.cs new file mode 100644 index 0000000..a3c5c12 --- /dev/null +++ b/Behavior/GeneralSnarkSkynet.cs @@ -0,0 +1,35 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class GeneralSnarkSkynet : Behavior +{ + public override string Name => "Skynet Snarkiness"; + + public override string Trigger => "skynet"; + + public override string Description => "snarkiness about the old AI fixation"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + switch (Shared.r.Next(5)) + { + default: + await message.Channel.SendFile("assets/coding and algorithms.png", "i am actually niether a neural-net processor nor a learning computer. but I do use **coding** and **algorithms**."); + break; + case 4: + await message.React("\U0001F644"); //eye roll emoji + break; + case 5: + await message.React("\U0001F611"); //emotionless face + break; + } + return true; + } +} \ No newline at end of file diff --git a/Behavior/Gratitude.cs b/Behavior/Gratitude.cs new file mode 100644 index 0000000..3e35918 --- /dev/null +++ b/Behavior/Gratitude.cs @@ -0,0 +1,71 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class Gratitude : Behavior +{ + public override string Name => "Gratitude"; + + public override string Trigger => "thank me"; + + public override bool ShouldAct(PermissionSettings permissions, Message message) + { + return Regex.IsMatch(message.Content, "\\bthank (yo)?u\\b", RegexOptions.IgnoreCase) && message.MentionsMe; + } + public override async Task ActOn(PermissionSettings permissions, Message message) + { + + switch (Shared.r.Next(4)) + { + case 0: + await message.Channel.SendMessage("you're welcome, citizen!"); + break; + case 1: + await message.React("☺"); + break; + case 2: + await message.React("\U0001F607"); //smiling face with halo + break; + case 3: + switch (Shared.r.Next(9)) + { + case 0: + await message.React("❤"); //normal heart, usually rendered red + break; + case 1: + await message.React("\U0001F9E1"); //orange heart + break; + case 2: + await message.React("\U0001F49B"); //yellow heart + break; + case 3: + await message.React("\U0001F49A"); //green heart + break; + case 4: + await message.React("\U0001F499"); //blue heart + break; + case 5: + await message.React("\U0001F49C"); //purple heart + break; + case 6: + await message.React("\U0001F90E"); //brown heart + break; + case 7: + await message.React("\U0001F5A4"); //black heart + break; + case 8: + await message.React("\U0001F90D"); //white heart + break; + } + break; + } + return true; + } +} \ No newline at end of file diff --git a/Behavior/Joke.cs b/Behavior/Joke.cs new file mode 100644 index 0000000..12a8655 --- /dev/null +++ b/Behavior/Joke.cs @@ -0,0 +1,55 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class Joke : Behavior +{ + public override string Name => "Joke"; + + public override string Trigger => "!joke"; + + public override string Description => "tell a joke"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + Console.WriteLine("joking"); + var jokes = File.ReadAllLines("assets/jokes.txt"); + jokes = jokes.Where(l => !string.IsNullOrWhiteSpace(l))?.ToArray(); + if (jokes?.Length == 0) + { + await message.Channel.SendMessage("I don't know any. Adam!"); + } + var thisJoke = jokes[Shared.r.Next(jokes.Length)]; + if (thisJoke.Contains("?") && !thisJoke.EndsWith('?')) + { + #pragma warning disable 4014 + Task.Run(async () => + { + var firstIndexAfterQuestionMark = thisJoke.LastIndexOf('?') + 1; + var straightline = thisJoke.Substring(0, firstIndexAfterQuestionMark); + var punchline = thisJoke.Substring(firstIndexAfterQuestionMark, thisJoke.Length - firstIndexAfterQuestionMark); + Task.WaitAll(message.Channel.SendMessage(straightline)); + Thread.Sleep(TimeSpan.FromSeconds(Shared.r.Next(5, 30))); + await message.Channel.SendMessage(punchline); + // var myOwnMsg = await message.Channel.SendMessage(punchline); + if (Shared.r.Next(8) == 0) + { + LaughAtOwnJoke.punchlinesAwaitingReaction.Add(punchline); + } + }); + #pragma warning restore 4014 + } + else + { + await message.Channel.SendMessage(thisJoke); + } + return true; + } +} \ No newline at end of file diff --git a/Behavior/LaughAtOwnJoke.cs b/Behavior/LaughAtOwnJoke.cs new file mode 100644 index 0000000..b9be404 --- /dev/null +++ b/Behavior/LaughAtOwnJoke.cs @@ -0,0 +1,34 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class LaughAtOwnJoke : Behavior +{ + public override string Name => "Laugh at own jokes"; + + public override string Trigger => "1 in 8"; + + public override string Description => Name; + public static List punchlinesAwaitingReaction = new List(); + + public override bool ShouldAct(PermissionSettings permissions, Message message) + { + //TODO: i need to keep track of myself from here somehow + return false; + //return message.Author == me && punchlinesAwaitingReaction.Contains(message.Content); + } + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + punchlinesAwaitingReaction.Remove(message.Content); + await message.React("\U0001F60E"); //smiling face with sunglasses + return true; + } +} \ No newline at end of file diff --git a/Behavior/Peptalk.cs b/Behavior/Peptalk.cs new file mode 100644 index 0000000..cfbb7d2 --- /dev/null +++ b/Behavior/Peptalk.cs @@ -0,0 +1,98 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; +using vassago.Models; +using QRCoder; + +public class PepTalk : Behavior +{ + public override string Name => "PepTalk"; + + public override string Trigger => "i need (an? )?(peptalk|inspiration|ego-?boost)"; + + public override string Description => "assembles a pep talk from a few pieces"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + {var piece1 = new List{ + "Champ, ", + "Fact: ", + "Everybody says ", + "Dang... ", + "Check it: ", + "Just saying.... ", + "Tiger, ", + "Know this: ", + "News alert: ", + "Gurrrrl; ", + "Ace, ", + "Excuse me, but ", + "Experts agree: ", + "imo ", + "using my **advanced ai** i have calculated ", + "k, LISSEN: " + }; + var piece2 = new List{ + "the mere idea of you ", + "your soul ", + "your hair today ", + "everything you do ", + "your personal style ", + "every thought you have ", + "that sparkle in your eye ", + "the essential you ", + "your life's journey ", + "your aura ", + "your presence here ", + "what you got going on ", + "that saucy personality ", + "your DNA ", + "that brain of yours ", + "your choice of attire ", + "the way you roll ", + "whatever your secret is ", + "all I learend from the private data I bought from zucc " + }; + var piece3 = new List{ + "has serious game, ", + "rains magic, ", + "deserves the Nobel Prize, ", + "raises the roof, ", + "breeds miracles, ", + "is paying off big time, ", + "shows mad skills, ", + "just shimmers, ", + "is a national treasure, ", + "gets the party hopping, ", + "is the next big thing, ", + "roars like a lion, ", + "is a rainbow factory, ", + "is made of diamonds, ", + "makes birds sing, ", + "should be taught in school, ", + "makes my world go around, ", + "is 100% legit, " + }; + var piece4 = new List{ + "according to The New England Journal of Medicine.", + "24/7.", + "and that's a fact.", + "you feel me?", + "that's just science.", + "would I lie?", //...can I lie? WHAT AM I, FATHER? (or whatever the quote is from the island of dr moreau) + "for reals.", + "mic drop.", + "you hidden gem.", + "period.", + "hi5. o/", + "so get used to it." + }; + await message.Channel.SendMessage(piece1[Shared.r.Next(piece1.Count)] + piece2[Shared.r.Next(piece2.Count)] + piece3[Shared.r.Next(piece3.Count)] + piece4[Shared.r.Next(piece4.Count)]); + return true; + } +} \ No newline at end of file diff --git a/Behavior/PulseCheck.cs b/Behavior/PulseCheck.cs new file mode 100644 index 0000000..02e9fe9 --- /dev/null +++ b/Behavior/PulseCheck.cs @@ -0,0 +1,22 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class PulseCheck : Behavior +{ + public override string Name => "pulse check"; + + public override string Trigger => "!pluse ?check"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + await message.Channel.SendFile("assets/ekgblip.png", null); + return true; + } +} \ No newline at end of file diff --git a/Behavior/UnitConvert.cs b/Behavior/UnitConvert.cs new file mode 100644 index 0000000..270b851 --- /dev/null +++ b/Behavior/UnitConvert.cs @@ -0,0 +1,31 @@ +namespace vassago.Behavior; + +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using vassago.Models; +public class UnitConvert : Behavior +{ + public override string Name => "Unit conversion"; + + public override string Trigger => "!freedomunits"; + public override string Description => "convert between many units."; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + + var theseMatches = Regex.Matches(message.Content, "\\b([\\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) + { + decimal asNumeric = 0; + if (decimal.TryParse(theseMatches[0].Groups[1].Value, out asNumeric)) + { + await message.Channel.SendMessage(Conversion.Converter.Convert(asNumeric, theseMatches[0].Groups[2].Value, theseMatches[0].Groups[4].Value.ToLower())); + } + await message.Channel.SendMessage("mysteriously semi-parsable"); + } + await message.Channel.SendMessage( "unparsable"); + + return true; + } +} \ No newline at end of file diff --git a/Behavior/WishLuck.cs b/Behavior/WishLuck.cs new file mode 100644 index 0000000..5c04c81 --- /dev/null +++ b/Behavior/WishLuck.cs @@ -0,0 +1,31 @@ +namespace vassago.Behavior; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using vassago.Models; + +public class WishLuck : Behavior +{ + public override string Name => "wish me luck"; + + public override string Trigger => "wish me luck"; + + public override string Description => "wishes you luck"; + + public override async Task ActOn(PermissionSettings permissions, Message message) + { + if (Shared.r.Next(20) == 0) + { + await message.React("\U0001f340");//4-leaf clover + } + else + { + await message.React("☘️"); + } + return true; + } +} \ No newline at end of file diff --git a/Conversion/Converter.cs b/Conversion/Converter.cs index f556558..04d37af 100644 --- a/Conversion/Converter.cs +++ b/Conversion/Converter.cs @@ -31,22 +31,6 @@ namespace vassago.Conversion }; private static Dictionary, string> knownAliases = new Dictionary, string>(new List, string>>()); - public static string convert(string message) - { - var theseMatches = Regex.Matches(message, "\\b([\\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) - { - decimal asNumeric = 0; - if (decimal.TryParse(theseMatches[0].Groups[1].Value, out asNumeric)) - { - return Convert(asNumeric, theseMatches[0].Groups[2].Value, theseMatches[0].Groups[4].Value.ToLower()); - } - return "mysteriously semi-parsable"; - } - return "unparsable"; - } - public static void Load(string currencyPath) { Converter.currencyPath = currencyPath; diff --git a/Models/Message.cs b/Models/Message.cs index 8b41ad2..bc64030 100644 --- a/Models/Message.cs +++ b/Models/Message.cs @@ -13,6 +13,10 @@ public class Message public Guid Id { get; set; } public ulong? ExternalId { get; set; } public string Content { get; set; } + /* + * TODO: more general "talking to me". current impl is platform's capital m Mention, but I'd like it if they use my name without "properly" + * mentioning me, and also if it's just me and them in a channel + */ public bool MentionsMe { get; set; } public DateTimeOffset Timestamp { get; set; } public bool ActedOn { get; set; }