thehamkercat hace 5 años
padre
commit
473204d8ab
Se han modificado 1 ficheros con 12 adiciones y 13 borrados
  1. 12 13
      wbb/modules/reddit.py

+ 12 - 13
wbb/modules/reddit.py

@@ -1,8 +1,8 @@
 import requests as r
 from pyrogram import filters
-from wbb import app
+from wbb import app, ARQ
 from wbb.utils.errors import capture_err
-
+from wbb.utils.fetch import fetch
 
 __MODULE__ = "Reddit"
 __HELP__ = "/reddit [query] - results something from reddit"
@@ -13,14 +13,13 @@ async def reddit(_, message):
     if len(message.command) != 2:
         await message.reply_text("/reddit needs an argument")
         return
-    subreddit = message.command[1]
-    res = r.get(f"https://meme-api.herokuapp.com/gimme/{subreddit}")
-    res = res.json()
-    rpage = res.get(str("subreddit"))  # Subreddit
-    title = res.get(str("title"))  # Post title
-    memeu = res.get(str("url"))  # meme pic url
-    plink = res.get(str("postLink"))
-    caps = f"<b>Title</b>: {title}\n"
-    caps += f"<b>Subreddit: </b>r/{rpage}\n"
-    caps += f"<b>PostLink:</b> {plink}"
-    await message.reply_photo(photo=memeu, caption=(caps))
+    subreddit = message.text.split(None, 1)[1]
+    res = await fetch(f"{ARQ}reddit?query={subreddit}")
+    sreddit = res["subreddit"]
+    title = res["title"]
+    image = res["url"]
+    link = res["postLink"]
+    caption = f"""**Title:** `{title}`
+**Subreddit:** {sreddit}
+**PostLink:** {link}"""
+    await message.reply_photo(photo=image, caption=caption)