So, I just bought a Pi (should be here early next week) to make a TwitterBot and I was wondering if anyone knew if you can have multiple bots on one Pi. I've searched around some and can't find anyone talking about it. I was wanting to post replies to tweets. I was going to start off simple and maybe just reply with a standard message, but who knows what I'll get into. I was also thinking about retweeting some tweets with specific hashtags and/or from specific people.
There is nothing to prevent you from running multiple twitterbots on one pi, as a twitter bot isn't really one specific program or script it is merely the concept of having a computer operate a twitter account. Furthermore the way twitter bots communicate with twitter is through their apps api you can create your own twitter bot by following the steps below.
(keep in mind that this tutorial assumes that you have a twitter account with a phone number linked already set up) 1. navigate to https://apps.twitter.com/ and click on the create new app button. and enter the following:
a. Name of your application b. Description c. Link to valid URL (keep in mind this can be changed later)
2. We are now going to update our pi from the terminal by running:
sudo apt-get update sudo apt-get upgrade
3. We are now going to install a package called twython which is my preferred way to interact with the twitter api, By running the following:
sudo apt-get install python-setuptools sudo easy_install pip sudo pip install twython
4. we are going to create a file for our script:
sudo nano mohammad.py
5. We are now going to write a short script that will interact with our twitter account(s):
#!/usr/bin/env python import sys from twython import Twython tweetData = "Mohammad-ALi is the coolest man alive, he taught me how to make a bot interact with my twitter account" # your twitter consumer and access information goes here # please replace the hashtags with your credentials apiKey = '#' apiSecret = '#' accessToken = '#' accessTokenSecret = '#' api = Twython(apiKey,apiSecret,accessToken,accessTokenSecret) #Establishes a connection to twitter servers api.update_status(status=tweetData)
- now all thats left to do is to save and close by pressing
ctrl + x
and run the script by entering the following into the terminal:
here is the part where you check your twitter account as you can see from above twitter bots simply establish connections to twitter servers, so if you where to call the function
Twythonagain you would be able to have two active connections to different twitter accounts, and keep in mind this may be done a virtually limitless number of times.