Skip to content

urbanriskmap/cognicity-reports-twitter

 
 

Repository files navigation

CogniCity

Open Source GeoSocial Intelligence Framework

Travis build status: Build Status

DOI for current stable release v2.0.0: DOI

####cognicity-reports-powertrack: Module for cognicity-reports module to collect unconfirmed reports from Twitter via public API and send verification requests.

About

Cognicity-reports is the NodeJS reports module for the CogniCity framework, responsible for collecting relevant tweets, and sending users verification messages via Twitter. For detailed framework documentation see http://cognicity.info.

Dependencies

Node Modules

  • Check package.json for details

Installation

Download the source code for cognicity-reports from github: http://github.com/smart-facility/cognicity-reports or view the CogniCity installation documentation at http://cognicity.info.

Install the node dependencies in package.json using NPM: npm install

PostgreSQL/PostGIS schema

These can be found in the cognicity-schema repository and consist of

  • createdb.sql, which creates an empty database for cognicity, and
  • schema.sql, which adds PostGIS support and builds the relational schema for cognicity. These scripts need to be run in that order in order to set up the database, e.g.
psql -U postgres -h hostname -f createdb.sql
psql -U postgres -h hostname -d cognicity -f schema.sql

Platform-specific notes

To build on OS X we recommend using homebrew to install node, npm, and required node modules as follows:

brew install node
npm install

To build on Windows we recommend installing all dependencies (making sure to use all 32 bit or all 64 bit, depending on your architecture) plus following the instructions (for Windows 7 follow the Windows 7/8 instructions) for node-gyp and then:

  • You need to add C:\Program Files\PostgreSQL\9.3\bin (modifying that location if necessary to point to the installed version of PostgreSQL) to path so the build script finds pg_config, and
  • You need to create the %APPDATA%\npm folder and run cmd (and hence npm) as administrator. %APPDATA% is usually under C:\Users\your_username\AppData\Remote. Then you can run npm install.

Configuration

App configuration parameters are stored in a configuration file which is parsed by app.js. See sample-reports-config.js for an example configuration.

Twitter send parameters

  • send_enabled [true | false] - set to true to enable confirmation request tweets to be sent.
  • addTimestamp [true | false] - if true, append a timestamp to each sent tweet.
  • url_length - The length of the twitter t.co URL shortened URLs (see https://dev.twitter.com/overview/t.co ).

Twitter account configuration

Set the app authentication parameters as provided by Twitter. See the ntwitter-module documentation for more details.

  • usernameReplyBlacklist - Twitter usernames (without @, comma separated for multiples) which will never be sent to in response to tweet processing
  • usernameVerify - Twitter username (without @) authorised to verify reports via retweet functionality

Twitter stream parameters

  • bbox - bounding box coordinates for area of interest (lat, long) cognicity-reports will collect all geo-located tweets in the specified area, and then filter by keyword
  • track - keywords, cognicity-reports will collect all tweets (geo-located and non-spatial) which contains these words
  • city - specify user city to help filter tweets without geolocation data
  • users - the Twitter account usernames designated for confirmation tweets.
  • send_enabled [true | false] - set to true to enable confirmation request tweets to be sent.
  • stream [true | false] - set to true to connect to twitter stream.
  • timeout - if no tweet is received in this time (in ms) connection will be reestablished

Messages

Messages can be at most 109 characters long if addTimestamp is enabled, or 123 characters long if addTimestamp is disabled. Note that this length includes one shortened URL at current lengths - see https://dev.twitter.com/overview/t.co for details.

  • invite_text - Text for confirmation request tweets
  • thanks_text - Thank-you message for confirmed tweet

Postgres connection

Run

The app is run as a background process using the Daemonize 2 library. The process name is set to the configuration instance config.instance defined in the configuration file.

$ cd cognicity-server/
$ node daemon.js sample-config.js start
project-name daemon started. PID 1000

$node daemon.js sample-config.js status
project-name running

$node daemon.js sample-config.js stop
project-name daemon stopped

Logging

Express logger writes to project-name.log

License

This software is released under the GPLv3 License. See License.txt for details.

About

cognicity-reports: NodeJS app - Twitter support for the CogniCity framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%