0

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.

  • Your going to have to elaborate on what your "Twitter bot" is doing, and where the code is coming from, if you could share the code as an edit into your answer that would be great. – Mohammad Ali Aug 4 '16 at 4:57
  • Well, I haven't received my Pi yet, so I can't tell you in detail...but, 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. – WallbrownF Aug 4 '16 at 4:59
  • 2
    I'm not defending anyone here (shudder) but I would prefer not to see the door opened on political arguments, or "I want to get back at Assad/Putin/Taylor Swift/The Green Party/whatever..." type material (which is borderline spam), so please refrain. I think you have a legitimate technical question and that is fine. By "elaborate" I assume Mohammad Ali meant in a technical sense, not whom you were hoping to tweet to and what about. That's your own business. – goldilocks Aug 4 '16 at 11:01
  • 1
    One additional comment. In order to make tags useful to all users of the site it's advisable to use only those of relevance to the question. Here you used raspbian and windows-iot (pick the relevant) and also Pi-2 and Pi-3. You probably know which Pi you ordered, just pick the right one - or going a little further on that - in the end this question is probably completely independent of the specific hardware. – Ghanima Aug 4 '16 at 11:29
3

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) 
  1. now all thats left to do is to save and close by pressing ctrl + x
  2. and run the script by entering the following into the terminal:

    python mohammad.py
    
  3. 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 Twython again 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.

| improve this answer | |
  • You're the best. Now, I just need to get my Pi. Very excited. – WallbrownF Aug 5 '16 at 1:08
  • not a problem, you can always start writing your python script on your pc, as python is pretty much the same on all platforms. – Mohammad Ali Aug 5 '16 at 1:09
  • So, end of step three: – WallbrownF Aug 9 '16 at 20:50
  • @WallbrownF is that a statement or a question? – Mohammad Ali Aug 9 '16 at 20:53
  • 'code' pi@raspberrypi:~$ sudo pip install twython Downloading/unpacking twython Cannot fetch index base URL pypi.python.org/simple Could not find any downloads that satisfy the requirement twython Cleaning up... No distributions at all found for twython Storing debug log for failure in /root/.pip/pip.log 'code' Also, I don't know if this has anything to do with it, but I've also been trying to setup remote access to my pi through my home network (PuTTY, TightVNC, Windows Remote Desktop) and I have failed multiple times. I'm also using WiFi for the bot. – WallbrownF Aug 9 '16 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.