Chat parsing library written with JSPM, SystemJS and the Fetch API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Josh Habdas e07aedf190 Update url 3 years ago
dist Repackage distributable for 1.1.0 4 years ago
lib Add Travis-CI support 4 years ago
.editorconfig Initial commit 4 years ago
.gitignore Add support for Fetch API and Docker 4 years ago
.travis.yml Disable CI email notifications 4 years ago
CHANGELOG.md Update NPM start script; bump for patch release 4 years ago
Dockerfile Be more descriptive 4 years ago
LICENSE Initial commit 4 years ago
README.md Be more terse 3 years ago
config.js Initial commit 4 years ago
index.html Initial commit 4 years ago
package.json Update url 3 years ago

README.md

Xanthippe

Build Status

Introduction

Xanthippe takes a chat message string and returns a formatted JSON string containing information about its contents.

Features

  • Parses @mentions, (emoticons) and links with standard URLs
  • Dynamically fetches link titles to build custom link objects
  • Optimizes JSON payload by trimming empty results
  • Supports emoticons up to 15 characters

Installation

  • git clone git@github.com:jhabdas/xanthippe.git xanthippe && cd $_
  • npm install -g jspm && jspm install until #535 is resolved
  • open ./dist/index.html in browser with CORS enabled, or use a reverse proxy

Usage

const string = '@bob @john (success) such a cool feature; https://twitter.com/jdorfman/status/430511497475670016  http://localhost:8000 @josh'
new Matchmaker(string, (matches => console.log(matches)), 'fetch');

logs the following:

{
  "mentions": [
    "bob",
    "john",
    "josh"
  ],
  "emoticons": [
    "success"
  ],
  "links": [
    {
      "url": "https://twitter.com/jdorfman/status/430511497475670016",
      "title": "Justin Dorfman on Twitter: "nice @littlebigdetail from @HipChat (shows hex colors when pasted in chat). http://t.co/7cI6Gjy5pq""
    }
  ]
}

Third argument to Matchmaker constructor is optional. Supports Fetch API with 'fetch' specified. Defaults to 'qwest' for Ajax otherwise.

Hacking

From source

  • git clone git@github.com:jhabdas/xanthippe.git xanthippe && cd $_
  • npm install && npm start

Starts web server on port 8000 with index.html at web root.

With Docker

  • docker pull jhabdas/xanthippe to get Hub image
  • docker run -d -P jhabdas/xanthippe to run daemonized

Use docker ps to verify process is running and show port forwarding details.

File Structure

├── dist                      # Self-executing distributable
├── jspm_packages             # Packages installed by JSPM
├── lib                       # Source files
│   ├── main.js               # Bootstrapper
│   ├── utils.js              # Utilities
│   └── xanthippe.js          # Chat parser
├── node_modules              # Packages installed by NPM
├── config.js                 # JSPM configuration file
├── index.html                # Development HTML file
└── package.json              # Project dependencies and configuration

Bundling

Unbundled (for development)

jspm unbundle

Bundled (for testing)

jspm bundle lib/main --inject

Distributable (for production)

jspm bundle-sfx lib/main ./dist/lib.js --minify --skip-source-maps

Languages

Libraries

  • Babel (with polyfill) — 6to5 transpiler and more
  • jspm — Frictionless browser package management
  • qwest (optional) — Ajax library with XHR2, promises and requests limitation