MsgParser is a simple python package that can build json metadata about a chat message.
I am @sam and here is a link: https://www.simple.com have a nice day (smiley).
{
"raw": "I am @sam and here is a link: https://www.simple.com have a nice day (smiley).",
"emoticons": ["smiley"],
"links": [{
"url": "https://www.simple.com",
"title": "Simple | Online Banking With Automatic Budgeting & Savings"
}],
"mentions": ["sam"]
}
This software was developed in OS X 10.11.3 with Python 2.7.10.
This guide assumes that you have pulled the source code down onto your local machine.
Add the code directory to your python path
$ export PYTHONPATH=$PYTHONPATH:/path/to/code/directory
Install dependencies pytest and mechanize using easy_install
$ easy_install -U pytest
$ easy_install -U mechanize
To run the tests locally simply run pytest in the code directory
$ py.test
Continuous Integration is hosted in drone.io
It's easy to try out MsgParser in the python console:
$ cd /path/to/code/directory
$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from msg_parser import MsgParser
>>> parse = MsgParser()
>>> parse.parse_message("Hello, @sam!")
>>> parse.to_json_str()
'{"raw": "Hello, @sam!", "emoticons": [], "links": [], "mentions": ["sam"]}'
See test_msg_parser.py for more interesting examples.