Fix tps parsing
This commit is contained in:
parent
960a4447ce
commit
80055b2225
|
@ -1,8 +1,9 @@
|
||||||
use nom::{
|
use nom::{
|
||||||
bytes::complete::tag,
|
bytes::complete::tag,
|
||||||
combinator::{all_consuming, map, opt},
|
character::complete::one_of,
|
||||||
|
combinator::{all_consuming, map, opt, value},
|
||||||
number::complete::double,
|
number::complete::double,
|
||||||
sequence::{preceded, tuple},
|
sequence::{pair, preceded, tuple},
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,14 +39,14 @@ impl RconCommand for TpsCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_tps_result(inp: &str) -> IResult<&str, Tps> {
|
fn parse_tps_result(inp: &str) -> IResult<&str, Tps> {
|
||||||
let start = tag("§6TPS from last 1m, 5m, 15m: §a");
|
let start = tag("§6TPS from last 1m, 5m, 15m: ");
|
||||||
all_consuming(map(
|
all_consuming(map(
|
||||||
tuple((
|
tuple((
|
||||||
start,
|
start,
|
||||||
tps_value,
|
tps_value,
|
||||||
tag(", §a"),
|
tag(", "),
|
||||||
tps_value,
|
tps_value,
|
||||||
tag(", §a"),
|
tag(", "),
|
||||||
tps_value,
|
tps_value,
|
||||||
tag("\n"),
|
tag("\n"),
|
||||||
)),
|
)),
|
||||||
|
@ -54,5 +55,9 @@ fn parse_tps_result(inp: &str) -> IResult<&str, Tps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tps_value(inp: &str) -> IResult<&str, f64> {
|
fn tps_value(inp: &str) -> IResult<&str, f64> {
|
||||||
preceded(opt(tag("*")), double)(inp)
|
preceded(pair(ignore_color, opt(tag("*"))), double)(inp)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ignore_color(inp: &str) -> IResult<&str, ()> {
|
||||||
|
value((), opt(pair(tag("§"), one_of("0123456789abcdef"))))(inp)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue