Example #1
0
#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;
            }
Example #2
0
 public Task TakeAction(
     IBotProvider provider, IBotEvent evt, IEventMatchResult match,
     IReadOnlyDictionary <string, IBotPlugin> plugins
     ) => provider.SendMessage(
     evt.ChannelInfo,
     Expand(evt, match, plugins)
     );
Example #3
0
        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;
                }
Example #4
0
 public void CallEvent(IBotEvent Event)
 {
     foreach (IBotListener listener in listeners)
     {
         Event.Call(listener);
     }
 }
Example #5
0
        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);
        }
Example #6
0
 private void Notify(IBotEvent @event)
 {
     _subject.OnNext(@event);
     Handle(@event);
 }
Example #7
0
 private void OnNext(IBotEvent @event)
 {
     _logger.Debug("[BotFarm:{BotFarmId}]. Event: {@Event}.", _id, @event);
 }
Example #8
0
 public IEventMatchResult Match(IBotEvent @event) => null;
Example #9
0
 public IEventMatchResult Match(IBotEvent evt) =>
 evt is IJoinEvent ? EventMatched.Instance : null;
Example #10
0
 public void Notify(IBotEvent @event)
 {
     _notify(@event);
 }