-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment.rtf
More file actions
50 lines (45 loc) · 2.56 KB
/
Assignment.rtf
File metadata and controls
50 lines (45 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf340
{\fonttbl\f0\fswiss\fcharset0 ArialMT;}
{\colortbl;\red255\green255\blue255;\red38\green38\blue38;\red16\green60\blue192;\red26\green26\blue26;
}
\margl1440\margr1440\vieww22700\viewh13820\viewkind0
\deftab720
\pard\pardeftab720\partightenfactor0
\f0\fs28 \cf2 \expnd0\expndtw0\kerning0
Please write a solution that takes a chat message string and returns a JSON string containing information about its contents. Special content to look for includes:\
1. @mentions - A way to mention a user. Always starts with an '@' and ends when hitting a non-word character. ({\field{\*\fldinst{HYPERLINK "http://help.hipchat.com/knowledgebase/articles/64429-how-to-mentions-work-"}}{\fldrslt \cf3 \ul \ulc3 http://help.hipchat.com/knowledgebase/articles/64429-how-to-mentions-work-}})\
2. Emoticons - For this exercise, you only need to consider 'custom' emoticons which are alphanumeric strings, no longer than 15 characters, contained in parenthesis. You can assume that anything matching this format is an emoticon. ({\field{\*\fldinst{HYPERLINK "https://www.hipchat.com/emoticons"}}{\fldrslt \cf3 \ul \ulc3 https://www.hipchat.com/emoticons}})\
3. 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" ] \}
\fs26 \cf4 \
\fs28 \cf2 Input: "Good morning! (megusta) (coffee)"\
Return (string):\
\{ "emoticons": [ "megusta", "coffee" ] \}
\fs26 \cf4 \
\fs28 \cf2 Input: "Olympics are starting soon;{\field{\*\fldinst{HYPERLINK "http://www.nbcolympics.com/"}}{\fldrslt \cf3 \ul \ulc3 http://www.nbcolympics.com}}"\
Return (string):\
\{\
"links": [\
\{ "url": "{\field{\*\fldinst{HYPERLINK "http://www.nbcolympics.com/"}}{\fldrslt \cf3 \ul \ulc3 http://www.nbcolympics.com}}", "title": "NBC Olympics | 2014 NBC Olympics in Sochi Russia" \}
\fs26 \cf4 \
\fs28 \cf2 ]\
\}\
Input: "@bob @john (success) such a cool feature; {\field{\*\fldinst{HYPERLINK "https://twitter.com/jdorfman/status/430511497475670016"}}{\fldrslt \cf3 \ul \ulc3 https://twitter.com/jdorfman/status/430511497475670016}}"\
Return (string):\
\{\
"mentions": [\
"bob",\
"john"\
],\
"emoticons": [\
"success"\
],\
"links": [\
\{ "url": "{\field{\*\fldinst{HYPERLINK "https://twitter.com/jdorfman/status/430511497475670016"}}{\fldrslt \cf3 \ul \ulc3 https://twitter.com/jdorfman/status/430511497475670016}}", "title": "Twitter / jdorfman: nice @littlebigdetail from ..." \}
\fs26 \cf4 \
\fs28 \cf2 ]\
\}\
}