| Crates.io | lol_chat_parser |
| lib.rs | lol_chat_parser |
| version | 0.2.0 |
| created_at | 2025-11-05 14:30:35.402115+00 |
| updated_at | 2025-11-18 23:44:58.725708+00 |
| description | A parser for League of Legends chat logs that extracts structured data into JSON. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1918065 |
| size | 46,280 |
Brief Description:
LoLCP is a parser for League of Legends chat logs.
It uses a custom grammar written in pest to extract structured events such as chat messages, kill events, team achievements, purchases, map-objective interactions, and smart pings.
The parser is now capable of handling most common LoL chat log structures and extracting:
However, LoL logs are complex and frequently updated (and not documented π ), so
I do not guarantee 100% correctness across all client versions or rare system messages.
Nevertheless, the included grammar and logic are designed to be modular and extensible.
The goal of this project is to take a plain-text League of Legends log and transform it into structured JSON, containing:
This allows further analysis such as:
Each chat line (except the first one by system) in the log typically follows this pattern:
<timestamp><event>
Type /help for a list of commands
00:42 uskin432 (Warwick) is on the way
00:52 kozakSyla (Lux) has drawn first blood!
02:24 Enemy team has completed the Feat of Warfare!
13:05 Golf4f (Mel) has shut down BorysBulba (Tahm Kench)! (Bonus Bounty: 149G)
13:08 [Party] piwkobb (Yone): Cho'Gath Heartsteel - 20 charges
13:10 BorysBulba (Tahm Kench) purchased Control Ward
14:46 kozakSyla (Lux) is on rampage!
15:40 piwkobb (Yone) has targeted TheMiozl - (Renekton)
16:53 [All] piwkobb (Yone): hello this is all chat msg
17:34 [Team] kozakSyla (Lux): hi in team chat
18:32 kozakSyla (Lux) has targeted the Power Flower (33%)
The parser breaks these into structured components using pest grammar rules.
The full grammar is located in:
src/grammar.pest
Below is a shortened overview of the most important rules:
line = { time ~ " " ~ line_body }
time = @{ ASCII_DIGIT ~ ASCII_DIGIT ~ ":" ~ ASCII_DIGIT ~ ASCII_DIGIT }
player_with_champion = {
player_name ~ " " ~ "(" ~ champion_name ~ ")"
}
chat_message = {
channel_chat_message
| bare_chat_message
}
kill_shutdown_event = {
player_with_champion ~ " has shut down " ~ player_with_champion ~ "!" ~ " " ~ shutdown_bounty
}
target_objective_event = {
player_with_champion ~ " has targeted " ~ name_phrase ~ " (" ~ percentage ~ "%)"
}
ping_on_the_way_event = {
player_with_champion ~ " " ~ ping_phrase
}
(This is only a simplified subset for demonstrationβsee the full grammar file for all details.)
The project includes a command-line interface with several commands:
cargo run -- help
cargo run -- credits
cargo run -- parse lol_chat_example.txt
{
"players": [
{
"name": "BorysBulba",
"champions": [
"Tahm Kench"
]
},
{
"name": "Golf4f",
"champions": [
"Mel"
]
},
{
"name": "TheMiozl",
"champions": [
"Renekton"
]
},
{
"name": "kozakSyla",
"champions": [
"Lux"
]
},
{
"name": "piwkobb",
"champions": [
"Yone"
]
},
{
"name": "uskin432",
"champions": [
"Warwick"
]
}
],
"kills": [
{
"time": "00:52",
"killer": "kozakSyla",
"killer_champion": "Lux",
"victim": null,
"victim_champion": null,
"bounty": null,
"is_shutdown": false,
"is_first_blood": true
},
{
"time": "13:05",
"killer": "Golf4f",
"killer_champion": "Mel",
"victim": "BorysBulba",
"victim_champion": "Tahm Kench",
"bounty": 149,
"is_shutdown": true,
"is_first_blood": false
}
],
"events": [
{
"time": "00:42",
"team": null,
"description": "uskin432 (Warwick) is on the way"
},
{
"time": "02:24",
"team": "Enemy team",
"description": "Enemy team has completed the Feat of Warfare!"
},
{
"time": "13:10",
"team": null,
"description": "BorysBulba (Tahm Kench) purchased Control Ward"
},
{
"time": "14:46",
"team": null,
"description": "kozakSyla (Lux) is on rampage!"
},
{
"time": "15:40",
"team": null,
"description": "piwkobb (Yone) has targeted TheMiozl - (Renekton)"
},
{
"time": "18:32",
"team": null,
"description": "kozakSyla (Lux) has targeted the Power Flower (33%)"
}
],
"messages": [
{
"time": "13:08",
"channel": "party",
"player": "piwkobb",
"champion": "Yone",
"text": "Cho'Gath Heartsteel - 20 charges"
},
{
"time": "16:53",
"channel": "all",
"player": "piwkobb",
"champion": "Yone",
"text": "hello this is all chat msg"
},
{
"time": "17:34",
"channel": "team",
"player": "kozakSyla",
"champion": "Lux",
"text": "hi in team chat"
}
],
"system": [
{
"text": "Type /help for a list of commands"
}
]
}
src/
βββ grammar.pest # Full grammar definition
βββ lib.rs # Core parsing logic
βββ main.rs # CLI interface
tests/
βββ grammar_rules_spec.rs
βββ json_integration_spec.rs
README.md
Cargo.toml
Cargo.lock
lol_chat_example.txt # Example log file
.gitignore
MIT License. Project created as part of the National University of Kyiv-Mohyla Academy Rust course.
Created by Bohdan Tarverdiiev
/\_/\
( o.o ) -- hello there :)
> ^ <