From b002c4e24f8b942274d6681d318f86f53c5fe922 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 31 May 2017 23:00:04 +0200 Subject: [PATCH] Initial commit --- .gitignore | 1 + README.md | 19 +++++++++++++++++++ logger.js | 18 ++++++++++++++++++ package.json | 19 +++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 logger.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/README.md b/README.md new file mode 100644 index 0000000..37e0bc0 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# listenlogger + +Quick-and-dirty tweet logger for listentotwitter.com. + +Setup (after cloning the repository): + +``` +npm install +``` + +Usage: + +``` +node logger.js bbcdebate +``` + +... where `bbcdebate` is the query you want to listen for. + +All data is output to stdout in newline-delimited JSON format, and can be redirected to a file, passed through `jq`, and so on. diff --git a/logger.js b/logger.js new file mode 100644 index 0000000..6cf3d0b --- /dev/null +++ b/logger.js @@ -0,0 +1,18 @@ +'use strict'; + +const socketIO = require("socket.io-client"); + +let client = socketIO.connect("http://ws.listentotwitter.com"); + +function heartbeat() { + client.emit('ping', {keyword: process.argv[2]}); +} + +client.on("tweet", (data) => { + console.log(JSON.stringify(data)); +}); + +client.on("connect", () => { + heartbeat(); + setInterval(heartbeat, 3000); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..f231908 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "listenlogger", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git@git.cryto.net:joepie91/listenlogger.git" + }, + "keywords": [], + "author": "Sven Slootweg", + "license": "WTFPL", + "dependencies": { + "socket.io-client": "^0.9.17" + } +}