Browse Source

Add command random (#23)

* Added /del and /http

* Added /promote

* Added /pin and /unpin

* Added Many Commands
TheHamkerCat 5 năm trước cách đây
mục cha
commit
dc61cd76da
6 tập tin đã thay đổi với 153 bổ sung và 59 xóa
  1. 5 1
      commands.txt
  2. 1 0
      requirements.txt
  3. 1 57
      wbb/modules/admin.py
  4. 1 1
      wbb/modules/images.py
  5. 96 0
      wbb/modules/search.py
  6. 49 0
      wbb/modules/succ.py

+ 5 - 1
commands.txt

@@ -5,9 +5,10 @@ banme - Ban Yourself
 cat - Get Cute Cats Images
 commit - Generate Funny Commit Messages
 del - Delete Replied Message
-demote - Demote A Member
 dev - Forward Anything To Developers [SPAM = GBAN]
 dog - Get Cute Dogs Images
+google - Search For Something On Google
+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
@@ -27,7 +28,10 @@ rice - Forward Your Linux Rice To DE_WM'sRice Gallery only works in DE_WM
 runs - Idk Test Yourself
 start - Start The Bot
 speedtest - To Perform A Speedtest.
+so - Search For Something On StackOverflow
 stats  - To Check System Status.
+succ - Sends Succ Image For A Given Word
+ud - Search For Something In Urban Dictionary
 unban - Unban A User
 unpin - Unpin The Last Pinned Message.
 wall - Get Wallpapers

+ 1 - 0
requirements.txt

@@ -7,3 +7,4 @@ requests
 speedtest-cli
 uvloop
 youtube_dl
+search_engine_parser

+ 1 - 57
wbb/modules/admin.py

@@ -12,7 +12,6 @@ __HELP__ = '''/ban    - Ban A User
 /del    - Delete Replied Message
 /banme  - Bans A User Who Issued The Command
 /kickme - Kicks A User Who Issued The Command
-/demote - Demote A Member
 /promote - Promote A Member
 /pin - Pin A Message
 /unpin - Unpin A Message'''
@@ -303,60 +302,6 @@ async def promote(_, message: Message):
         await message.reply_text("Well, Your Know What?, I'M NOT AN ADMIN!"
                                  + " MAKE ME ADMIN!")
 
-# Demote Members
-
-
-@app.on_message(cust_filter.command(commands=("demote")) & ~filters.edited)
-async def demote(_, message: Message):
-    admins = await list_admins(message.chat.id)
-    chat_id = message.chat.id
-    from_user_id = message.from_user.id
-
-    if (await app.get_chat_member(chat_id,
-                                  BOT_ID)).can_promote_members:
-        if message.from_user.id in admins \
-                or message.from_user.id in SUDO:
-            if (await app.get_chat_member(chat_id,
-                                          from_user_id)).can_promote_members \
-                or (await app.get_chat_member(chat_id, from_user_id)).status \
-                == 'creator' \
-                    or message.from_user.id in SUDO:
-
-                if message.text != '/demote':
-                    username = message.text.replace('/demote', '')
-                    user_id = (await app.get_users(username)).id
-                    await message.chat.promote_member(
-                        user_id=user_id,
-                        can_change_info=False,
-                        can_invite_users=False,
-                        can_restrict_members=False,
-                        can_delete_messages=False,
-                        can_pin_messages=False,
-                        can_promote_members=False)
-                    await message.reply_text('Promoted!')
-
-                else:
-                    user_id = message.reply_to_message.from_user.id
-                    await message.chat.promote_member(
-                        user_id=user_id,
-                        can_change_info=False,
-                        can_invite_users=False,
-                        can_restrict_members=False,
-                        can_delete_messages=False,
-                        can_pin_messages=False,
-                        can_promote_members=False)
-                    await message.reply_text('Demoted!')
-
-            else:
-                await message.reply_text("Yeah, I Can See You're An Admin,"
-                                         + " But You Don't Have Permissions"
-                                         + " To Demote Someone.")
-        else:
-            await message.reply_text("You're Not An Admin, Want A Good Ban?")
-    else:
-        await message.reply_text("Well, Your Know What?, I'M NOT AN ADMIN!"
-                                 + " MAKE ME ADMIN!")
-
 # Pin Messages
 
 
@@ -394,7 +339,6 @@ async def unpin(_, message: Message):
             or (await app.get_chat_member(chat_id, from_user_id)).status \
             == 'creator' \
                 or message.from_user.id in SUDO:
-
-            await app.unpin_chat_message(chat_id)
+            await app.unpin_all_chat_messages(chat_id)
     else:
         await message.reply_text("You're Not An Admin, Stop Spamming!")

+ 1 - 1
wbb/modules/images.py

@@ -43,7 +43,7 @@ async def dog(_, message: Message):
 async def wall(_, message: Message):
     app.set_parse_mode("markdown")
     m = await message.reply_text("Searching!")
-    initial_term = (message.text.replace('/wall', ''))
+    initial_term = (message.text.replace('/wall ', ''))
     term = initial_term.replace(' ', '%20')
     api = "https://wall.alphacoders.com/api2.0/get.php?auth=" + \
         "{}&method=search&term={}".format(WALL_API_KEY, term)

+ 96 - 0
wbb/modules/search.py

@@ -0,0 +1,96 @@
+from search_engine_parser import GoogleSearch
+from pyrogram.types import Message
+from pyrogram import filters
+from requests import get
+from wbb import app
+from wbb.utils import cust_filter
+
+__MODULE__ = "Search"
+__HELP__ = '''/ud - Search For Something In Urban Dictionary
+/google - Search For Something On google
+/so - Search For Something On StackOverflow
+/gh - Search For Something On Github'''
+
+# ud -  urbandictionary
+
+
+@app.on_message(cust_filter.command(commands=("ud")) & ~filters.edited)
+async def urbandict(_, message: Message):
+    text = message.text.replace("/ud ", '')
+    api = "http://api.urbandictionary.com/v0/define?term="
+    if text != '':
+        try:
+            results = get(f"{api}{text}").json()
+            reply_text = f'Definition: {results["list"][0]["definition"]}'
+            reply_text += f'\n\nExample: {results["list"][0]["example"]}'
+        except IndexError:
+            reply_text = ("Sorry could not find any matching results!")
+        ignore_chars = "[]"
+        reply = reply_text
+        for chars in ignore_chars:
+            reply = reply.replace(chars, "")
+        if len(reply) >= 4096:
+            reply = reply[:4096]
+        await message.reply_text(reply)
+
+    else:
+        await message.reply_text('"/ud" Needs An Argument.')
+
+# google
+
+
+@app.on_message(cust_filter.command(commands=("google")) & ~filters.edited)
+async def google(_, message: Message):
+    text = message.text.replace("/google ", '')
+    if text != '':
+        gresults = await GoogleSearch().async_search(text, 1)
+        result = ""
+        for i in range(4):
+            title = gresults["titles"][i].replace("\n", " ")
+            source = gresults["links"][i]
+            description = gresults["descriptions"][i]
+            result += f"[{title}]({source})\n"
+            result += f"`{description}`\n\n"
+        await message.reply_text(result, disable_web_page_preview=True)
+    else:
+        await message.reply_text('"/google" Needs An Argument')
+
+# StackOverflow [This is also a google search with some added args]
+
+
+@app.on_message(cust_filter.command(commands=("so")) & ~filters.edited)
+async def stack(_, message: Message):
+    gett = message.text.replace("/so ", '')
+    text = gett + ' site:stackoverflow.com'
+    if gett != '':
+        gresults = await GoogleSearch().async_search(text, 1)
+        result = ""
+        for i in range(4):
+            title = gresults["titles"][i].replace("\n", " ")
+            source = gresults["links"][i]
+            description = gresults["descriptions"][i]
+            result += f"[{title}]({source})\n"
+            result += f"`{description}`\n\n"
+        await message.reply_text(result, disable_web_page_preview=True)
+    else:
+        await message.reply_text('"/so" Needs An Argument')
+
+# Github [This is also a google search with some added args]
+
+
+@app.on_message(cust_filter.command(commands=("gh")) & ~filters.edited)
+async def github(_, message: Message):
+    gett = message.text.replace("/gh ", '')
+    text = gett + ' site:github.com'
+    if gett != '':
+        gresults = await GoogleSearch().async_search(text, 1)
+        result = ""
+        for i in range(4):
+            title = gresults["titles"][i].replace("\n", " ")
+            source = gresults["links"][i]
+            description = gresults["descriptions"][i]
+            result += f"[{title}]({source})\n"
+            result += f"`{description}`\n\n"
+        await message.reply_text(result, disable_web_page_preview=True)
+    else:
+        await message.reply_text('"/gh" Needs An Argument')

+ 49 - 0
wbb/modules/succ.py

@@ -0,0 +1,49 @@
+import random
+from pyrogram.types import Message
+from pyrogram import filters
+from wbb import app
+from wbb.utils import cust_filter
+
+__MODULE__ = "Succ"
+__HELP__ = "/succ - Sends Succ Image For A Given Argument"
+
+hack = ['https://i.ibb.co/YLLhCtt/i.png', 'https://i.ibb.co/DMzyLMZ/e.jpg',
+        'https://i.ibb.co/sqngHGt/d.jpg', 'https://i.ibb.co/b1Y1rGf/a.jpg']
+
+kemeest = "https://i.ibb.co/bB4pqNN/i.jpg"
+educ = "https://i.ibb.co/LCB3yTX/q.jpg"
+health = "https://i.ibb.co/TKHxkH4/m.jpg"
+nhealth = "https://i.ibb.co/dBVBzJY/p.jpg"
+feminism = "https://i.ibb.co/PNhPJR1/o.jpg"
+security = "https://i.ibb.co/ctf3MGM/c.jpg"
+
+
+def suck(text):
+    socc = {'komidi': 'message.reply_photo("https://i.ibb.co/mRL3Nnf/j.jpg")',
+            'kemist': f'message.reply_photo({kemeest})',
+            'ejucation': f'message.reply_photo({educ})',
+            'helth': f'message.reply_photo({health})',
+            'nothelth': f'message.reply_photo({nhealth})',
+            'femnnism': f'message.reply_photo({feminism})',
+            'tehc': 'message.reply_photo("https://i.ibb.co/gdSvHSr/n.jpg")',
+            'stonks': 'message.reply_photo("https://i.ibb.co/TtZ144x/h.png")',
+            'sekuriti': 'message.reply_photo()',
+            'enjenir': f'message.reply_photo({security})',
+            'phijiks': 'message.reply_photo("https://i.ibb.co/Zz4wBnc/g.png")',
+            'welth': 'message.reply_photo("https://i.ibb.co/JxFm4pW/k.jpg")',
+            'smrt': 'message.reply_photo("https://i.ibb.co/7bVkyC7/l.jpg")',
+            'hacc': 'message.reply_photo(random.choice(hack))'}
+    return socc.get(text)
+
+
+@app.on_message(cust_filter.command(commands=("succ")) & ~filters.edited)
+def succ(_, message: Message):
+    result = suck(message.text.replace('/succ ', ''))
+    print(result)
+    if result is None:
+        message.reply_text('''"/succ" Needs And Argument
+Args - `komidi, kemist, ejucation, helth, nothelth,
+femnnism, tehc, hacc, stonks, sekuriti, enjenir,
+phijiks, welth, smrt`''')
+    print(random)
+    exec(result)