Browse Tag: how to

Create a Reddit Novelty Bot that Replies to User Comments using Python

I’ve been learning to program using Python recently and started making simple bots that can be used on Reddit. I created a Chat Bot that will reply questions asked on /r/AskReddit recently and wanted to make something a little more lighter and meme worthy. I created a bot that searches for people that say ‘Sad.’ at the end of a sentence and replies with ‘this is sad, alexa play despacito’. its basically two memes in one. A lot of people now add ‘Sad.’ to the end of their comments and I reply with the ‘alexa play despacito’ meme. It’s a very simple bot that shows you how to search all users comments and you can change the parameters however you see fit. If you think of other idea’s for simple reply’s please let me know in the comments below.

I programmed the Reddit Bot in Python and use Reddit’s API Wrapper (PRAW) that lets me easily search for Reddit comments and post reply’s. I use my Raspberry Pi to run my bot since my Raspberry Pi is always on and connected to the internet. Using the Raspberry Pi allows my bot to be running 24/7 which is nice to watch it respond to people all the time. you can view my bot in action by searching for the Reddit username /u/very_slowly

Objective

To create a Reddit Bot that automatically replies to comments that end in ‘Sad.’

Material

You will need the following:

Instructions

I will go over the functions and steps I used to create my Reddit bot below and try to explain what I am going to get the Bot the work. At the bottom I will combine everything together. You should be able to simply copy and paste the final code into Python, add your bot’s API credentials and it will start replying to comment

Continue Reading

Create a Reddit Bot that automatically replies to Questions on AskReddit using Python

I recently published an article on creating a basic Reddit Chatbot you would be able to ask it questions and it would search Reddit for the answer and reply with an answer. This is an upgraded version of the previous Reddit bot I created except this one will actually post replies on Reddit and other users will assume it is a real person replying to their questions. I used Reddit s PRAW library that uses the Reddit API and makes it very easy to search for submissions and grabbing comments and posting reply’s on Reddit. You will need to install the PRAW library in Python to use this script.

The way the script works is it monitors /r/AskReddit for new submissions and grabs the title of the new submission. After it grabs the title it will search Reddit using the title and try to see if the question was asked before. If it was asked before it will look at the comments to that question, grab a random comment and reply to the new submission with the grabbed comment. Its actully very ingenious and has a very high confidence rating when replying to submissions.

I use my Raspberry Pi to run my bot since my Raspberry Pi is always on and connected to the internet. Using the Raspberry Pi allows my bot to be running 24/7 which is nice to watch it respond to people all the time.

Objective

To create a Reddit Bot that automatically replies to Questions on the AskReddit subreddit using Python

Material

You will need the following:

Instructions

I will go over the functions and steps I used to create my Reddit bot below and try to explain what I am going to get the Bot the work. At the bottom I will combine everything together. You should be able to simply copy and paste the final code into Python, add your bot’s API credentials and it will start replying to comments.

Continue Reading

How to use VNC to Remote Desktop to the Raspberry Pi

VNC stands for Virtual Network Computing and it allows us to remote into our Raspberry Pi and view a graphic interface of our desktop environment over the network. You can use your mouse and keyboard over the network and have full remote access to the Raspberry Pi over your network. You can even forward your VNC connection over your router or VPN and access your Raspberry Pi from anywhere in the world. We will be using a program called ‘RealVNC‘ to access our Raspberry Pi from any computer on the network. Our Raspberry Pi will act as the server and the computer running RealVNC will be the client.

When you connect to your Raspberry Pi using the VNC software you will get a Remote Desktop view that opens in a new Window and you can minimize and maximize it. You can also set up your Raspberry Pi without a monitor and use the Remote Desktop connection as your monitor. Installing the VNC on your Raspberry Pi is very easy and doesn’t require much configuration since Raspbian sets up VNC pretty easy right out of the box.

Objective

To use VNC to access our Raspberry Pi Remotely

Material

You will need the following:

Instructions

I will assume you are running Raspbian on your Raspberry Pi. I have tested this procedure with a Raspberry Pi running Stretch, but it should work for older and new builds. If there are any issues just leave a comment below.

