Class represents ChatMessage in a Twitch channel.
Exemplo n.º 1
0
 public ChatCommand(string ircString, ChatMessage chatMessage)
 {
     ChatMessage = chatMessage;
     Command = chatMessage.Message.Split(' ')?[0].Substring(1, chatMessage.Message.Split(' ')[0].Length - 1) ?? chatMessage.Message.Substring(1, chatMessage.Message.Length - 1);
     ArgumentsAsString = chatMessage.Message.Contains(" ") ? chatMessage.Message.Replace(chatMessage.Message.Split(' ')?[0] + " ", "") ?? "" : "";
     if (!chatMessage.Message.Contains("\"") || chatMessage.Message.Count(x => x == '"') % 2 == 1)
         ArgumentsAsList = chatMessage.Message.Split(' ')?.Where(arg => arg != chatMessage.Message[0] + Command).ToList<string>() ?? new List<string>();
     else
         ArgumentsAsList = Common.ParseQuotesAndNonQuotes(ArgumentsAsString);
     CommandIdentifier = chatMessage.Message[0];
 }
Exemplo n.º 2
0
        /// <summary>[Works] Parse function to detect new commands.</summary>
        /// <param name="botUsername"></param>
        /// <param name="message"></param>
        /// <param name="channels"></param>
        /// <param name="_channelEmotes"></param>
        /// <param name="WillReplaceEmotes"></param>
        /// <param name="_commandIdentifiers"></param>
        /// <returns></returns>
        public static DetectionReturn detectCommandReceived(string botUsername, string message, List<JoinedChannel> channels, MessageEmoteCollection _channelEmotes, bool WillReplaceEmotes, List<char> _commandIdentifiers)
        {
            string readType = null;
            string channelRet = null;
            foreach (JoinedChannel channel in channels)
            {
                readType = getReadType(message, channel.Channel);
                if (readType != null)
                {
                    channelRet = channel.Channel;
                    break;
                }
            }

            if (readType != null && readType == "PRIVMSG")
            {
                var chatMessage = new ChatMessage(botUsername, message, ref _channelEmotes, WillReplaceEmotes);
                return new DetectionReturn((_commandIdentifiers.Count != 0 && _commandIdentifiers.Contains(chatMessage.Message[0])), channelRet);
            }
            return new DetectionReturn(false);
        }
Exemplo n.º 3
0
 /// <summary>Handles a message</summary>
 public void HandleMessage(ChatMessage message)
 {
     PreviousMessage = message;
 }