コード例 #1
0
ファイル: main.py プロジェクト: octatone/Top-Poster
def hourly():
    """hourly tasks"""
    # WHITELIST RADIOREDDIT.COM IN THE MOD QUEUE
    print "Logging in ..."
    rio = RedditIO()
    print "Whitelisting ..."
    rio.whitelistCheck("radioreddit", ["radioreddit.com"])

    # TELL PEOPLE TO UPLOAD THEIR SHIT
    print "Looking for bands posting to music ..."
    new = rio.getNewPosts("music", 100)
    hour_ago = time.mktime((datetime.datetime.now() - datetime.timedelta(hours=1)).timetuple())
    comments = [
        "Don't forget to upload your music to [radio reddit](http://radioreddit.com/uploading)!",
        "Put your music on [radio reddit](http://radioreddit.com/uploading)",
        "We'd love to have your stuff on [radio reddit](http://radioreddit.com/uploading)!",
        "If you want to reach more ears, put your music up on [radio reddit](http://radioreddit.com/uploading)!",
    ]

    for post in new:
        # print datetime.datetime.fromtimestamp(hour_ago), datetime.datetime.fromtimestamp(post.created_utc), post.title
        if (
            post.created_utc > hour_ago
            and re.search("(my|our) (band|music|ep|cd|album|song).*free", post.title, re.IGNORECASE)
            and not re.search("(cover|remix)", post.title, re.IGNORECASE)
        ):
            print "Leaving comment on:"
            print post.created_utc, post.title, "..."
            rio.postComment(post, choice(comments))
コード例 #2
0
def hourly():
    """hourly tasks"""
    # WHITELIST RADIOREDDIT.COM IN THE MOD QUEUE
    print 'Logging in ...'
    rio = RedditIO()
    print 'Whitelisting ...'
    rio.whitelistCheck('radioreddit',['radioreddit.com'])

    # TELL PEOPLE TO UPLOAD THEIR SHIT
    print 'Looking for bands posting to music ...'
    new = rio.getNewPosts('music', 100)
    hour_ago = time.mktime((datetime.datetime.now() - datetime.timedelta(hours=1)).timetuple())
    comments = ['Don\'t forget to upload your music to [radio reddit](http://radioreddit.com/uploading)!', 'Put your music on [radio reddit](http://radioreddit.com/uploading)', 'We\'d love to have your stuff on [radio reddit](http://radioreddit.com/uploading)!','If you want to reach more ears, put your music up on [radio reddit](http://radioreddit.com/uploading)!']

    for post in new:
        #print datetime.datetime.fromtimestamp(hour_ago), datetime.datetime.fromtimestamp(post.created_utc), post.title
        if post.created_utc > hour_ago and re.search('(my|our) (band|music|ep|cd|album|song).*free', post.title, re.IGNORECASE) and not re.search('(cover|remix)', post.title, re.IGNORECASE):
            print 'Leaving comment on:'
            print post.created_utc, post.title, '...'
            rio.postComment(post, choice(comments))