Jelajahi Sumber

Beta (#28)

* Added /yt and /ipinfo
TheHamkerCat 5 tahun lalu
induk
melakukan
ba0dd8ffd6
5 mengubah file dengan 53 tambahan dan 18 penghapusan
  1. 2 0
      commands.txt
  2. 1 0
      requirements.txt
  3. 26 1
      wbb/modules/misc.py
  4. 1 15
      wbb/modules/rice.py
  5. 23 2
      wbb/modules/search.py

+ 2 - 0
commands.txt

@@ -14,6 +14,7 @@ gh - Search For Something On Github
 help - Help Yourself!
 http - Get Cats Reference Photo For Http Error Codes
 id - Get Chat_ID or User_ID
+ipinfo - Get Info About An Ip Address
 kick - Kick A User
 kickme - Kick Yourself
 log - Get Logs From Last Run.
@@ -38,3 +39,4 @@ unban - Unban A User
 unpin - Unpin The Last Pinned Message.
 wall - Get Wallpapers
 wiki - Search For Something On Wikipedia
+yt - Search For Something On YouTube

+ 1 - 0
requirements.txt

@@ -9,3 +9,4 @@ uvloop
 youtube_dl
 search_engine_parser
 wikipedia
+ipinfo

+ 26 - 1
wbb/modules/misc.py

@@ -1,5 +1,6 @@
 import secrets
 import string
+import ipinfo
 from pyrogram import filters
 from pyrogram.types import Message
 from cryptography.fernet import Fernet
@@ -16,7 +17,8 @@ __HELP__ = '''/commit - Generate Funny Commit Messages
 /random - Generate Random Complex Passwords
 /http - Get Cats Reference Photo For Http Error Codes
 /encrypt - Encrypt Text [Can Only Be Decrypted By This Bot]
-/decrypt - Decrypt Text'''
+/decrypt - Decrypt Text
+/ipinfo - Get Info About An Ip Address'''
 
 
 @app.on_message(cust_filter.command(commands=("commit")) & ~filters.edited)
@@ -144,3 +146,26 @@ async def decrypt(_, message: Message):
         decoded_text = cipher_suite.decrypt(text_in_bytes)
         bytes_in_text = decoded_text.decode("utf-8")
         await message.reply_text(bytes_in_text)
+
+# Ipinfo
+
+
+@app.on_message(cust_filter.command(commands=('ipinfo')) & ~filters.edited)
+async def ipaddrinfo(_, message: Message):
+    app.set_parse_mode('markdown')
+    ipaddr = message.text.replace("/ipinfo", "")
+    if ipaddr != "":
+        handler = ipinfo.getHandler()
+        details = handler.getDetails(ipaddr)
+        await message.reply_text(f'''`IP - {details.ip}
+City - {details.city}
+Region - {details.region}
+Country - {details.country}
+Location - {details.loc}
+ORG - {details.org}
+Postal - {details.postal}
+Timezone - {details.timezone}`''')
+
+    else:
+        await message.reply_text('`/ipinfo` Requires An IP As Argument'
+                                 + '. Ex - `/ipinfo 1.1.1.1`')

+ 1 - 15
wbb/modules/rice.py

@@ -34,19 +34,6 @@ async def rice(_, message: Message):
         ),
         quote=True
     )
-    return
-    if message.media_group_id:
-        message_id = message.message_id
-        media_group = await app.get_media_group(RICE_GROUP, message_id)
-        reply = await app.forward_messages(
-            RICE_CHANNEL, RICE_GROUP,
-            [m.message_id for m in media_group])
-    else:
-        reply = await message.forward(RICE_CHANNEL)
-    link = reply.link
-    reply_text = (f"Successfully forwarded to [Rice Gallery]({link})")
-    await message.reply_text(reply_text, parse_mode="markdown",
-                             disable_web_page_preview=True)
 
 
 @app.on_callback_query(filters.regex("forward"))
@@ -75,8 +62,7 @@ async def callback_query_forward_rice(_, callback_query):
                   f"<b>Approver</b>: {approver.mention()}\n"
                   f"<b>Forwarded</b>: "
                   f"<a href=\"{link}\">Rice Gallery</a>")
-    await m_rice.reply_text(reply_text, parse_mode="html",
-                            disable_web_page_preview=True)
+    await m_rice.reply_text(reply_text, disable_web_page_preview=True)
 
 
 @app.on_callback_query(filters.regex("ignore"))

+ 23 - 2
wbb/modules/search.py

@@ -1,4 +1,5 @@
 import wikipedia
+from youtube_search import YoutubeSearch
 from search_engine_parser import GoogleSearch
 from pyrogram.types import Message
 from pyrogram import filters
@@ -8,10 +9,11 @@ from wbb.utils import cust_filter
 
 __MODULE__ = "Search"
 __HELP__ = '''/ud - Search For Something In Urban Dictionary
-/google - Search For Something On google
+/google - Search For Something On Google
 /so - Search For Something On StackOverflow
 /gh - Search For Something On Github
-/wiki - Search For Something On Wikipedia'''
+/wiki - Search For Something On Wikipedia
+/yt - Search For Something On YouTube'''
 
 # ud -  urbandictionary
 
@@ -128,3 +130,22 @@ async def wiki(_, message: Message):
         if i == limit:
             break
     await message.reply_text(output, disable_web_page_preview=True)
+
+# YouTube
+
+
+@app.on_message(cust_filter.command(commands=("yt")) & ~filters.edited)
+async def ytsearch(_, message: Message):
+    m = await message.reply_text("Searching....")
+    query = message.text.replace("/yt", '')
+    results = YoutubeSearch(query, max_results=4).to_dict()
+    i = 0
+    text = ""
+    while i < 4:
+        text += f"Title - {results[i]['title']}\n"
+        text += f"Duration - {results[i]['duration']}\n"
+        text += f"Views - {results[i]['views']}\n"
+        text += f"Channel - {results[i]['channel']}\n"
+        text += f"https://youtube.com{results[i]['url_suffix']}\n\n"
+        i += 1
+    await m.edit(text, disable_web_page_preview=True)