Note: LINE is a trademark of LINE Corporation. This project is neither affiliated with nor endorsed by LINE Corporation.
LINE on desktop and mobile allows you to export/save chats. The formats are a bit different depending on system and locale, but it looks roughly like this:
2017.09.03 Sunday 16:23 Bob Today I found something: Apparently there is a Node package for parsing chats now! 16:25 Alice Whaaat 16:25 Bob Yeah, it's called line-chat-parser. 16:26 Bob Here's a screenshot: 16:27 Bob Photos 16:30 Alice Looks awesome!
This package can parse these exports into message objects:
date: '2017-09-03T14:23:00.000Z'author: 'Bob'text: 'Today I found something:\nApparently there is a Node package for parsing chats now!'date: '2017-09-03T14:25:00.000Z'author: 'Alice'text: 'Whaaat'date: '2017-09-03T14:25:00.000Z'author: 'Bob'text: 'Yeah, it\'s called line-chat-parser.'date: '2017-09-03T14:26:00.000Z'author: 'Bob'text: 'Here\'s a screenshot:'date: '2017-09-03T14:27:00.000Z' author: 'Bob' text: 'Photos'date: '2017-09-03T14:30:00.000Z'author: 'Alice'text: 'Looks awesome!'
Note: The date properties above are native
Date objects. They are just
This package is available on NPM:
npm i line-chat-parser
Note: user name array
Exports from the Windows .exe (not the Store app) are formatted with single spaces. This makes it impossible to correctly detect user names without a list of participating users.
Exports from the mobile app separate the names from the message bodies with tab characters. There, you can do without the user list.
What you need ultimately comes down to what kind of export you want to process.
There are two ways to use the parser. Note that both require an array of participating users so that the message authors can be deduced correctly.
Asynchronous parsing ('message' event)
The asynchronous method should be used with huge amounts of messages or when not
all lines are known yet -- it emits a
message event every time a message is
const LineChatParser =// as stated above, you can leave out the user name array when processing// mobile app exportslet parser = 'Alice' 'Bob'parserparserparserparser// now the message is done and the event is emittedparser// ...// IMPORTANT - always call flush - it emits the final messageparser
Synchronous parsing (static 'parse' function)
Use this method when you have the full file in memory already and/or need the complete message array immediately without listening for events.
You can supply an array of lines or a single string with line terminators.
const LineChatParser =const messages = LineChatParser// as stated above, you can leave out the user name array when processing// mobile app exports// or, alternatively:const messages = LineChatParserconsole