This code takes a chat message string and returns a JSON string containing information about its contents.
-
@mentions - A way to mention a user. Always starts with an '@' and ends when hitting a non-word character. (http://help.hipchat.com/knowledgebase/articles/64429-how-do-mentions-work-)
-
Emoticons - We need to consider 'custom' emoticons which are ASCII strings, no longer than 15 characters, contained in parenthesis. You can assume that anything matching this format is an emoticon. (http://hipchat-emoticons.nyh.name)
-
Links - Any URLs contained in the message, along with the page's title.
For example, calling your function with the following inputs should result in the corresponding return values.
Input: "@chris you around?"
Return (string):
{
"mentions": [
"chris"
]
}
Input: "Good morning! (megusta) (coffee)"
Return (string):
{
"emoticons": [
"megusta",
"coffee"
]
}
Input: "Olympics are starting soon; http://www.nbcolympics.com"
Return (string):
{
"links": [
{
"url": "http://www.nbcolympics.com",
"title": "NBC Olympics | 2014 NBC Olympics in Sochi Russia"
}
]
}
Input: "@bob @john (success) such a cool feature; https://twitter.com/jdorfman/status/430511497475670016"
Return (string):
{
"mentions": [
"bob",
"john"
],
"emoticons": [
"success"
]
"links": [
{
"url": "https://twitter.com/jdorfman/status/430511497475670016",
"title": "Twitter / jdorfman: nice @littlebigdetail from ..."
}
]
}Assumptions:
1.0
The project can be tested 2 ways.
I) CLI :
- Run
messageDecode.pylike a normal python script - Provide your own chat string (please see above section for examples)
- Get the formatted JSON output in the console.
II) Webapplication :
The webapp is not hosted but a demo is given @ (https://www.youtube.com/watch?v=Ou1nndcva54&feature=em-upload_owner)
Following are the ways of installing and testing the webapp.
a) Git repo clone:
$ git clone https://github.com/rsubra13/atlasproj.git
b) Installing virtualenv
It is a good practice to install all the packages in a virtual environment.
$ cd venv
$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip...done.
In Unix-Like Systems
$ source venv/bin/activate
In Windows-Systems
$ source venv/Source/activate
$ pip install -r requirements.txt
Presently there is an error while installing requirements.txt
"pg_config executable not found".
This can be overcome by installing "libpq-dev" and "python-dev".
$ sudo apt-get install libpq-dev python-devc) PostGRESQL server
- Make sure PostGRESQL is installed in your and system and it is running properly. Please create the database and use the POSTGRES connection string as given in
config.py
d) Startup script
$ python run.py