Skip to content
This repository has been archived by the owner. It is now read-only.
Python
Branch: master
Clone or download

Latest commit

Latest commit b289241 Feb 28, 2016

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
TweetPoster Update footer.txt Feb 28, 2016
.gitignore Add some db stuff to keep track of posts we've processed Jul 1, 2013
.travis.yml
LICENSE Add MIT license Jun 30, 2013
README.md
requirements.txt
run.py

README.md

TweetPoster Build Status

TweetPoster is a reddit bot that posts the contents of the submitted tweet (and any parents) as a comment on the submission itself, as well as rehosts any images.
It is a replacement for the now-defunct /u/tweet_poster.

Adding an image host

All image hosts must subclass TweetPoster.rehost.ImageHost, this allows them to be automatically picked up when it comes time to rehost an image.

Each image host has two prerequisites:

  1. a url_re attribute which will be used to match against a url
  2. an extract method that recieves a url

extract should return an imgur.com url (obtained using ImageHost.rehost) or None

An example can be found below, and further examples can be found in rehost.py

class Instagram(ImageHost):

    url_re = 'https?://instagram.com/p/\w+/'

    def extract(self, url):
        try:
            r = requests.get(url)
        except requests.exceptions.RequestException:
            return None

        soup = BeautifulSoup(r.content)
        photo = soup.find("img", class_="photo")['src']
        return self.rehost(photo)

Links

You can’t perform that action at this time.