RemoteTags() public static method

public static RemoteTags ( string inputString ) : string
inputString string
return string
Beispiel #1
0
        internal void AddMsgToLobby(string ID, ChatMessage response)
        {
            System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: PrintMsgToLobby ID: " + response.id);
            if (!_chatLobbies.ContainsKey(ID))
            {
                // we don't know this lobby :S
                System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: ID (" + response.id + ") is unknown");
                return;
            }

            GuiChatLobby cl  = _chatLobbies[ID];
            string       msg = Processor.RemoteTags(response.msg);

            System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: lobby: " + cl.Lobby.lobby_name);
            System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: msg: " + msg + " from " + response.peer_nickname);
            System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: rec: " + response.recv_time + " send: " + response.send_time);

            // add "*time* - *nick* > *msg*"
            cl.ChatText += Processor.conv_Timestamp2Date(response.send_time).ToLocalTime().ToLongTimeString() + " - " + response.peer_nickname + " > " + msg + "\n";

            _chatLobbies[ID] = cl;
            if (_b.GUI.clb_chatLobbies.SelectedIndex == cl.Index)
            {
                //SetChatText(ID);
                _reDrawChat = true;
            }
            else
            {
                if (!cl.Unread)
                {
                    cl.Unread = true;
                    _b.GUI.clb_chatLobbies.SetItemCheckState(cl.Index, CheckState.Indeterminate);
                    _chatLobbies[ID] = cl;
                }
            }

            //AutoAnswer(Processor.RemoteTags(response.msg.msg));
            AutoAnswer(response, cl);
        }
Beispiel #2
0
        /// <summary>
        /// This function will scan a given message and create a response
        /// </summary>
        /// <param name="msg">message to scan</param>
        /// <returns>message to return</returns>
        public string Process(ChatMessage msgIN)
        {
            // check if item is active
            // if not return
            if (!_active)
            {
                return("");
            }

            string msg = Processor.RemoteTags(msgIN.msg);

            if (!_caseSensitive)
            {
                msg = msg.ToLower();
            }

            // check for prefix
            // if matching prefix is found cut it off and continue
            // if no matching prefix is found return
            if (_prefix != '\0')
            {
                if (msg.StartsWith(Convert.ToString(_prefix)))
                {
                    msg = msg.Substring(1);
                }
                else
                {
                    return("");
                }
            }

            // check if the sought phrase should occur alone
            // if it's found return the answer
            // if not return
            if (_only)
            {
                if (msg == _searchFor)
                {
                    return(Process2(msgIN, msg));
                }
                else
                {
                    return("");
                }
            }

            if (_withSpaces && _prefix == '\0')
            {
                if (Regex.IsMatch(msg, "\\b" + _searchFor + "\\b"))
                {
                    return(Process2(msgIN, msg));
                }
                else
                {
                    return("");
                }
            }
            else if (_withSpaces && _prefix != '\0')
            {
                // the problem with the prefix is, that the matching word must appear after the prefix -> StartsWith()
                // the + " " is requiered because of _withSpaces
                // in case word == _searchFor it does NOT match _searchFor + " "
                if (msg.StartsWith(_searchFor + " ") || msg == _searchFor)
                {
                    return(Process2(msgIN, msg));
                }
                else
                {
                    return("");
                }
            }
            else
            if (msg.Contains(_searchFor))
            {
                return(Process2(msgIN, msg));
            }
            else
            {
                return("");
            }
        }