forked from adam/discord-bot-shtik
Adam R Grey
efb4ab00d2
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.
32 lines
956 B
C#
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 {}
|