scholtzm / punk

⚡ Alternative cross-platform Steam client for desktop
MIT License
100 stars 29 forks source link

Past chat history #40

Open mxamber opened 7 years ago

mxamber commented 7 years ago

Hi,

it'd be great if Punk could show past chat histories after a restart. I tried this today, did a "test chat" with a friend, restarted Punk, and the past chat posts were gone.

Since Punk keeps logs anyway, I imagine it wouldn't be hard to load those and display them. The Steam client usually displays the last couple lines from previous chats, and having the Punk client display the entirety (or, if preferences are implemented some day, a customisable amount of past chats) would be a feature I've always missed with the default client.

scholtzm commented 7 years ago

Yep, I was thinking about using the chat log to load previous chats messages - the only problem is that the chat log is stored in a human-readable file but it's not very easy to parse.

Official Steam client loads the last few messages from Steam servers, so I might implement that as well. However, that would only provide very limited functionality - like 10 last messages or so.

mxamber commented 7 years ago

I'm not a pro with JS, but wouldn't you be able to do a bit of RegEx magic on the logs? I assume it can't be that hard.

/\[([0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2})\]/ would get the date string, which IIRC is in a format JavaScript Date can read, and getting the chat text should be manageable as well. Get the posts separated by doing Array.split() with newline char on the text file. I'd say parsing the usernames to match SteamIDs would be the only hard part.