瀏覽代碼

Added /reddit and some more fixes

TheHamkerCat 5 年之前
父節點
當前提交
4a9f876db3
共有 4 個文件被更改,包括 24 次插入 和 3 次删除
  1. 1 1
      README.md
  2. 2 0
      wbb/modules/search.py
  3. 21 0
      wbb/modules/succ.py
  4. 0 2
      wbb/modules/sudoers.py

+ 1 - 1
README.md

@@ -14,7 +14,7 @@ Just Another Telegram Bot Written In Python Using Pyrogram.
 ## Run
 
 1. `git clone https://github.com/thehamkercat/WilliamButcherBot`, to download the source code.
-2. `cd wbb`, to enter the directory.
+2. `cd WilliamButcherBot`, to enter the directory.
 3. `pip3 install -r requirements.txt`, to install the requirements.
 4. `cp sample_config.ini config.ini`
 5. Edit `config.ini` with your own values

+ 2 - 0
wbb/modules/search.py

@@ -138,6 +138,8 @@ async def wiki(_, message: Message):
 async def ytsearch(_, message: Message):
     m = await message.reply_text("Searching....")
     query = message.text.replace("/yt", '')
+    if query == "":
+        await message.reply_text("/yt needs an argument")
     results = YoutubeSearch(query, max_results=4).to_dict()
     i = 0
     text = ""

+ 21 - 0
wbb/modules/succ.py

@@ -1,4 +1,5 @@
 import random
+import requests as r
 from pyrogram.types import Message
 from pyrogram import filters
 from wbb import app
@@ -46,3 +47,23 @@ femnnism, tehc, hacc, stonks, sekuriti,
 phijiks, welth, smrt`''')
     print(random)
     exec(result)
+
+
+@app.on_message(cust_filter.command(commands=("reddit")) & ~filters.edited)
+async def reddit(_, message: Message):
+    app.set_parse_mode('html')
+    if len(message.command) != 2:
+        await message.reply_text("/reddit needs an argument")
+    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))

+ 0 - 2
wbb/modules/sudoers.py

@@ -3,7 +3,6 @@ import re
 import requests
 import time
 import wget
-from io import BytesIO
 from pyrogram import filters, types
 from pyrogram.types import Message
 import speedtest
@@ -18,7 +17,6 @@ __HELP__ = '''/log - To Get Logs From Last Run.
 /song - To Download Songs From JioSaavn
 /upload - To Upload Files Via Direct Link'''
 
-
 SUDOERS = [OWNER_ID, SUDO_USER_ID]