2023-06-15 23:29:07 -04:00
|
|
|
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-15 23:29:07 -04:00
|
|
|
|
2023-06-19 11:03:06 -04:00
|
|
|
public virtual bool ShouldAct(Message message)
|
2023-06-15 23:29:07 -04:00
|
|
|
{
|
2024-01-05 21:39:31 -05:00
|
|
|
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);
|
2023-06-15 23:29:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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-15 23:29:07 -04:00
|
|
|
}
|
2023-06-20 21:26:44 -04:00
|
|
|
|
2023-07-04 18:51:27 -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>
|
2023-11-30 12:50:51 -05:00
|
|
|
public class StaticPlzAttribute : Attribute {}
|