You’ll need access to your Raspberry Pi to run some commands. You can also run these commands over SSH if you have enabled SSH in case you Raspberry Pi is headless and running without a monitor. You can enable SSH by following the tutorial here.

Continue Reading

How to Enable SSH on a Headless Raspberry Pi 3

With recent releases of Raspbian (Jessie+) the SSH is disabled by default. The Raspberry Pi foundation has done this to improve security on the many Raspberry Pi’s out there. Leaving SSH enabled by default allows hackers to target your Raspberry Pi and gain access to you system and network if your Raspberry Pi is being run as a web server or connected to the internet. Enabling SSH will allow you to remotely connect to your Raspberry Pi. You will not see the full desktop, only a command line. Using SSH to remotely connect to your Raspberry Pi will allow you to perform updates or install software from another computer on your network.

Objective

To enable SSH on a Raspberry Pi running Raspbian

Material

You will need the following:

Instructions

I will assume you are running Raspbian on your Raspberry Pi. Since we will be running a headless Raspberry Pi, which means no monitor will be connected, we will need to edit the /boot/ folder of our Raspberry Pi SD card. After you burn the Raspberry Pi image onto your SD card open the /boot/ folder on the image and create a file called ssh. You do not need to edit the file or add any content to the file. As long as the ssh file is in the /boot/ partition of the Raspberry Pi you are good to go. Continue Reading

How to Build a Raspberry Pi TorrentBox

If you already use your Raspberry Pi as a server then you’ll want to add some torrent capabilities to it. Even if you are not using your Raspberry Pi as a server you can turn your Raspberry Pi into a torrent box using a very popular torrent program called Transmission. You may have heard of Transmission before, it comes pre-installed on many popular Debian based Linux distro’s.

Transmission is usually a standalone program you can use to manage your torrents but today I will be showing your how to install Transmission on your Raspberry Pi and run and manage your torrents from your browser. This is beneficial because you can download torrents from anywhere in your house and connect your Raspberry Pi to a Network Attached Storage and store your files there. If you have a VPN at home you can even connect to your network and tell your Raspberry Pi TorrentBox what to download.

I currently have my Raspberry Pi running a network wide adblocker, Kodi, and a Raspberry Pi VPN and found that it can handle running a torrent client like Transmission with ease. Transmission really doesn’t take up to much process power and the Raspberry Pi runs the web GUI with ease.

Objective

To install a torrent client onto our Raspberry Pi and turn our Raspberry Pi into a TorrentBox

Material

You will need the following:

Instructions

I will assume you are running Raspbian on your Raspberry Pi. You can also follow this tutorial for any Debian based Linux distro. I have Rasbian Jessie Lite installed on my Raspberry Pi and will be connecting to my Pi over SSH to install Transmission.

Continue Reading

How to Setup a Raspberry Pi Plex Server

In this tutorial I will be showing how to turn your Raspberry Pi into a Plex Media Server. Plex is a Client/Software media player which organizes all your TV Shows, Movies, and Music and allows you play them on any of your devices. The Plex Server will store all your media and will transmit the media to your client, which can be your Phone, TV, Tablet, XBox, Chromecast or even your Raspberry Pi running RasPlex, the possibilities are endless since the Plex Client is available for almost every device. You can also setup your Raspberry Pi Plex Server to allow you to take your media anywhere by setting it up to be available outside of your network.

The Plex Media Server will also trans-code your media on the fly so that you can play any media file on any device, even if the client device doesn’t support the media file. This is why I recommend loading the Plex Server on the Raspberry Pi 3, it will work on the Raspberry Pi 2 as well. The Raspberry Pi 3 will work the best since it has the fastest processor, I would not recommend running the Plex Server on the original Raspberry Pi.

Objective

To install the Plex Media Server on our Raspberry Pi 3

Material

You will need the following:

Instructions

I will be installing the Raspberry Pi Plex Server remotely to my Raspberry Pi over SSH. I will be running my Raspberry Pi as a server without a monitor which will allow me to control it from any other computer over SSH. I will assume you know how to SSH into your Raspberry Pi server.

Install the Raspberry Pi Plex Server

SSH into your Raspberry Pi and run the apt-get update and upgrade commands to get our Raspberry Pi software up to date before we start installing our Plex Server. Run the following commands: Continue Reading