How to set up a curation bot on raspberry pi

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@ubg·
0.000 HBD
How to set up a curation bot on raspberry pi
## <center> Introduction</center>
If you feel like trusting your keys to external sites is not a great way to curate content, I've got a 35 dollar lifetime solution for you. Not that many people know that steemit curation bots can even be built on your mobile phones, since singing transactions takes little to no computational power.
<center>https://i.imgur.com/fD12skM.png</center>
In this tutorial, I'll be showing you how to set up a curation bot on a small arm processor machine, that takes up little to no power, so you can run it with almost no running costs. The specific machine that I'm going to use is __Raspberry Pi 2 Model B__ however the same process applies to any other Raspberry Pi models, Arduino, BeagleBone or any other device that can run linux.
## <center> Needed programs/files/accessories</center>
__Raspberry Pi__ - https://www.amazon.com/Raspberry-Pi-RASP-PI-3-Model-Motherboard/dp/B01CD5VC92

-------
__Wifi dongle__ - https://www.amazon.com/FotoFo-USB-WiFi-Adapter-Raspberry/dp/B01I191N48

--------
__Micro SD card__ - https://www.amazon.com/SanDisk-microSD-High-Capacity-microSDHC/dp/B00488G6P8

---
__Micro SD card reader__ - https://www.amazon.com/IOGEAR-MicroSD-Reader-Writer-GFR204SD/dp/B0046TJG1U

---
__A copy of raspian(any other linux based operating system will work as well)__ - https://www.raspberrypi.org/downloads/raspbian/
Make sure to download the pixel version. 
If you have larger than 8gb sd card I'd reccommend Ubuntu mate located here - https://ubuntu-mate.org/raspberry-pi/
You might even consider rokos OS if you want to stake your favorite altcoins meantime - http://rokos.space/core.html

----
__SDFormatter__ - https://www.sdcard.org/downloads/formatter_4/index.html

----
__etcher__ - https://etcher.io/

----
__Bitwise SSH client__ - https://www.bitvise.com/ssh-client-download

---
### <center> Step by step tutorial </center>
### 1. Format the Micro SD card
Get and install __SDFormatter__, when that is done insert your Micro SD card to the reader,  open up SDFormatter and make sure format size adjustment is swiched on. Then format the SD card.
<center>http://imgur.com/DlD8EYz.gif</center>
### 2. Burn raspbian on the SD card
We're going to use Etcher for this process. Burning the image on the SD card is fairly simple and straight forward.
<center>https://i.imgur.com/2K9NDwS.gif</center>
### 3. Install raspbian on your raspberry pi and log into your wifi
Installing rasbian is done automatically, you just have to wait until it boots up. After it's done booting, just log into your wifi and write down your local ip for the device. You'll be using this ip to ssh into the device.
<center>https://i.imgur.com/sE9Eleh.jpg</center>
### 4. SSH into your raspberry with bitvise
<center>https://i.imgur.com/AkQBOL0.png</center>
The default username is : __pi__
The default password is: __raspberry__
### 6. Install piston and all other prerequisites
bitvise will open up a terminal along with a ftp tunnel, paste the following commands into the terminal to install piston
##### Install screen
	sudo apt-get install screen
##### Install python with all piston the prerequisites
	sudo apt-get install python3
	sudo apt-get install python3-dev
	sudo apt-get install python3-pip

	sudo apt-get install git make automake cmake g++ libssl-dev autoconf libtool
	sudo apt-get install libboost-thread-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-signals-dev libboost-serialization-dev libboost-chrono-dev libboost-test-dev libboost-context-dev libboost-locale-dev libboost-coroutine-dev libboost-iostreams-dev
	sudo apt-get install doxygen perl libreadline-dev libncurses5-dev


##### install piston
	sudo pip3 install steem-piston

Just paste all of theese commands into your terminal one by one to intsall piston with all of the prerequisites
### 7. Compile the curation bot script
Make a new folder on your desktop called bot, then create 2 files in that folder called bot.py and votelist.txt
so it would look like this
<center>https://i.imgur.com/Vr2fb4M.png</center>
You can just create 2 text files and rename the extensions to get the .py extension.

