vassago/Behavior/Behavior.cs
Adam R Grey efb4ab00d2 IsSelf fix for Definitely snarkiness
notes to self. 1) trust in upsert. an account has an external ID, a channel has an external ID w.r.t. its protocol. 2) as long as you can collapse a User, collapse Self.
2024-01-05 21:39:31 -05:00

32 lines
956 B
C#

namespace vassago.Behavior;
using vassago.Models;
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections.Generic;
public abstract class Behavior
{
public abstract Task<bool> ActOn(Message message);
public virtual bool ShouldAct(Message message)
{
if(Behaver.Instance.IsSelf(message.Author.Id))
return false;
return Regex.IsMatch(message.Content, $"{Trigger}\\b", RegexOptions.IgnoreCase);
}
public abstract string Name { get; }
public abstract string Trigger { get; }
public virtual string Description => Name;
}
///<summary>
///the behavior should be static. I.e., we make one at the start and it's ready to check and go for the whole lifetime.
///As opposed to LaughAtOwnJoke, which only needs to be created to wait for 1 punchline one time.
///</summary>
public class StaticPlzAttribute : Attribute {}