Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
152 lines (97 sloc) 4.64 KB

How To Replace Yourself With A Bot

Procedure

  1. Review what a twitter bot is
  2. Create a low-tech bot
  3. Cover a basic bot script/system
  4. Break into groups/teams to work on bots

#What is a twitter bot?

  • Automated posts on the Twitter microblogging service.
  • Yes - some are spam to entice clicks. Others post @replies or automatically retweet in response to tweets that include a certain word or phrase.
  • 24% of tweets that are on Twitter? source: Mashable
  • new art form
  • internet as poetry
  • experimental, weird, community

Bot styles

Chatbot, datamining, markov chains, visual generation, text generation, mashup/text remixing, scheduled tweets, response bots...

#Some Twitter bots

Bot Approaches / Low Tech v. High Tech

Low Tech

  • Start With a Concept
  • Find/write/develop your text
  • You type out your tweets in advance.
  • You use a scheduler like Hootsuite, Buffer or Botize. Or a simple script/program like IFTTT.

High Tech

  • Using cronjobs
  • cron is a daemon, meaning it starts once and stays dormant until it is needed (a web server is also a daemon. it waits for a user to type in the url to load.)

Register a new twitter name/handle

  • Note: You can make many accounts under same email address if you use YourEmail+NewTwitterHandle@gmail.com for example (you can do this while using private browse so you can have mulitple accounts open at once)
  • Verify via email after making new account

Register a new app on twitter & get access tokens/keys

  • Go to https://apps.twitter.com/
    • You need to register a phone number (arrrgh) if not already done. Must be unique!
  • Create new app
  • Go to Keys and Access Tokens tab
  • Access Level should be: Read and write
  • At bottom of page click the button to generate access tokens

Getting started With twitter in Python

  • We'll be installing tweepy to access twitter in Python
  • Open the command line/terminal shell and run this in Bash

Linux

sudo apt-get install python-pip

OR

Mac

sudo easy_install pip #if not already installed
pip install virtualenv
pip install tweepy

Create your python bot

  • Example script such as scriptname.py
  • Add your access tokens and keys
  • Test it in your terminal with python scriptname.py

Sign up on digital ocean

  • DigitalOcean is a virtual private server
  • You create droplets aka virtual (cloud) servers
  • Sign up for an Ubuntu server
  • You will be emailed an ip address, etc, prompted to change emails
  • Log in

Login via ssh

Steps are here

Connect to your server via ssh

Steps are here

Upload Your Script

  • You can upload to your server with scp

scp <path/to/file/on/your/computer> <username>@<hostname>:<destination path>

for example

scp /Users/2sman/Documents/code/github\ projects/Gamelan_Ebooks/gamelan* admin@45.55.87.237:~

Re-install what you need on remote

Getting started With twitter in Python

  • We'll be installing tweepy to access twitter in Python
  • Install pip on digitalocean server to root
apt-get update
sudo apt-get install python-pip
pip install tweepy

Create a cronjob

  • first you need to add cron

sudo apt-get install cron

  • Run crontab -e and you may have to select nano (2) as your editor
  • Add to bottom 0 * * * * python script.py to have it run once an hour

Additional things/links