Code Monkey home page Code Monkey logo

nyt-campfinbot's Introduction

A Python-based SlackBot derived from SlackHQ's remarkable RTMBot

Getting started

  • This bot uses MongoDB instead of the filesystem for persistence. You can install MongoDB locally (default) or export CAMPFINBOT_MONGO_URL with your custom connection string.
brew install mongodb
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
  • Create a virtualenv and install the required packages.
mkvirtualenv nyt-campfinbot && pip install -r requirements.txt
  • Create a bot integration for your campfinbot and get the channel ID. Then export the channel ID and the token.
export CAMPFINBOT_SLACK_CHANNEL=C012345
export CAMPFINBOT_SLACK_TOKEN=ABCEFGHIJKLMNOPQRSTUVWXYZ01234567890
  • Export the hosts for preloaded data.
CAMPFINBOT_CANDIDATES_HOST=interactive-api.newsdev.nytimes.com
CAMPFINBOT_FILINGS_HOST=projects.nytimes.com
  • Create the log file if it doesn't exist.
touch /tmp/campfinbot.log
  • Preload data for the bot. It needs some committees and would appreciate knowing about old filings so it doesn't spam your slack channel with stuff you already know about.
python -m campfinbot.preload
  • Run the bot itself.
python -m campfinbot.bot
  • Tail the log to see what's going on.
tail -f /tmp/campfinbot.log

Deployment

Ubuntu Linux

  • Make an Upstart script in /etc/init/campfinbot.conf and use this template.
start on runlevel [2345]
stop on runlevel [!2345]

respawn

script
  export CAMPFINBOT_CANDIDATES_HOST='interactive-api.newsdev.nytimes.com'
  export CAMPFINBOT_SLACK_CHANNEL='C012345'
  export CAMPFINBOT_FILINGS_HOST='projects.nytimes.com'
  export CAMPFINBOT_SLACK_TOKEN='xoxb-1234567890-AbcDefGhijkLmNOpQRstUvWXyz'
  export CAMPFINBOT_PRD_HOST='ec2-0-0-0-0.compute-99.amazonaws.com'
  export CAMPFINBOT_MONGO_URL='127.0.0.1:12345'
  cd /home/ubuntu/nyt-campfinbot && /home/ubuntu/.virtualenvs/nyt-campfinbot/bin/python /home/ubuntu/nyt-campfinbot/campfinbot/bot.py
end script

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.