##### Edit the bot.py file and paste the following code inside:
	from steem.steem import Steem
	from steem.steem import BroadcastingError
	import threading
	import time
	import random
	import csv
	 
	my_subscriptions = []

	 
	with open('votelist.txt', mode='r') as infile:
		reader = csv.reader(infile)
		for rows in reader:
			v = rows[0]
			my_subscriptions.append(v)
	 
	# accounts and passwords
	account = ["account_goes_here"]
	posting_key = ["password_goes_here"]
	# delay in seconds when the bot votes
	vote_delay = random.randrange(1200,1800)
	
	upvote_history = []
	 
	def feed():
		print("Waiting for new posts by %s\n\n\nGo Oprah!\nGo Winfrey!" % my_subscriptions)
		steem = Steem(wif=posting_key[0])
		for comment in steem.stream_comments():
	 
			if comment.author in my_subscriptions:
				# Comments don't have titles. This is how we can know if we have a post or a comment.
				if len(comment.title) > 0:
	 
					# check if we already upvoted this. Sometimes the feed will give duplicates.
					if comment.identifier in upvote_history:
						continue
	 
					print("New post by @%s %s" % (comment.author, url_builder(comment)))
					workerThread = threading.Thread(name=comment.identifier, target=worker, args=(comment,))
					workerThread.start()
	 

	def url_builder(comment):
		return "https://steemit.com/%s/%s" % (comment.category, comment.identifier)
	 
	def worker(worker_comment):
		 time.sleep(vote_delay)
		 try:
		   for (k,v) in enumerate(account):
			 worker_steem = Steem(wif=posting_key[k])
			 upvote_comment = worker_steem.get_content(worker_comment.identifier)
			 # vote weight 100 full power vote -100 full power flag
			 upvote_comment.vote(100, v)
			 print("@%s====> ^Upvoted^" % upvote_comment.author)
			 upvote_history.append(upvote_comment.identifier)
		 except BroadcastingError as e:
		   print("@%s<- failed" % upvote_comment.author)
		   print(str(e))

	 
	if __name__ == "__main__":
		while True:
			try:
				feed()
			except (KeyboardInterrupt, SystemExit):
				print("Quitting...")
				break
			except Exception as e:
				traceback.print_exc()
				print("### Exception Occurred: Restarting...")

### 8. Add your account to the curation bot, also modify the the settings
add your account to "your_account_goes_here"
add your password to "your_password_goes_here"

##### you can also add multiple account by seperating the accounts and keys with a comma like so:
	account = ["account1", "account2"]
	posting_key = ["key1", "key2"]
##### You can modify the delay when the bot votes by altering this line (in seconds)
	vote_delay = random.randrange(1200,1800)
##### You can also modify the vote weight by altering this line (100 being full power and -100 being full power flag)
	upvote_comment.vote(100, v)	
### 9. Add users to the curation list
open up your votelist.txt and add users you want to vote on, each line contains a new user for the bot to vote on
##### So the list would go like so
	ubg
	fyrstikken
	furion
	contentjunkie
	xeroc
	steempowertwins
### 10. Move the files from your desktop to raspberry
After you're done adding accounts to your curation list just via  bitvise ftp tunnel like so
<center>http://imgur.com/krE86Go.gif</center>
### 11. Run your bot
To run your bot, you first need to navigate to the bots folder
##### you do that by typing
    cd bot
##### then you need to run your bot
    screen python3 bot.py
By using that command you're attaching the python script to a screen. So you can close your terminal and log out. 
##### Each time you want to know how the bot is doing you type
    screen -r
<center>https://i.imgur.com/Nh6fKBr.png</center>
If you want to detach the screen use keyboard shortcut ctrl+a+d
If you want to close the script use keyboard shortcut ctrl+c
----

Big thanks to @fyrstikken for releasing the source code for the winfrey bot. 
You can find the original code for the winfrey bot here:  https://steemit.com/socialist-bot/@fyrstikken/the-anonymous-winfrey-bot-upvotes-for-everyone-download-here-easy-steps-for-n00bs
Also if you have any questions regarding setting up your own bot, just ask in the comments or contact @ubg in rocket chat. Also a huge thanks to @noganoo for providing me the piston prerequisites.
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,