Răsfoiți Sursa

fixed anime

TheHamkerCat 5 ani în urmă
părinte
comite
46aaea5b8e
4 a modificat fișierele cu 94 adăugiri și 10 ștergeri
  1. 1 0
      .gitignore
  2. 2 0
      requirements.txt
  3. 22 10
      wbb/modules/anime.py
  4. 69 0
      wbb/modules/bay.py

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
+images/
 # Byte-compiled / optimized / DLL files
 __pycache__/
 *.py[cod]

+ 2 - 0
requirements.txt

@@ -1,3 +1,5 @@
+wget
+requests
 python-arq
 TgCrypto
 pillow

+ 22 - 10
wbb/modules/anime.py

@@ -2,7 +2,7 @@ from wbb import app
 from wbb.utils.errors import capture_err
 from wbb.utils.fetch import fetch
 from pyrogram import filters
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InputMediaPhoto
 
 
 BASE_URL = "https://rgprojectx-gogoanime.herokuapp.com"
@@ -49,7 +49,9 @@ async def anime_search(_, message):
     if DATA_LEN == 0:
         await message.reply_text("**Found literally nothing.**")
         return
-    m = await app.send_message(
+    await m.delete()
+    m = await app.send_photo(
+        message.chat.id,
         photo=data[RESULT_NUMBER]['thumbnail'],
         caption=f"**Title:** {data[RESULT_NUMBER]['title']}",
         reply_markup=initial_keyboard
@@ -65,10 +67,10 @@ async def previous_callbacc(_, CallbackQuery):
             show_alert=True
         )
         return
-    RESULT_NUMBER -= 0
+    RESULT_NUMBER -= 1
+    await m.edit_media(media=InputMediaPhoto(data[RESULT_NUMBER]['thumbnail']))
     await m.edit(
-        photo=data[RESULT_NUMBER]['thumbnail'],
-        caption=f"**Title:** {data[RESULT_NUMBER]['title']}",
+        f"**Title:** {data[RESULT_NUMBER]['title']}",
         reply_markup=initial_keyboard
     )
 
@@ -83,9 +85,9 @@ async def next_callbacc(_, CallbackQuery):
         )
         return
     RESULT_NUMBER += 1
+    await m.edit_media(media=InputMediaPhoto(data[RESULT_NUMBER]['thumbnail']))
     await m.edit(
-        photo=data[RESULT_NUMBER]['thumbnail'],
-        caption=f"**Title:** {data[RESULT_NUMBER]['title']}",
+        f"**Title:** {data[RESULT_NUMBER]['title']}",
         reply_markup=initial_keyboard
     )
 
@@ -104,7 +106,17 @@ async def more_details_callbacc(_, CallbackQuery):
 **Other Name:** __{data['other_name']}__
 **Episodes:** __{len(data['episodes'])}__
 **Summary:** __{data['summary']}__"""
+    await m.edit_media(media=InputMediaPhoto(data['thumbnail']))
     await m.edit(
-        photo=data['thumbnail'],
-        caption=caption,
-        keyboard=InlineKeyboardMarkup([[InlineKeyboardButton(text="Episode", callback_data="hoe")]])
+        caption,
+        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="Delete", callback_data="delete_message")]]))
+
+
+@app.on_callback_query(filters.regex("delete_message"))
+async def delete_callbacc(_, CallbackQuery):
+    global RESULT_NUMBER, data, DATA_LEN, m
+    RESULT_NUMBER = 0
+    data = None
+    DATA_LEN = 0
+    await m.delete()
+

+ 69 - 0
wbb/modules/bay.py

@@ -0,0 +1,69 @@
+import os
+import requests
+import wget
+from wbb import app, OWNER_ID
+from pyrogram import Client, filters
+
+
+__MODULE__ = "BAYFILES"
+__HELP__ = """/url [URL] To upload a url to bayfiles. [SUDO ONLY]
+/tg To Upload a telegram file to bayfiles. [SUDO ONLY]"""
+
+
+@app.on_message(filters.command("url") & filters.user(OWNER_ID))
+async def url(_, message):
+    if len(message.command) != 2:
+        await message.reply_text("/url [url]")
+        return
+    if message.entities[1]['type'] != "url":
+        await message.reply_text("/url [url]")
+        return
+    m = await message.reply_text("downloading....bot will be unresponsive until download finishes.")
+    lenk = message.text.split(None, 1)[1]
+    try:
+        filename = wget.download(lenk)
+        files = { 'file': open(filename, 'rb')}
+        await m.edit("Uploading....")
+        r = requests.post("https://api.bayfiles.com/upload", files=files)
+        text = r.json()
+        output = f"""
+**status:** `{text['status']}`
+**link:** {text['data']['file']['url']['full']}
+**id:** `{text['data']['file']['metadata']['id']}`
+**name:** `{text['data']['file']['metadata']['name']}`
+**size:** `{text['data']['file']['metadata']['size']['readable']}`"""
+        await message.reply_text(output)
+        os.remove(filename)
+    except Exception as e:
+        print(str(e))
+        await m.edit(str(e))
+        return
+
+
+@app.on_message(filters.command("tg") & filters.user(OWNER_ID))
+async def tg(_, message):
+    if not message.reply_to_message:
+        await message.reply_text("Reply To A File With /tg To Upload")
+        return
+    if not message.reply_to_message.media:
+        await message.reply_text("Reply To A File With /tg To Upload")
+        return
+    m = await message.reply_text("Downloading Document.")
+    fn = await message.reply_to_message.download()
+    try:
+        files = { 'file': open(fn, 'rb')}
+        await m.edit("Uploading....")
+        r = requests.post("https://api.bayfiles.com/upload", files=files)
+        text = r.json()
+        output = f"""
+**status:** `{text['status']}`
+**link:** {text['data']['file']['url']['full']}
+**id:** `{text['data']['file']['metadata']['id']}`
+**name:** `{text['data']['file']['metadata']['name']}`
+**size:** `{text['data']['file']['metadata']['size']['readable']}`"""
+        await message.reply_text(output)
+        os.remove(fn)
+    except Exception as e:
+        print(str(e))
+        await m.edit(str(e))
+        return