#pragma warning disable 1998 // Task needs to be async for API public async Task TakeAction( IBotProvider provider, IBotEvent @event, IEventMatchResult match, IReadOnlyDictionary <string, IBotPlugin> plugins ) { plugin.vars[varname] += adjustment; }
public Task TakeAction( IBotProvider provider, IBotEvent evt, IEventMatchResult match, IReadOnlyDictionary <string, IBotPlugin> plugins ) => provider.SendMessage( evt.ChannelInfo, Expand(evt, match, plugins) );
private string Expand( IBotEvent evt, IEventMatchResult match, IReadOnlyDictionary <string, IBotPlugin> plugins ) { if (Params == null) { return(Message); } var sb = new StringBuilder(Message); foreach (var param in Params.Reverse()) { string value = null; if (param.Param == "{" || param.Param == "}") { value = param.Param; } else if (param.Param == "match") { value = match.Param(param.Arg); } else if (evt is IMessageEvent mev && param.Param == "sender") { value = mev.SenderInfo.UserReference; }
public void CallEvent(IBotEvent Event) { foreach (IBotListener listener in listeners) { Event.Call(listener); } }
public IEventMatchResult Match(IBotEvent evt) { if (evt is IMessageEvent m) { var match = pattern.Match(m.Message); if (match.Success) { return(new MatchResult(match)); } } return(null); }
private void Notify(IBotEvent @event) { _subject.OnNext(@event); Handle(@event); }
private void OnNext(IBotEvent @event) { _logger.Debug("[BotFarm:{BotFarmId}]. Event: {@Event}.", _id, @event); }
public IEventMatchResult Match(IBotEvent @event) => null;
public IEventMatchResult Match(IBotEvent evt) => evt is IJoinEvent ? EventMatched.Instance : null;
public void Notify(IBotEvent @event) { _notify(@event); }