diff --git a/reddit.py b/reddit.py index 52dd2a6..d4abcdc 100644 --- a/reddit.py +++ b/reddit.py @@ -1,6 +1,7 @@ import praw from prawcore import exceptions import requests +import random def get_post_type(url): @@ -50,11 +51,20 @@ def get_reddit_post(sub, is_image_post=False): if tries >= 5: return "Geile, gib Sub mit Bildern (über 5 Fehlversuche)" - return post + return post + + +# def fourtwenty(bot, update): +def fourtwenty(): + stoner_subs = ["StonerThoughts"] + # post = get_reddit_post(random.randint(0, len(stoner_subs) - 1)) + post = get_reddit_post("StonerThoughts") + print(post.title) + print(post.text) def wrong_dog(bot, update): - reddit(bot, update, ['whatswrongwithyourdog']) + reddit_img(bot, update, ['whatswrongwithyourdog']) def hamster(bot, update): @@ -67,7 +77,7 @@ def reddit(bot, update, args): return sub = args[0] - update.message.reply_text(get_reddit_post(sub)) + update.message.reply_text(get_reddit_post(sub).url) def reddit_img(bot, update, args): @@ -83,3 +93,5 @@ def reddit_img(bot, update, args): except AttributeError: update.message.reply_text(post) print("ERROR") + +# fourtwenty()y