vassago/Behavior/Behavior.cs

32 lines
956 B
C#
Raw Normal View History

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
{
2023-06-19 11:03:06 -04:00
public abstract Task<bool> ActOn(Message message);
2023-06-19 11:03:06 -04:00
public virtual bool ShouldAct(Message message)
{
if(Behaver.Instance.IsSelf(message.Author.Id))
2023-06-20 21:26:44 -04:00
return false;
2023-06-19 01:14:04 -04:00
return Regex.IsMatch(message.Content, $"{Trigger}\\b", RegexOptions.IgnoreCase);
}
public abstract string Name { get; }
public abstract string Trigger { get; }
2023-06-19 01:14:04 -04:00
public virtual string Description => Name;
}
2023-06-20 21:26:44 -04:00
///<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 {}