Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Latest commit

 

History

History
98 lines (83 loc) · 2.69 KB

README-local.md

File metadata and controls

98 lines (83 loc) · 2.69 KB

Running Locally

Redis Setup

  • Download redis and activate your redis server -> youtube example
  • Start running your redis-server
  • Next open your redis-cli
    • Be sure to change the requirepass within your config to secure your server
    • Within redis-cli// > config get requirepass
      1. "requirepass"
      2. "This Will Be Empty"
  • Set your password
    • Within redis-cli// > config set requirepass yourPasswordHere (recommended >= 32 characters)

Docker Setup (if you don't want to use Docker skip to here)

Build and Run Docker Images

Build your image and then run the image as a Docker container with the commands below.

  • FIRST cd into your working directory with Dockerfile and bot.py
$ docker build twitter-bot

$ docker run -d \
  --name bot_name \
  --restart unless-stopped \
  -e CONSUMER_KEY="some consumer ID" \
  -e CONSUMER_SECRET="some consumer secret KEY" \
  -e KEY="some key ID" \
  -e SECRET="some secret key ID" \
  -e REDIS_PASS="some password" \
  -v $PWD:/work \
  twitter-bot

Pull from previous build (optional)

docker pull bot-name \
&& docker run -d \
  --name bot_name \
  --restart unless-stopped \
  -e CONSUMER_KEY="some consumer ID" \
  -e CONSUMER_SECRET="some consumer secret KEY" \
  -e KEY="some key ID" \
  -e SECRET="some secret key ID" \
  -e REDIS_PASS="some password" \
  bot-name

Build & Push to remote portainer

Make sure you are in the directory that has your Dockerfile and bot script

docker build --no-cache -t 10.0.0.1:PORT/bot-name .

docker push 10.0.0.1:PORT/bot-name

Running locally without Docker

Dependencies

You will need to pip install the following packages if you want to run this bot locally without Docker.

  • Using requirements.txt
pip install -r requirements.txt
  • pip install manually
pip install redis
pip install schedule
pip install tweepy

# If you don't plan on using sentiment analysis ignore these
pip install matplotlib
pip install numpy
pip install pandas
pip install seaborn
pip install textblob

Setup local Environment

  • Be sure to cd into your working directory that contains your bot.py script
  • Export your variables so you can access them with os.getenv() (Mac OS)
export CONSUMER_KEY="your key" \
&& export CONSUMER_SECRET="your secret" \
&& export SECRET="your secret"\
&& export HOST="external ip address" \
&& export REDIS_PASS="your redis password"\
&& export KEY="your key"
  • Now you are ready to run your script
python bot.py