Hi there pythonistas. I hope you are all fine. In this post I am going to teach you how we can make a Reddit + Twitter bot. What this bot will do is that it will copy post titles and url from any subreddit that you want and then it will post them to twitter keeping the 140 characters length in mind.

  1. Reddit Twitter Leaks
  2. Reddit Twitter Voicemail
  3. Reddit Twitter Trumpnickelsburggeekwire

Firstly let me tell you what Reddit is. Reddit is a social link sharing site where good links are upvoted and bad links are down voted. So lets start.

Required external libraries

  • Praw - (Reddidt API wrapper in python) pip install praw
  • Requests - (HTTP library) pip install requests
  • Tweepy - (Twitter python API) pip install tweepy

Set up the Reddit trigger, and make magic happen automatically in Twitter. Zapier's automation tools make it easy to connect Reddit and Twitter. The latest tweets from @redditcfb.

First step - Register Yourself

So first of all you will have to register an app on http://dev.twitter.com/apps and after registering copy the

  • access token
  • access token secret
  • consumer key
  • consumer secret
  • 2 days ago  On this episode of Actually Me, Polo G goes undercover on the Internet and responds to real comments from Reddit, YouTube, Instagram, Twitter, Wikipedia and Quora.
  • The latest tweets from @redditstatus.

You will have to edit the permissions for your app under the settings tab and grant your application read and write permission. So now we are ready to move on.

Required imports

So now lets start writing our script. First of all we will have to import the required libraries and set up some basic variables:

Initiating connection with Reddit

Now we have to initiate connection with Reddit. Lets define a function to do just that.

This method connects with Reddit and gets the subreddit of our choice and then returns that subreddit for us to work further with.

Getting posts and links from Reddit

So now we have to define a function that gets the list of posts and there urls from Reddit for us. So lets just do that as well.

First of all we are declaring a dictionary to hold the post title and link and after that we are making a list to hold the unique ids of every post that we grab. This is used to track which posts we have already grabbed.

After that we are looping over the posts and appending values to the dictionary and the list. If you use twitter very frequently then you know that how disgusting long links look like so in order to tackle that we are using goo.gl to generate short links for us. That’s the next thing we have done in the above function. We loop over the post dict and make a short link for every link and append it to a new dictionary which is mini_post_dict.

No one likes long links

Now lets define a function which will actually shorten the links for us. So here it is:

The above function contains a header and a payload which we are going to send to google and after that google will return the short link in the form of json.

Twitter hates more than 140 characters

If you use twitter regularly then I am sure that you know that twitter does not like tweets that are more than 140 characters. So in order to tackle that lets define a function that will truncate long tweets to short ones.

In the above method we will pass a title and the above method will check that whether the title is 93 characters or more. If it is more than 93 characters then it will truncate it and append three dots at its end.

Reddit twitter voicemail

Dealing with duplicate posts

So now we have started to shape our final script. There is one thing that we have to keep in mind. No one likes duplicate posts so we have to make sure that we do not post same tweets over and over again.

In order to tackle this issue we are going to make a file with the name of posted_posts.txt. When ever we grab a post from Reddit we will add it’s ID to this file and when posting to twitter we will check whether the post with this ID has already been posted or not.

Lets define two more functions. The first one will write the IDs to file and the second one will check whether the post is already posted or not.

Make a function for twitter will ya

So now lets make our one of the main function. This function is actually going to post to twitter.

Firstly we setup connection with twitter by using the credentials we defined in the beginning. After that we loop over the post_dict and post_ids. Then we check for duplicate posting. If it is not previously posted then we post it and add the id of the post in the posted_posts.txt file. After posting we wait for 30 seconds so that we do not spam twitter with tweets.

Wheres the main function bud

So lets define our last function. This function will co ordinate with all other functions. Here is the code for that last function:

So now we are ready just add this little line at the end as well:

This checks whether the script is directly executed or is it imported. If it is directly executed only then the main() function is executed.

Complete code

Here is the complete script:

Save this file with the name of reddit_bot.py and make a file with the name of posted_posts.txt and then execute the python script from the terminal. Your output will look something like this:

And after some time your posted_posts.txt file will look something like this:

Reddit Twitter

Goodbye

I hope you enjoyed today’s post as much as I enjoyed writing it. I hope to see you in future with some more tutorials. Do follow my blog to give me some support and get regular updates. Goodbye till next time.

Culture

You might also like

    👉 A surprize for you
    👉 All about the metaclasses in Python!

Reddit is hit by a lawsuit after a woman claimed that the platform allowed her ex-boyfriend to repeatedly post images of her as a 16-year-old in a compromising position.

Reddit Faces Lawsuit

The lawsuit applies controversial measures instituted in 2018 under FOSTA-SESTA to a site that is drawn particular criticism for child sexualization.

The case will test the limits of social media platforms' legal shields amid ongoing efforts to pare back the law behind them.

The woman, with a pseudonym Jane Doe, argues that Reddit knowingly benefits from lax enforcement of its content polices, including sexual content of minors, according to Law 360.

Jane Doe claims that in 2019, an abusive ex-boyfriend posted sexual photos and videos that he had taken without her knowledge or consent.

Also Read: Parent Files Lawsuit Against Epic Games Over 'Predatory' Llama Loot Boxes In 'Fortnite'

But when she alerted Reddit moderators about what happened, she was advised that it would take several days before the content can be removed.

The Reddit administrators allowed the man to keep posting and create a new account when his old account was banned from the platform. Free excel for windows 10.

The complaint reads that because Reddit refused to help, it fell to Jane Doe to monitor more than 36 subreddits, which Reddit allowed her ex-boyfriend to repeatedly use to post sexual photos of her as a minor.

Reddit's refusal to act has meant that for the past several years, Jane Doe has been forced to log on to Reddit and spend hours looking through some of its darkest and most disturbing subreddits so that she can locate the posts of her underage self and fight with the platform to have them removed.

Jane Doe is now seeking a class action suit that also represents those who had similar photos or videos posted on Reddit while they were under 18 years of age.

Reddit is accused of distributing sexual content of minors, failing to report the material, and violating the Trafficking Victims Protection Act. It is not clear if the ex-boyfriend is also sued or is criminally charged already.

FOSTA-SESTA Amendment

The lawsuit cites FOSTA-SESTA, an amendment to Section 230 of the Communications Decency Act that provides a broad legal shield for interactive computer services like Reddit, limiting their liability if users post illegal content.

However, the 2018 FOSTA-SESTA bill removed protections for material related to trafficking.

The lawsuit argues that Jane Doe's case meets that definition because Reddit's advertising revenue turned the inappropriate video into a commercial sex act.

Furthermore, the lawsuit states that Reddit knew its site was a hub for illegal photos and videos, and it should have done more to protect the victims.

The complaint cited numerous past subreddits that had sexually suggestive notes. The forums were since removed after media controversy.

Meanwhile, Reddit denies that it condones abuse.

A Reddit spokesperson said in a statement to The Verge that child sexual abuse material, or CSAM, has no place on the Reddit platform.

The spokesperson continued that they maintain policies and procedures that do not just follow the law, but also go above and beyond it. They deploy both automated tools and human intelligence to proactively detect and prevent the dissemination of CSAM material.

Related Article: TikTok Lawsuit: Allegedly Processing Data From Children's Accounts-Is Your Child's Privacy and Data in Danger?

Reddit Twitter Leaks

This article is owned by Tech Times

Reddit Twitter Voicemail

Written by Sophie Webster

Reddit Twitter Trumpnickelsburggeekwire

ⓒ 2021 TECHTIMES.com All rights reserved. Do not reproduce without permission.