private void Client_OnMessageReceived(object sender, TwitchLib.Client.Events.OnMessageReceivedArgs e)
        {
            IChatMessageRule chatmessageRule = _listChatMessageRules.FirstOrDefault(rule => rule.IsTextMatched(e.ChatMessage.Message));

            if (!(chatmessageRule is null))
            {
                string messageReturnedFromRule = chatmessageRule.ReturnedMessage(e);
                _twitchLibClient.SendMessage(_twitchConfiguration.ChannelName, messageReturnedFromRule);
            }


            if (e.ChatMessage.Message.StartsWith("!uptime", StringComparison.InvariantCultureIgnoreCase))
            {
                var upTime = GetUpTime().Result;
                _twitchLibClient.SendMessage(_twitchConfiguration.ChannelName, upTime?.ToString() ?? "Offline");
            }
        }
示例#2
0
        public string HandleBotCommands(TwitchLib.Client.Events.OnMessageReceivedArgs e)
        {
            IChatMessageRule chatmessageRule = _listChatMessageRules.FirstOrDefault(rule => rule.IsTextMatched(e.ChatMessage.Message.Trim()));

            if (chatmessageRule != null)
            {
                return(chatmessageRule.ReturnedMessage(e));
            }


            //if (e.ChatMessage.Message.StartsWith("!uptime", StringComparison.InvariantCultureIgnoreCase))
            //{
            //    var upTime = GetUpTime().Result;
            //    _twitchLibClient.SendMessage(_twitchConfiguration.ChannelName, upTime?.ToString() ?? "Offline");
            //}

            return(string.Empty);
        }