コード例 #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;
            }
コード例 #2
0
 public Task TakeAction(
     IBotProvider provider, IBotEvent evt, IEventMatchResult match,
     IReadOnlyDictionary <string, IBotPlugin> plugins
     ) => provider.SendMessage(
     evt.ChannelInfo,
     Expand(evt, match, plugins)
     );
コード例 #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;
                }
コード例 #4
0
 public void CallEvent(IBotEvent Event)
 {
     foreach (IBotListener listener in listeners)
     {
         Event.Call(listener);
     }
 }
コード例 #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);
        }
コード例 #6
0
 private void Notify(IBotEvent @event)
 {
     _subject.OnNext(@event);
     Handle(@event);
 }
コード例 #7
0
ファイル: BotFarm.cs プロジェクト: smolyakoff/conreign
 private void OnNext(IBotEvent @event)
 {
     _logger.Debug("[BotFarm:{BotFarmId}]. Event: {@Event}.", _id, @event);
 }
コード例 #8
0
 public IEventMatchResult Match(IBotEvent @event) => null;
コード例 #9
0
 public IEventMatchResult Match(IBotEvent evt) =>
 evt is IJoinEvent ? EventMatched.Instance : null;
コード例 #10
0
 public void Notify(IBotEvent @event)
 {
     _notify(@event);
 }