behaviors separated out

This commit is contained in:
Adam R Grey 2023-06-19 01:14:04 -04:00
parent 567a59550e
commit 3a4a6df087
19 changed files with 525 additions and 388 deletions

View File

@ -59,172 +59,6 @@ public class Behaver
{ {
Shared.dbContext.SaveChanges(); 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; return message.ActedOn;
} }

View File

@ -11,14 +11,15 @@ using System.Collections.Generic;
//expect a behavior to be created per mesage //expect a behavior to be created per mesage
public abstract class Behavior public abstract class Behavior
{ {
//TODO: message should have a channel, which should provide permissions. shouldn't have to pass it here.
public abstract Task<bool> ActOn(PermissionSettings permissions, Message message); public abstract Task<bool> ActOn(PermissionSettings permissions, Message message);
public virtual bool ShouldAct(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 Name { get; }
public abstract string Trigger { get; } public abstract string Trigger { get; }
public abstract string Description { get; } public virtual string Description => Name;
} }

24
Behavior/ChatGPTSnark.cs Normal file
View File

@ -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<bool> 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;
}
}

View File

@ -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<bool> ActOn(PermissionSettings permissions, Message message)
{
await message.Reply("that's not what cognitive dissonance means. Did you mean \"hypocrisy\"?");
return true;
}
}

View File

@ -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<bool> 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;
}
}

View File

@ -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<string>{
"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<string>{
"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<string>{
"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<string>{
"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)]);
}
}

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using vassago.Models; using vassago.Models;
public class Deheic : Behavior public class FiximageHeic : Behavior
{ {
public override string Name => "deheic"; public override string Name => "deheic";

View File

@ -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<bool> 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;
}
}

View File

@ -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<bool> 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;
}
}

View File

@ -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<bool> 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;
}
}

71
Behavior/Gratitude.cs Normal file
View File

@ -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<bool> 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;
}
}

55
Behavior/Joke.cs Normal file
View File

@ -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<bool> 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;
}
}

View File

@ -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<string> punchlinesAwaitingReaction = new List<string>();
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<bool> ActOn(PermissionSettings permissions, Message message)
{
punchlinesAwaitingReaction.Remove(message.Content);
await message.React("\U0001F60E"); //smiling face with sunglasses
return true;
}
}

98
Behavior/Peptalk.cs Normal file
View File

@ -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<bool> ActOn(PermissionSettings permissions, Message message)
{var piece1 = new List<string>{
"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<string>{
"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<string>{
"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<string>{
"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;
}
}

22
Behavior/PulseCheck.cs Normal file
View File

@ -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<bool> ActOn(PermissionSettings permissions, Message message)
{
await message.Channel.SendFile("assets/ekgblip.png", null);
return true;
}
}

31
Behavior/UnitConvert.cs Normal file
View File

@ -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<bool> 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;
}
}

31
Behavior/WishLuck.cs Normal file
View File

@ -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<bool> ActOn(PermissionSettings permissions, Message message)
{
if (Shared.r.Next(20) == 0)
{
await message.React("\U0001f340");//4-leaf clover
}
else
{
await message.React("☘️");
}
return true;
}
}

View File

@ -31,22 +31,6 @@ namespace vassago.Conversion
}; };
private static Dictionary<List<string>, string> knownAliases = new Dictionary<List<string>, string>(new List<KeyValuePair<List<string>, string>>()); private static Dictionary<List<string>, string> knownAliases = new Dictionary<List<string>, string>(new List<KeyValuePair<List<string>, 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) public static void Load(string currencyPath)
{ {
Converter.currencyPath = currencyPath; Converter.currencyPath = currencyPath;

View File

@ -13,6 +13,10 @@ public class Message
public Guid Id { get; set; } public Guid Id { get; set; }
public ulong? ExternalId { get; set; } public ulong? ExternalId { get; set; }
public string Content { 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 bool MentionsMe { get; set; }
public DateTimeOffset Timestamp { get; set; } public DateTimeOffset Timestamp { get; set; }
public bool ActedOn { get; set; } public bool ActedOn { get; set; }