Example #1
0
        public BaseRConParser()
        {
            Configuration = new DynamicRConParserConfiguration()
            {
                CommandPrefixes = new CommandPrefix()
                {
                    Tell          = "tell {0} {1}",
                    Say           = "say {0}",
                    Kick          = "clientkick {0} \"{1}\"",
                    Ban           = "clientkick {0} \"{1}\"",
                    TempBan       = "tempbanclient {0} \"{1}\"",
                    RConCommand   = "ÿÿÿÿrcon {0} {1}",
                    RConGetDvar   = "ÿÿÿÿrcon {0} {1}",
                    RConSetDvar   = "ÿÿÿÿrcon {0} set {1}",
                    RConGetStatus = "ÿÿÿÿgetstatus",
                    RConGetInfo   = "ÿÿÿÿgetinfo",
                    RConResponse  = "ÿÿÿÿprint",
                },
            };

            Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){8,32}|(?:[a-z]|[0-9]){8,32}|bot[0-9]+|(?:[0-9]+)) +(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$";
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConClientNumber, 1);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConScore, 2);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConPing, 3);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConNetworkId, 4);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7);

            Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)?\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$";
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarLatchedValue, 4);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDomain, 5);
        }
Example #2
0
        public BaseRConParser(IParserRegexFactory parserRegexFactory)
        {
            Configuration = new DynamicRConParserConfiguration(parserRegexFactory)
            {
                CommandPrefixes = new CommandPrefix()
                {
                    Tell                      = "tell {0} {1}",
                    Say                       = "say {0}",
                    Kick                      = "clientkick {0} \"{1}\"",
                    Ban                       = "clientkick {0} \"{1}\"",
                    TempBan                   = "tempbanclient {0} \"{1}\"",
                    RConCommand               = "ÿÿÿÿrcon {0} {1}",
                    RConGetDvar               = "ÿÿÿÿrcon {0} {1}",
                    RConSetDvar               = "ÿÿÿÿrcon {0} set {1}",
                    RConGetStatus             = "ÿÿÿÿgetstatus",
                    RConGetInfo               = "ÿÿÿÿgetinfo",
                    RConResponse              = "ÿÿÿÿprint",
                    RconGetInfoResponseHeader = "ÿÿÿÿinfoResponse"
                },
                ServerNotRunningResponse = "Server is not running."
            };

            Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){8,32}|(?:[a-z]|[0-9]){8,32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback|unknown) +(-*[0-9]+) +([0-9]+) *$";
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConClientNumber, 1);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConScore, 2);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConPing, 3);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConNetworkId, 4);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5);
            Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7);

            Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)?\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$";
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarLatchedValue, 4);
            Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDomain, 5);

            Configuration.StatusHeader.Pattern   = "num +score +ping +guid +name +lastmsg +address +qport +rate *";
            Configuration.GametypeStatus.Pattern = "";
            Configuration.MapStatus.Pattern      = @"map: (([a-z]|_|\d)+)";
            Configuration.MapStatus.AddMapping(ParserRegex.GroupType.RConStatusMap, 1);

            if (!Configuration.DefaultDvarValues.ContainsKey("mapname"))
            {
                Configuration.DefaultDvarValues.Add("mapname", "Unknown");
            }
        }