├── Config.txt
├── Dockerfile
├── LICENSE
├── Procfile
├── README.md
├── Zaid
├── __init__.py
├── __main__.py
├── database
│ ├── __init__.py
│ ├── gbandb.py
│ ├── gmutedb.py
│ ├── pmpermitdb.py
│ └── rraid.py
├── helper
│ ├── PyroHelpers.py
│ ├── __init__.py
│ ├── adminHelpers.py
│ ├── aiohttp_helper.py
│ ├── basic.py
│ ├── constants.py
│ ├── data.py
│ ├── inline.py
│ ├── interval.py
│ ├── parser.py
│ └── utility.py
└── modules
│ ├── __init__.py
│ ├── basic
│ ├── __init__.py
│ ├── administrator.py
│ ├── adminlist.py
│ ├── afk.py
│ ├── animation.py
│ ├── autoscroll.py
│ ├── broadcast.py
│ ├── carbon.py
│ ├── clone.py
│ ├── create.py
│ ├── define.py
│ ├── eval_exec.py
│ ├── git_commands.py
│ ├── google.py
│ ├── hentai_api.py
│ ├── invite.py
│ ├── joinleave.py
│ ├── locks.py
│ ├── lyrics.py
│ ├── mention.py
│ ├── metrics.py
│ ├── misc.py
│ ├── music.py
│ ├── nekobin.py
│ ├── pats.py
│ ├── ping.py
│ ├── profile.py
│ ├── purge.py
│ ├── quote.py
│ ├── sangmata.py
│ ├── screenshot.py
│ ├── stats.py
│ ├── stickers.py
│ ├── tagalert.py
│ ├── tagall.py
│ ├── telegraph.py
│ ├── translate.py
│ ├── ud.py
│ ├── unsplash.py
│ ├── upload_files.py
│ ├── vctools.py
│ ├── vulgar.py
│ ├── weather.py
│ └── whois.py
│ ├── bot
│ ├── __init__.py
│ ├── bot.py
│ ├── inline.py
│ └── start.py
│ ├── cctools
│ └── scraper.py
│ ├── fun
│ ├── __init__.py
│ ├── autopic.py
│ ├── emoji.py
│ ├── stickers.py
│ ├── text_api.py
│ └── texts.py
│ ├── globals
│ └── global.py
│ ├── help
│ ├── __init__.py
│ └── help.py
│ ├── private
│ ├── __init__.py
│ ├── apmguarde.py
│ └── pmguard.py
│ ├── spam
│ ├── Spam.py
│ ├── __init__.py
│ ├── areplyraid.py
│ ├── dmspam.py
│ ├── replyraid.py
│ └── watcher.py
│ ├── sudo
│ ├── __init__.py
│ └── sudos.py
│ └── updater
│ ├── __init__.py
│ └── update.py
├── app.json
├── cache
├── __init__.py
├── autopic-font-ubuntu.ttf
├── autopic-template.jpg
├── blank.png
├── data.py
└── default.ttf
├── config.py
├── heroku.yml
├── render.yaml
├── requirements.txt
├── sample.env
├── server.py
└── start.sh
/Config.txt:
--------------------------------------------------------------------------------
1 | import os
2 | from os import getenv
3 | from dotenv import load_dotenv
4 |
5 |
6 | API_ID = int(6435225) #optional
7 | API_HASH = "4e984ea35f854762dcde906dce426c2d" #optional
8 |
9 | SUDO_USERS = list(map(int, ("").split()))
10 | OWNER_ID = int(1234567890)
11 | MONGO_URL = "MONGO_URL"
12 | BOT_TOKEN = "BOT_TOKEN"
13 | ALIVE_PIC = 'https://telegra.ph/file/3c52a01057865f7511168.jpg'
14 | ALIVE_TEXT = None
15 | PM_LOGGER = None
16 | LOG_GROUP = None
17 | GIT_TOKEN = None #personal access token
18 | REPO_URL = "https://github.com/ITZ-ZAID/ZAID-USERBOT"
19 | BRANCH = "master" #don't change
20 |
21 | STRING_SESSION1 = ""
22 | STRING_SESSION2 = ""
23 | STRING_SESSION3 = ""
24 | STRING_SESSION4 = ""
25 | STRING_SESSION5 = ""
26 | STRING_SESSION6 = ""
27 | STRING_SESSION7 = ""
28 | STRING_SESSION8 = ""
29 | STRING_SESSION9 = ""
30 | STRING_SESSION10 = ""
31 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.9.7-slim-buster
2 | RUN apt-get update && apt-get upgrade -y
3 | RUN apt-get install git curl python3-pip ffmpeg -y
4 | RUN pip3 install -U pip
5 | RUN python3 -m pip install --upgrade pip
6 | COPY . /app/
7 | WORKDIR /app/
8 | RUN pip3 install -U -r requirements.txt
9 | CMD ["bash","start.sh"]
10 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | worker: python3 -m Zaid
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
𝐙𝐚𝐢𝐝 𝐔𝐬𝐞𝐫𝐛𝐨𝐭 🔥
4 | 5 | - A First Telegram Userbot Project With Multi Clients Based On PyroGram 6 | 7 | 8 |
9 |
10 |
11 | ## Repo Stats
12 |
13 | 
14 |
15 |
16 | ## Requirements
17 |
18 | - PyroGram Session
19 | - Dummy account
20 | - Python 3.8+ or 3.7
21 | - [Mongo Db](https://youtu.be/mnvjt_a5JYA)
22 |
23 | ## String Session
24 |
25 |
𝐒𝐮𝐩𝐩𝐨𝐫𝐭 / 𝐂𝐡𝐚𝐧𝐧𝐞𝐥 ---->
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /Zaid/__init__.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client 2 | from config import API_ID, API_HASH, SUDO_USERS, OWNER_ID, BOT_TOKEN, STRING_SESSION1, STRING_SESSION2, STRING_SESSION3, STRING_SESSION4, STRING_SESSION5, STRING_SESSION6, STRING_SESSION7, STRING_SESSION8, STRING_SESSION9, STRING_SESSION10 3 | from datetime import datetime 4 | import time 5 | from aiohttp import ClientSession 6 | 7 | StartTime = time.time() 8 | START_TIME = datetime.now() 9 | CMD_HELP = {} 10 | SUDO_USER = SUDO_USERS 11 | clients = [] 12 | ids = [] 13 | 14 | SUDO_USERS.append(OWNER_ID) 15 | aiosession = ClientSession() 16 | 17 | if API_ID: 18 | API_ID = API_ID 19 | else: 20 | print("WARNING: API ID NOT FOUND USING ZAID API ⚡") 21 | API_ID = "6435225" 22 | 23 | if API_HASH: 24 | API_HASH = API_HASH 25 | else: 26 | print("WARNING: API HASH NOT FOUND USING ZAID API ⚡") 27 | API_HASH = "4e984ea35f854762dcde906dce426c2d" 28 | 29 | if not BOT_TOKEN: 30 | print("WARNING: BOT TOKEN NOT FOUND PLZ ADD ⚡") 31 | 32 | app = Client( 33 | name="app", 34 | api_id=API_ID, 35 | api_hash=API_HASH, 36 | bot_token=BOT_TOKEN, 37 | plugins=dict(root="Zaid/modules/bot"), 38 | in_memory=True, 39 | ) 40 | 41 | if STRING_SESSION1: 42 | print("Client1: Found.. Starting..📳") 43 | client1 = Client(name="one", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION1, plugins=dict(root="Zaid/modules")) 44 | clients.append(client1) 45 | 46 | if STRING_SESSION2: 47 | print("Client2: Found.. Starting.. 📳") 48 | client2 = Client(name="two", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION2, plugins=dict(root="Zaid/modules")) 49 | clients.append(client2) 50 | 51 | if STRING_SESSION3: 52 | print("Client3: Found.. Starting.. 📳") 53 | client3 = Client(name="three", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION3, plugins=dict(root="Zaid/modules")) 54 | clients.append(client3) 55 | 56 | if STRING_SESSION4: 57 | print("Client4: Found.. Starting.. 📳") 58 | client4 = Client(name="four", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION4, plugins=dict(root="Zaid/modules")) 59 | clients.append(client4) 60 | 61 | if STRING_SESSION5: 62 | print("Client5: Found.. Starting.. 📳") 63 | client5 = Client(name="five", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION5, plugins=dict(root="Zaid/modules")) 64 | clients.append(client5) 65 | 66 | if STRING_SESSION6: 67 | print("Client6: Found.. Starting.. 📳") 68 | client6 = Client(name="six", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION6, plugins=dict(root="Zaid/modules")) 69 | clients.append(client6) 70 | 71 | if STRING_SESSION7: 72 | print("Client7: Found.. Starting.. 📳") 73 | client7 = Client(name="seven", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION7, plugins=dict(root="Zaid/modules")) 74 | clients.append(client7) 75 | 76 | if STRING_SESSION8: 77 | print("Client8: Found.. Starting.. 📳") 78 | client8 = Client(name="eight", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION8, plugins=dict(root="Zaid/modules")) 79 | clients.append(client8) 80 | 81 | if STRING_SESSION9: 82 | print("Client9: Found.. Starting.. 📳") 83 | client9 = Client(name="nine", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION9, plugins=dict(root="Zaid/modules")) 84 | clients.append(client9) 85 | 86 | if STRING_SESSION10: 87 | print("Client10: Found.. Starting.. 📳") 88 | client10 = Client(name="ten", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION10, plugins=dict(root="Zaid/modules")) 89 | clients.append(client10) 90 | -------------------------------------------------------------------------------- /Zaid/__main__.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import importlib 3 | from pyrogram import Client, idle 4 | from Zaid.helper import join 5 | from Zaid.modules import ALL_MODULES 6 | from Zaid import clients, app, ids 7 | 8 | async def start_bot(): 9 | await app.start() 10 | print("LOG: Founded Bot token Booting..") 11 | for all_module in ALL_MODULES: 12 | importlib.import_module("Zaid.modules" + all_module) 13 | print(f"Successfully Imported {all_module} 💥") 14 | for cli in clients: 15 | try: 16 | await cli.start() 17 | ex = await cli.get_me() 18 | await join(cli) 19 | print(f"Started {ex.first_name} 🔥") 20 | ids.append(ex.id) 21 | except Exception as e: 22 | print(f"{e}") 23 | await idle() 24 | 25 | loop = asyncio.get_event_loop() 26 | loop.run_until_complete(start_bot()) 27 | -------------------------------------------------------------------------------- /Zaid/database/__init__.py: -------------------------------------------------------------------------------- 1 | import motor.motor_asyncio 2 | 3 | from config import MONGO_URL 4 | cli = motor.motor_asyncio.AsyncIOMotorClient(MONGO_URL) 5 | 6 | dbb = cli.program 7 | -------------------------------------------------------------------------------- /Zaid/database/gbandb.py: -------------------------------------------------------------------------------- 1 | from typing import Dict, List, Union 2 | 3 | from Zaid.database import dbb as db 4 | 5 | gbansdb = db.gban 6 | 7 | 8 | async def gban_list() -> list: 9 | users = gbansdb.find({"user_id": {"$gt": 0}}) 10 | users = await users.to_list(length=100000) 11 | return users 12 | 13 | async def gban_count() -> int: 14 | users = gbansdb.find({"user_id": {"$gt": 0}}) 15 | users = await users.to_list(length=100000) 16 | return len(users) 17 | 18 | async def gban_info(user_id: int) -> bool: 19 | user = await gbansdb.find_one({"user_id": user_id}) 20 | if not user: 21 | return False 22 | return True 23 | 24 | async def gban_user(user_id: int): 25 | is_gbanned = await gban_info(user_id) 26 | if is_gbanned: 27 | return 28 | return await gbansdb.insert_one({"user_id": user_id}) 29 | 30 | async def ungban_user(user_id: int): 31 | is_gbanned = await gban_info(user_id) 32 | if not is_gbanned: 33 | return 34 | return await gbansdb.delete_one({"user_id": user_id}) 35 | -------------------------------------------------------------------------------- /Zaid/database/gmutedb.py: -------------------------------------------------------------------------------- 1 | from Zaid.database import cli 2 | 3 | gmuteh = cli["GMUTE"] 4 | 5 | 6 | async def is_gmuted(sender_id): 7 | kk = await gmuteh.find_one({"sender_id": sender_id}) 8 | return bool(kk) 9 | 10 | 11 | async def gmute(sender_id, reason="#GMuted"): 12 | await gmuteh.insert_one({"sender_id": sender_id, "reason": reason}) 13 | 14 | 15 | async def ungmute(sender_id): 16 | await gmuteh.delete_one({"sender_id": sender_id}) 17 | -------------------------------------------------------------------------------- /Zaid/database/pmpermitdb.py: -------------------------------------------------------------------------------- 1 | from Zaid.database import cli 2 | import asyncio 3 | 4 | collection = cli["Zaid"]["pmpermit"] 5 | 6 | PMPERMIT_MESSAGE = ( 7 | "**ᴡᴀʀɴɪɴɢ!⚠️ ᴘʟᴢ ʀᴇᴀᴅ ᴛʜɪꜱ ᴍᴇꜱꜱᴀɢᴇ ᴄᴀʀᴇꜰᴜʟʟʏ..\n\n**" 8 | "**ɪ'ᴍ ᴢᴀɪᴅ ᴜꜱᴇʀʙᴏᴛ ɪ'ᴍ ʜᴇʀᴇ ᴛᴏ ᴘʀᴏᴛᴇᴄᴛ ᴍʏ ᴍᴀꜱᴛᴇʀ ꜰʀᴏᴍ ꜱᴘᴀᴍᴍᴇʀꜱ.**" 9 | "**ɪꜰ ʏᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴀ ꜱᴘᴀᴍᴍᴇʀ ᴛʜᴇɴ ᴘʟᴢ ᴡᴀɪᴛ!.\n\n**" 10 | "**ᴜɴᴛɪʟ ᴛʜᴇɴ, ᴅᴏɴ'ᴛ ꜱᴘᴀᴍ, ᴏʀ ʏᴏᴜ'ʟʟ ɢᴇᴛ ʙʟᴏᴄᴋᴇᴅ ᴀɴᴅ ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ ᴍᴇ, ꜱᴏ ʙᴇ ᴄᴀʀᴇꜰᴜʟʟ ᴛᴏ ꜱᴇɴᴅ ᴀɴʏ ᴍᴇꜱꜱᴀɢᴇꜱ!**" 11 | ) 12 | 13 | BLOCKED = "**ʙᴇᴇᴘ ʙᴏᴏᴘ ꜰᴏᴜɴᴅᴇᴅ ᴀ ꜱᴘᴀᴍᴍᴇʀ!, ʙʟᴏᴄᴋᴇᴅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ!**" 14 | 15 | LIMIT = 5 16 | 17 | 18 | async def set_pm(value: bool): 19 | doc = {"_id": 1, "pmpermit": value} 20 | doc2 = {"_id": "Approved", "users": []} 21 | r = await collection.find_one({"_id": 1}) 22 | r2 = await collection.find_one({"_id": "Approved"}) 23 | if r: 24 | await collection.update_one({"_id": 1}, {"$set": {"pmpermit": value}}) 25 | else: 26 | await collection.insert_one(doc) 27 | if not r2: 28 | await collection.insert_one(doc2) 29 | 30 | 31 | async def set_permit_message(text): 32 | await collection.update_one({"_id": 1}, {"$set": {"pmpermit_message": text}}) 33 | 34 | 35 | async def set_block_message(text): 36 | await collection.update_one({"_id": 1}, {"$set": {"block_message": text}}) 37 | 38 | 39 | async def set_limit(limit): 40 | await collection.update_one({"_id": 1}, {"$set": {"limit": limit}}) 41 | 42 | 43 | async def get_pm_settings(): 44 | result = await collection.find_one({"_id": 1}) 45 | if not result: 46 | return False 47 | pmpermit = result["pmpermit"] 48 | pm_message = result.get("pmpermit_message", PMPERMIT_MESSAGE) 49 | block_message = result.get("block_message", BLOCKED) 50 | limit = result.get("limit", LIMIT) 51 | return pmpermit, pm_message, limit, block_message 52 | 53 | 54 | async def allow_user(chat): 55 | doc = {"_id": "Approved", "users": [chat]} 56 | r = await collection.find_one({"_id": "Approved"}) 57 | if r: 58 | await collection.update_one({"_id": "Approved"}, {"$push": {"users": chat}}) 59 | else: 60 | await collection.insert_one(doc) 61 | 62 | 63 | async def get_approved_users(): 64 | results = await collection.find_one({"_id": "Approved"}) 65 | if results: 66 | return results["users"] 67 | else: 68 | return [] 69 | 70 | 71 | async def deny_user(chat): 72 | await collection.update_one({"_id": "Approved"}, {"$pull": {"users": chat}}) 73 | 74 | 75 | async def pm_guard(): 76 | result = await collection.find_one({"_id": 1}) 77 | if not result: 78 | return False 79 | if not result["pmpermit"]: 80 | return False 81 | else: 82 | return True 83 | -------------------------------------------------------------------------------- /Zaid/database/rraid.py: -------------------------------------------------------------------------------- 1 | from Zaid.database import cli 2 | 3 | collection = cli["Zaid"]["rraid"] 4 | 5 | 6 | async def rraid_user(chat): 7 | doc = {"_id": "Rraid", "users": [chat]} 8 | r = await collection.find_one({"_id": "Rraid"}) 9 | if r: 10 | await collection.update_one({"_id": "Rraid"}, {"$push": {"users": chat}}) 11 | else: 12 | await collection.insert_one(doc) 13 | 14 | 15 | async def get_rraid_users(): 16 | results = await collection.find_one({"_id": "Rraid"}) 17 | if results: 18 | return results["users"] 19 | else: 20 | return [] 21 | 22 | 23 | async def unrraid_user(chat): 24 | await collection.update_one({"_id": "Rraid"}, {"$pull": {"users": chat}}) 25 | -------------------------------------------------------------------------------- /Zaid/helper/PyroHelpers.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import Message, User 2 | from pyrogram import Client, enums 3 | 4 | async def get_ub_chats( 5 | client: Client, 6 | chat_types: list = [ 7 | enums.ChatType.GROUP, 8 | enums.ChatType.SUPERGROUP, 9 | enums.ChatType.CHANNEL, 10 | ], 11 | is_id_only=True, 12 | ): 13 | ub_chats = [] 14 | async for dialog in client.get_dialogs(): 15 | if dialog.chat.type in chat_types: 16 | if is_id_only: 17 | ub_chats.append(dialog.chat.id) 18 | else: 19 | ub_chats.append(dialog.chat) 20 | else: 21 | continue 22 | return ub_chats 23 | 24 | def ReplyCheck(message: Message): 25 | reply_id = None 26 | 27 | if message.reply_to_message: 28 | reply_id = message.reply_to_message.id 29 | 30 | elif not message.from_user.is_self: 31 | reply_id = message.id 32 | 33 | return reply_id 34 | 35 | 36 | def SpeedConvert(size): 37 | power = 2 ** 10 38 | zero = 0 39 | units = {0: "", 1: "Kbit/s", 2: "Mbit/s", 3: "Gbit/s", 4: "Tbit/s"} 40 | while size > power: 41 | size /= power 42 | zero += 1 43 | return f"{round(size, 2)} {units[zero]}" 44 | 45 | 46 | def GetFromUserID(message: Message): 47 | return message.from_user.id 48 | 49 | 50 | def GetChatID(message: Message): 51 | return message.chat.id 52 | 53 | 54 | def GetUserMentionable(user: User): 55 | if user.username: 56 | username = "@{}".format(user.username) 57 | else: 58 | if user.last_name: 59 | name_string = "{} {}".format(user.first_name, user.last_name) 60 | else: 61 | name_string = "{}".format(user.first_name) 62 | 63 | username = "{}".format(user.id, name_string) 64 | 65 | return username 66 | -------------------------------------------------------------------------------- /Zaid/helper/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from pyrogram import Client 4 | 5 | 6 | 7 | def restart(): 8 | os.execvp(sys.executable, [sys.executable, "-m", "Zaid"]) 9 | 10 | async def join(client): 11 | try: 12 | await client.join_chat("TheUpdatesChannel") 13 | except BaseException: 14 | pass 15 | -------------------------------------------------------------------------------- /Zaid/helper/adminHelpers.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from time import time 3 | 4 | from pyrogram.types import Message 5 | 6 | from pyrogram import Client 7 | from Zaid.helper.interval import IntervalHelper 8 | 9 | 10 | async def CheckAdmin(message: Message): 11 | """Check if we are an admin.""" 12 | admin = "administrator" 13 | creator = "creator" 14 | ranks = [admin, creator] 15 | 16 | SELF = await Client.get_chat_member( 17 | chat_id=message.chat.id, user_id=message.from_user.id 18 | ) 19 | 20 | if SELF.status not in ranks: 21 | await message.edit("__I'm not Admin!__") 22 | await asyncio.sleep(2) 23 | await message.delete() 24 | 25 | else: 26 | if SELF.status is not admin: 27 | return True 28 | elif SELF.can_restrict_members: 29 | return True 30 | else: 31 | await message.edit("__No Permissions to restrict Members__") 32 | await asyncio.sleep(2) 33 | await message.delete() 34 | 35 | 36 | async def CheckReplyAdmin(message: Message): 37 | """Check if the message is a reply to another user.""" 38 | if not message.reply_to_message: 39 | await message.edit("The command needs to be a reply") 40 | await asyncio.sleep(2) 41 | await message.delete() 42 | elif message.reply_to_message.from_user.is_self: 43 | await message.edit(f"I can't {message.command[0]} myself.") 44 | await asyncio.sleep(2) 45 | await message.delete() 46 | else: 47 | return True 48 | 49 | return False 50 | 51 | 52 | async def Timer(message: Message): 53 | if len(message.command) > 1: 54 | secs = IntervalHelper(message.command[1]) 55 | return int(str(time()).split(".")[0] + secs.to_secs()[0]) 56 | else: 57 | return 0 58 | 59 | 60 | async def TimerString(message: Message): 61 | secs = IntervalHelper(message.command[1]) 62 | return f"{secs.to_secs()[1]} {secs.to_secs()[2]}" 63 | 64 | 65 | async def RestrictFailed(message: Message): 66 | await message.edit(f"I can't {message.command} this user.") 67 | await asyncio.sleep(2) 68 | await message.delete() 69 | -------------------------------------------------------------------------------- /Zaid/helper/aiohttp_helper.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | import aiohttp 4 | 5 | 6 | class AioHttp: 7 | @staticmethod 8 | async def get_json(link): 9 | async with aiohttp.ClientSession() as session: 10 | async with session.get(link) as resp: 11 | return await resp.json() 12 | 13 | @staticmethod 14 | async def get_text(link): 15 | async with aiohttp.ClientSession() as session: 16 | async with session.get(link) as resp: 17 | return await resp.text() 18 | 19 | @staticmethod 20 | async def get_json_from_text(link): 21 | async with aiohttp.ClientSession() as session: 22 | async with session.get(link) as resp: 23 | text = await resp.text() 24 | return json.loads(text) 25 | 26 | @staticmethod 27 | async def get_raw(link): 28 | async with aiohttp.ClientSession() as session: 29 | async with session.get(link) as resp: 30 | return await resp.read() 31 | 32 | @staticmethod 33 | async def get_url(link): 34 | async with aiohttp.ClientSession() as session: 35 | async with session.get(link) as resp: 36 | return resp.url 37 | -------------------------------------------------------------------------------- /Zaid/helper/basic.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import Message 2 | 3 | 4 | def get_user(message: Message, text: str) -> [int, str, None]: 5 | """Get User From Message""" 6 | if text is None: 7 | asplit = None 8 | else: 9 | asplit = text.split(" ", 1) 10 | user_s = None 11 | reason_ = None 12 | if message.reply_to_message: 13 | user_s = message.reply_to_message.from_user.id 14 | reason_ = text if text else None 15 | elif asplit is None: 16 | return None, None 17 | elif len(asplit[0]) > 0: 18 | if message.entities: 19 | if len(message.entities) == 1: 20 | required_entity = message.entities[0] 21 | if required_entity.type == "text_mention": 22 | user_s = int(required_entity.user.id) 23 | else: 24 | user_s = int(asplit[0]) if asplit[0].isdigit() else asplit[0] 25 | else: 26 | user_s = int(asplit[0]) if asplit[0].isdigit() else asplit[0] 27 | if len(asplit) == 2: 28 | reason_ = asplit[1] 29 | return user_s, reason_ 30 | 31 | 32 | def get_text(message: Message) -> [None, str]: 33 | """Extract Text From Commands""" 34 | text_to_return = message.text 35 | if message.text is None: 36 | return None 37 | if " " in text_to_return: 38 | try: 39 | return message.text.split(None, 1)[1] 40 | except IndexError: 41 | return None 42 | else: 43 | return None 44 | 45 | 46 | async def edit_or_reply(message: Message, *args, **kwargs) -> Message: 47 | apa = ( 48 | message.edit_text 49 | if bool(message.from_user and message.from_user.is_self or message.outgoing) 50 | else (message.reply_to_message or message).reply_text 51 | ) 52 | return await apa(*args, **kwargs) 53 | 54 | 55 | eor = edit_or_reply 56 | -------------------------------------------------------------------------------- /Zaid/helper/data.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import InlineKeyboardButton, WebAppInfo 2 | 3 | class Data: 4 | 5 | text_help_menu = ( 6 | "**Command List & Help**\n**— Prefixes:** `.`" 7 | .replace(",", "") 8 | .replace("[", "") 9 | .replace("]", "") 10 | .replace("'", "") 11 | ) 12 | reopen = [[InlineKeyboardButton("Re-Open", callback_data="reopen")]] 13 | -------------------------------------------------------------------------------- /Zaid/helper/inline.py: -------------------------------------------------------------------------------- 1 | from math import ceil 2 | from traceback import format_exc 3 | 4 | from pyrogram.errors import MessageNotModified 5 | from pyrogram.types import ( 6 | InlineKeyboardButton, 7 | InlineQueryResultArticle, 8 | InputTextMessageContent, 9 | ) 10 | 11 | from Zaid import ids as list_users 12 | 13 | looters = None 14 | 15 | 16 | def paginate_help(page_number, loaded_modules, prefix): 17 | number_of_rows = 5 18 | number_of_cols = 3 19 | global looters 20 | looters = page_number 21 | helpable_modules = [p for p in loaded_modules if not p.startswith("_")] 22 | helpable_modules = sorted(helpable_modules) 23 | modules = [ 24 | InlineKeyboardButton( 25 | text="{}".format(x), 26 | callback_data=f"ub_modul_{x}", 27 | ) 28 | for x in helpable_modules 29 | ] 30 | pairs = list(zip(modules[::number_of_cols], modules[1::number_of_cols])) 31 | if len(modules) % number_of_cols == 1: 32 | pairs.append((modules[-1],)) 33 | max_num_pages = ceil(len(pairs) / number_of_rows) 34 | modulo_page = page_number % max_num_pages 35 | if len(pairs) > number_of_rows: 36 | pairs = pairs[ 37 | modulo_page * number_of_rows : number_of_rows * (modulo_page + 1) 38 | ] + [ 39 | ( 40 | InlineKeyboardButton( 41 | text="✘", callback_data=f"{prefix}_prev({modulo_page})" 42 | ), 43 | InlineKeyboardButton(text="ᴄʟᴏsᴇ", callback_data="close_help"), 44 | InlineKeyboardButton( 45 | text="✘", callback_data=f"{prefix}_next({modulo_page})" 46 | ), 47 | ) 48 | ] 49 | return pairs 50 | 51 | 52 | def cb_wrapper(func): 53 | async def wrapper(client, cb): 54 | users = list_users 55 | if cb.from_user.id not in users: 56 | await cb.answer( 57 | "Kya Hai? Kaam kar apna!", 58 | cache_time=0, 59 | show_alert=True, 60 | ) 61 | else: 62 | try: 63 | await func(client, cb) 64 | except MessageNotModified: 65 | await cb.answer("🤔🧐") 66 | except Exception: 67 | print(format_exc()) 68 | await cb.answer( 69 | f"Oh No, SomeThing Isn't Right. Please Check Logs!", 70 | cache_time=0, 71 | show_alert=True, 72 | ) 73 | 74 | return wrapper 75 | 76 | 77 | def inline_wrapper(func): 78 | async def wrapper(client, inline_query): 79 | users = list_users 80 | if inline_query.from_user.id not in users: 81 | await client.answer_inline_query( 82 | inline_query.id, 83 | cache_time=1, 84 | results=[ 85 | ( 86 | InlineQueryResultArticle( 87 | title="Sorry, Friend You Can't Use Me!", 88 | input_message_content=InputTextMessageContent( 89 | "You cannot access this Bot" 90 | ), 91 | ) 92 | ) 93 | ], 94 | ) 95 | else: 96 | await func(client, inline_query) 97 | 98 | return wrapper 99 | -------------------------------------------------------------------------------- /Zaid/helper/interval.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | class IntervalHelper: 5 | class IntervalError(Exception): 6 | pass 7 | 8 | interval_re = re.compile(r"^(\d+)(w|d|h|m)?$") 9 | 10 | def __init__(self, _interval): 11 | self._interval = _interval 12 | if not self.interval_ok(): 13 | raise Exception("Invalid interval format.") 14 | 15 | def interval_ok(self): 16 | if IntervalHelper.interval_re.match(self._interval): 17 | return True 18 | return False 19 | 20 | def to_secs(self): 21 | m = IntervalHelper.interval_re.match(self._interval) 22 | num, unit = m.groups() 23 | num = int(num) 24 | 25 | if not unit: 26 | unit = "m" 27 | 28 | if unit == "m": 29 | return [num * 60, num, "minute" if num == 1 else "minutes"] 30 | elif unit == "h": 31 | return [num * 60 * 60, num, "hour" if num == 1 else "hours"] 32 | elif unit == "d": 33 | return [num * 60 * 60 * 24, num, "day" if num == 1 else "days"] 34 | elif unit == "w": 35 | return [num * 60 * 60 * 24 * 7, num, "week" if num == 1 else "weeks"] 36 | 37 | interval = property(lambda self: self._interval) 38 | -------------------------------------------------------------------------------- /Zaid/helper/parser.py: -------------------------------------------------------------------------------- 1 | import html 2 | import re 3 | 4 | 5 | def cleanhtml(raw_html): 6 | cleanr = re.compile("<.*?>") 7 | cleantext = re.sub(cleanr, "", raw_html) 8 | return cleantext 9 | 10 | 11 | def escape_markdown(text): 12 | """Helper function to escape telegram markup symbols.""" 13 | escape_chars = r"\*_`\[" 14 | return re.sub(r"([%s])" % escape_chars, r"\\\1", text) 15 | 16 | 17 | def mention_html(user_id, name): 18 | return '{}'.format(user_id, html.escape(name)) 19 | 20 | 21 | def mention_markdown(user_id, name): 22 | return "[{}](tg://user?id={})".format(escape_markdown(name), user_id) 23 | -------------------------------------------------------------------------------- /Zaid/helper/utility.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import math 3 | import random 4 | import time 5 | import uuid 6 | from random import randint 7 | 8 | def get_arg(message): 9 | msg = message.text 10 | msg = msg.replace(" ", "", 1) if msg[1] == " " else msg 11 | split = msg[1:].replace("\n", " \n").split(" ") 12 | if " ".join(split[1:]).strip() == "": 13 | return "" 14 | return " ".join(split[1:]) 15 | 16 | def split_list(input_list, n): 17 | n = max(1, n) 18 | return [input_list[i: i + n] for i in range(0, len(input_list), n)] 19 | 20 | 21 | def human_time(*args, **kwargs): 22 | secs = float(datetime.timedelta(*args, **kwargs).total_seconds()) 23 | units = [("day", 86400), ("hour", 3600), ("minute", 60), ("second", 1)] 24 | parts = [] 25 | for unit, mul in units: 26 | if secs / mul >= 1 or mul == 1: 27 | if mul > 1: 28 | n = int(math.floor(secs / mul)) 29 | secs -= n * mul 30 | else: 31 | n = secs if secs != int(secs) else int(secs) 32 | parts.append("%s %s%s" % (n, unit, "" if n == 1 else "s")) 33 | return ", ".join(parts) 34 | 35 | 36 | def random_interval(): 37 | rand_value = randint(14400, 43200) 38 | delta = (time.time() + rand_value) - time.time() 39 | return int(delta) 40 | 41 | 42 | def get_random_hex(chars=4): 43 | my_hex = uuid.uuid4().hex[:chars] 44 | return my_hex 45 | 46 | 47 | def get_mock_text(sentence): 48 | new_sentence = "" 49 | number = 0 50 | 51 | for letter in sentence.lower(): 52 | if len(new_sentence) < 2: 53 | random_number = random.randint( 54 | 0, 1 55 | ) 56 | if random_number == 0: 57 | new_sentence += letter.upper() 58 | else: 59 | new_sentence += letter 60 | else: 61 | if ( 62 | new_sentence[number - 2].isupper() 63 | and new_sentence[number - 1].isupper() 64 | or new_sentence[number - 2].islower() 65 | and new_sentence[number - 1].islower() 66 | ): 67 | if new_sentence[ 68 | number - 1 69 | ].isupper(): 70 | new_sentence += letter.lower() 71 | else: 72 | new_sentence += letter.upper() 73 | else: 74 | random_number = random.randint(0, 1) 75 | if random_number == 0: 76 | new_sentence += letter.upper() 77 | else: 78 | new_sentence += letter 79 | 80 | number += 1 81 | return new_sentence 82 | -------------------------------------------------------------------------------- /Zaid/modules/__init__.py: -------------------------------------------------------------------------------- 1 | import glob 2 | from os.path import dirname, isfile 3 | 4 | 5 | def __list_all_modules(): 6 | work_dir = dirname(__file__) 7 | mod_paths = glob.glob(work_dir + "/*/*.py") 8 | 9 | all_modules = [ 10 | (((f.replace(work_dir, "")).replace("/", "."))[:-3]) 11 | for f in mod_paths 12 | if isfile(f) 13 | and f.endswith(".py") 14 | and not f.endswith("__init__.py") 15 | ] 16 | 17 | return all_modules 18 | 19 | 20 | ALL_MODULES = sorted(__list_all_modules()) 21 | __all__ = ALL_MODULES + ["ALL_MODULES"] 22 | -------------------------------------------------------------------------------- /Zaid/modules/basic/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Zaid/modules/basic/adminlist.py: -------------------------------------------------------------------------------- 1 | import html 2 | 3 | from pyrogram import Client, enums, filters 4 | from pyrogram.types import Message 5 | 6 | from Zaid.helper.basic import edit_or_reply 7 | from Zaid.helper.parser import mention_html, mention_markdown 8 | from Zaid.modules.help import * 9 | 10 | 11 | @Client.on_message(filters.me & filters.command(["admins", "adminlist"], ".")) 12 | async def adminlist(client: Client, message: Message): 13 | replyid = None 14 | toolong = False 15 | if len(message.text.split()) >= 2: 16 | chat = message.text.split(None, 1)[1] 17 | grup = await client.get_chat(chat) 18 | else: 19 | chat = message.chat.id 20 | grup = await client.get_chat(chat) 21 | if message.reply_to_message: 22 | replyid = message.reply_to_message.id 23 | creator = [] 24 | admin = [] 25 | badmin = [] 26 | async for a in client.get_chat_members( 27 | message.chat.id, filter=enums.ChatMembersFilter.ADMINISTRATORS 28 | ): 29 | try: 30 | nama = a.user.first_name + " " + a.user.last_name 31 | except: 32 | nama = a.user.first_name 33 | if nama is None: 34 | nama = "☠️ Deleted account" 35 | if a.status == enums.ChatMemberStatus.ADMINISTRATOR: 36 | if a.user.is_bot: 37 | badmin.append(mention_markdown(a.user.id, nama)) 38 | else: 39 | admin.append(mention_markdown(a.user.id, nama)) 40 | elif a.status == enums.ChatMemberStatus.OWNER: 41 | creator.append(mention_markdown(a.user.id, nama)) 42 | admin.sort() 43 | badmin.sort() 44 | totaladmins = len(creator) + len(admin) + len(badmin) 45 | teks = "**Admins in {}**\n".format(grup.title) 46 | teks += "╒═══「 Creator 」\n" 47 | for x in creator: 48 | teks += "│ • {}\n".format(x) 49 | if len(teks) >= 4096: 50 | await message.reply(message.chat.id, teks, reply_to_message_id=replyid) 51 | teks = "" 52 | toolong = True 53 | teks += "╞══「 {} Human Administrator 」\n".format(len(admin)) 54 | for x in admin: 55 | teks += "│ • {}\n".format(x) 56 | if len(teks) >= 4096: 57 | await message.reply(message.chat.id, teks, reply_to_message_id=replyid) 58 | teks = "" 59 | toolong = True 60 | teks += "╞══「 {} Bot Administrator 」\n".format(len(badmin)) 61 | for x in badmin: 62 | teks += "│ • {}\n".format(x) 63 | if len(teks) >= 4096: 64 | await message.reply(message.chat.id, teks, reply_to_message_id=replyid) 65 | teks = "" 66 | toolong = True 67 | teks += "╘══「 Total {} Admins 」".format(totaladmins) 68 | if toolong: 69 | await message.reply(message.chat.id, teks, reply_to_message_id=replyid) 70 | else: 71 | await message.edit(teks) 72 | 73 | 74 | @Client.on_message( 75 | filters.me & filters.command(["reportadmin", "reportadmins", "report"], ".") 76 | ) 77 | async def report_admin(client: Client, message: Message): 78 | await message.delete() 79 | if len(message.text.split()) >= 2: 80 | text = message.text.split(None, 1)[1] 81 | else: 82 | text = None 83 | grup = await client.get_chat(message.chat.id) 84 | admin = [] 85 | async for a in client.get_chat_members( 86 | message.chat.id, filter=enums.ChatMembersFilter.ADMINISTRATORS 87 | ): 88 | if ( 89 | a.status == enums.ChatMemberStatus.ADMINISTRATOR 90 | or a.status == enums.ChatMemberStatus.OWNER 91 | ): 92 | if not a.user.is_bot: 93 | admin.append(mention_html(a.user.id, "\u200b")) 94 | if message.reply_to_message: 95 | if text: 96 | teks = "{}".format(text) 97 | else: 98 | teks = "{} reported to admins.".format( 99 | mention_html( 100 | message.reply_to_message.from_user.id, 101 | message.reply_to_message.from_user.first_name, 102 | ) 103 | ) 104 | else: 105 | if text: 106 | teks = "{}".format(html.escape(text)) 107 | else: 108 | teks = "Calling admins in {}.".format(grup.title) 109 | teks += "".join(admin) 110 | if message.reply_to_message: 111 | await client.send_message( 112 | message.chat.id, 113 | teks, 114 | reply_to_message_id=message.reply_to_message.id, 115 | parse_mode=enums.ParseMode.HTML, 116 | ) 117 | else: 118 | await client.send_message( 119 | message.chat.id, teks, parse_mode=enums.ParseMode.HTML 120 | ) 121 | 122 | 123 | @Client.on_message(filters.me & filters.command(["everyone", "mentionall"], ".")) 124 | async def tag_all_users(client: Client, message: Message): 125 | await message.delete() 126 | if len(message.text.split()) >= 2: 127 | text = message.text.split(None, 1)[1] 128 | else: 129 | text = "Hi all 🙃" 130 | kek = client.get_chat_members(message.chat.id) 131 | async for a in kek: 132 | if not a.user.is_bot: 133 | text += mention_html(a.user.id, "\u200b") 134 | if message.reply_to_message: 135 | await client.send_message( 136 | message.chat.id, 137 | text, 138 | reply_to_message_id=message.reply_to_message.id, 139 | parse_mode=enums.ParseMode.HTML, 140 | ) 141 | else: 142 | await client.send_message( 143 | message.chat.id, text, parse_mode=enums.ParseMode.HTML 144 | ) 145 | 146 | 147 | @Client.on_message(filters.me & filters.command(["botlist", "bots"], ".")) 148 | async def get_list_bots(client: Client, message: Message): 149 | replyid = None 150 | if len(message.text.split()) >= 2: 151 | chat = message.text.split(None, 1)[1] 152 | grup = await client.get_chat(chat) 153 | else: 154 | chat = message.chat.id 155 | grup = await client.get_chat(chat) 156 | if message.reply_to_message: 157 | replyid = message.reply_to_message.id 158 | getbots = client.get_chat_members(chat) 159 | bots = [] 160 | async for a in getbots: 161 | try: 162 | nama = a.user.first_name + " " + a.user.last_name 163 | except: 164 | nama = a.user.first_name 165 | if nama is None: 166 | nama = "☠️ Deleted account" 167 | if a.user.is_bot: 168 | bots.append(mention_markdown(a.user.id, nama)) 169 | teks = "**All bots in group {}**\n".format(grup.title) 170 | teks += "╒═══「 Bots 」\n" 171 | for x in bots: 172 | teks += "│ • {}\n".format(x) 173 | teks += "╘══「 Total {} Bots 」".format(len(bots)) 174 | if replyid: 175 | await client.send_message(message.chat.id, teks, reply_to_message_id=replyid) 176 | else: 177 | await message.edit(teks) 178 | 179 | 180 | add_command_help( 181 | "tag", 182 | [ 183 | [f".admins", "Get chats Admins list."], 184 | [f".kickdel or .zombies", "To Kick deleted Accounts."], 185 | [ 186 | f".everyone `or` .mentionall", 187 | "to mention Everyone ", 188 | ], 189 | [ 190 | f".botlist", 191 | "To get Chats Bots list", 192 | ], 193 | ], 194 | ) 195 | -------------------------------------------------------------------------------- /Zaid/modules/basic/afk.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from datetime import datetime 3 | 4 | import humanize 5 | from pyrogram import filters, Client 6 | from pyrogram.types import Message 7 | 8 | from Zaid.helper.PyroHelpers import GetChatID, ReplyCheck 9 | from Zaid.modules.help import add_command_help 10 | 11 | AFK = False 12 | AFK_REASON = "" 13 | AFK_TIME = "" 14 | USERS = {} 15 | GROUPS = {} 16 | 17 | 18 | def subtract_time(start, end): 19 | subtracted = humanize.naturaltime(start - end) 20 | return str(subtracted) 21 | 22 | 23 | @Client.on_message( 24 | ((filters.group & filters.mentioned) | filters.private) & ~filters.me & ~filters.service, group=3 25 | ) 26 | async def collect_afk_messages(bot: Client, message: Message): 27 | if AFK: 28 | last_seen = subtract_time(datetime.now(), AFK_TIME) 29 | is_group = True if message.chat.type in ["supergroup", "group"] else False 30 | CHAT_TYPE = GROUPS if is_group else USERS 31 | 32 | if GetChatID(message) not in CHAT_TYPE: 33 | text = ( 34 | f"`Beep boop. This is an automated message.\n" 35 | f"I am not available right now.\n" 36 | f"Last seen: {last_seen}\n" 37 | f"Reason: ```{AFK_REASON.upper()}```\n" 38 | f"See you after I'm done doing whatever I'm doing.`" 39 | ) 40 | await bot.send_message( 41 | chat_id=GetChatID(message), 42 | text=text, 43 | reply_to_message_id=ReplyCheck(message), 44 | ) 45 | CHAT_TYPE[GetChatID(message)] = 1 46 | return 47 | elif GetChatID(message) in CHAT_TYPE: 48 | if CHAT_TYPE[GetChatID(message)] == 50: 49 | text = ( 50 | f"`This is an automated message\n" 51 | f"Last seen: {last_seen}\n" 52 | f"This is the 10th time I've told you I'm AFK right now..\n" 53 | f"I'll get to you when I get to you.\n" 54 | f"No more auto messages for you`" 55 | ) 56 | await bot.send_message( 57 | chat_id=GetChatID(message), 58 | text=text, 59 | reply_to_message_id=ReplyCheck(message), 60 | ) 61 | elif CHAT_TYPE[GetChatID(message)] > 50: 62 | return 63 | elif CHAT_TYPE[GetChatID(message)] % 5 == 0: 64 | text = ( 65 | f"`Hey I'm still not back yet.\n" 66 | f"Last seen: {last_seen}\n" 67 | f"Still busy: ```{AFK_REASON.upper()}```\n" 68 | f"Try pinging a bit later.`" 69 | ) 70 | await bot.send_message( 71 | chat_id=GetChatID(message), 72 | text=text, 73 | reply_to_message_id=ReplyCheck(message), 74 | ) 75 | 76 | CHAT_TYPE[GetChatID(message)] += 1 77 | 78 | 79 | @Client.on_message(filters.command("afk", ".") & filters.me, group=3) 80 | async def afk_set(bot: Client, message: Message): 81 | global AFK_REASON, AFK, AFK_TIME 82 | 83 | cmd = message.command 84 | afk_text = "" 85 | 86 | if len(cmd) > 1: 87 | afk_text = " ".join(cmd[1:]) 88 | 89 | if isinstance(afk_text, str): 90 | AFK_REASON = afk_text 91 | 92 | AFK = True 93 | AFK_TIME = datetime.now() 94 | 95 | await message.delete() 96 | 97 | 98 | @Client.on_message(filters.command("afk", "!") & filters.me, group=3) 99 | async def afk_unset(bot: Client, message: Message): 100 | global AFK, AFK_TIME, AFK_REASON, USERS, GROUPS 101 | 102 | if AFK: 103 | last_seen = subtract_time(datetime.now(), AFK_TIME).replace("ago", "").strip() 104 | await message.edit( 105 | f"`While you were away (for {last_seen}), you received {sum(USERS.values()) + sum(GROUPS.values())} " 106 | f"messages from {len(USERS) + len(GROUPS)} chats`" 107 | ) 108 | AFK = False 109 | AFK_TIME = "" 110 | AFK_REASON = "" 111 | USERS = {} 112 | GROUPS = {} 113 | await asyncio.sleep(5) 114 | 115 | await message.delete() 116 | 117 | if AFK: 118 | @Client.on_message(filters.me, group=3) 119 | async def auto_afk_unset(bot: Client, message: Message): 120 | global AFK, AFK_TIME, AFK_REASON, USERS, GROUPS 121 | 122 | if AFK: 123 | last_seen = subtract_time(datetime.now(), AFK_TIME).replace("ago", "").strip() 124 | reply = await message.reply( 125 | f"`While you were away (for {last_seen}), you received {sum(USERS.values()) + sum(GROUPS.values())} " 126 | f"messages from {len(USERS) + len(GROUPS)} chats`" 127 | ) 128 | AFK = False 129 | AFK_TIME = "" 130 | AFK_REASON = "" 131 | USERS = {} 132 | GROUPS = {} 133 | await asyncio.sleep(5) 134 | await reply.delete() 135 | 136 | 137 | add_command_help( 138 | "afk", 139 | [ 140 | [".afk", "Activates AFK mode with reason as anything after .afk\nUsage: ```.afk" 32 | + i["definition"] 33 | + "\nExample\n
" 34 | + i["example"] 35 | + "" 36 | ) 37 | else: 38 | w_word += ( 39 | "\n**Definition**\n" + "
" + i["definition"] + "" 40 | ) 41 | w_word += "\n\n" 42 | return w_word 43 | 44 | def out_print(word1): 45 | out = "" 46 | if "meaning" in list(word1): 47 | meaning = word1["meaning"] 48 | if "noun" in list(meaning): 49 | noun = meaning["noun"] 50 | out += combine(noun, "noun") 51 | if "verb" in list(meaning): 52 | verb = meaning["verb"] 53 | out += combine(verb, "verb") 54 | if "preposition" in list(meaning): 55 | preposition = meaning["preposition"] 56 | out += combine(preposition, "preposition") 57 | if "adverb" in list(meaning): 58 | adverb = meaning["adverb"] 59 | out += combine(adverb, "adverb") 60 | if "adjective" in list(meaning): 61 | adjec = meaning["adjective"] 62 | out += combine(adjec, "adjective") 63 | if "abbreviation" in list(meaning): 64 | abbr = meaning["abbreviation"] 65 | out += combine(abbr, "abbreviation") 66 | if "exclamation" in list(meaning): 67 | exclamation = meaning["exclamation"] 68 | out += combine(exclamation, "exclamation") 69 | if "transitive verb" in list(meaning): 70 | transitive_verb = meaning["transitive verb"] 71 | out += combine(transitive_verb, "transitive verb") 72 | if "determiner" in list(meaning): 73 | determiner = meaning["determiner"] 74 | out += combine(determiner, "determiner") 75 | # print(determiner) 76 | if "crossReference" in list(meaning): 77 | crosref = meaning["crossReference"] 78 | out += combine(crosref, "crossReference") 79 | if "title" in list(word1): 80 | out += ( 81 | "**__Error Note__**\n\n▪️`" 82 | + word1["title"] 83 | + "\n\n▪️" 84 | + word1["message"] 85 | + "\n\n▪️" 86 | + word1["resolution"] 87 | + "`" 88 | ) 89 | return out 90 | 91 | if not input_string: 92 | await message.edit("`Plz enter word to search‼️`") 93 | else: 94 | word = input_string 95 | r_dec = await AioHttp().get_json( 96 | f"https://api.dictionaryapi.dev/api/v1/entries/en/{word}" 97 | ) 98 | 99 | v_word = input_string 100 | if isinstance(r_dec, list): 101 | r_dec = r_dec[0] 102 | v_word = r_dec["word"] 103 | last_output = out_print(r_dec) 104 | if last_output: 105 | await message.edit( 106 | "`Search result for `" + f" {v_word}\n\n" + last_output 107 | ) 108 | else: 109 | await message.edit("`No result found from the database.`") 110 | 111 | 112 | add_command_help( 113 | "dictionary", 114 | [ 115 | [".define | .dict", "Define the word you send or reply to."], 116 | ], 117 | ) 118 | -------------------------------------------------------------------------------- /Zaid/modules/basic/eval_exec.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import io 3 | import os 4 | import sys 5 | import traceback 6 | 7 | from pyrogram import filters, Client 8 | from pyrogram.types import Message 9 | 10 | from Zaid.database import cli as database 11 | from Zaid.helper.PyroHelpers import ReplyCheck 12 | 13 | 14 | @Client.on_message( 15 | filters.command("eval", ".") 16 | & filters.me 17 | & ~filters.forwarded 18 | & ~filters.via_bot 19 | ) 20 | async def eval_func_init(bot, message): 21 | await evaluation_func(bot, message) 22 | 23 | 24 | @Client.on_edited_message( 25 | filters.command("eval", ".") 26 | & filters.me 27 | & ~filters.forwarded 28 | & ~filters.via_bot 29 | ) 30 | async def eval_func_edited(bot, message): 31 | await evaluation_func(bot, message) 32 | 33 | 34 | async def evaluation_func(bot: Client, message: Message): 35 | status_message = await message.reply_text("Processing ...") 36 | cmd = message.text.split(" ", maxsplit=1)[1] 37 | 38 | reply_to_id = message.id 39 | if message.reply_to_message: 40 | reply_to_id = message.reply_to_message.id 41 | 42 | old_stderr = sys.stderr 43 | old_stdout = sys.stdout 44 | redirected_output = sys.stdout = io.StringIO() 45 | redirected_error = sys.stderr = io.StringIO() 46 | stdout, stderr, exc = None, None, None 47 | 48 | try: 49 | reply = message.reply_to_message or None 50 | await aexec(cmd, bot, message, reply, database) 51 | except Exception: 52 | exc = traceback.format_exc() 53 | 54 | stdout = redirected_output.getvalue() 55 | stderr = redirected_error.getvalue() 56 | sys.stdout = old_stdout 57 | sys.stderr = old_stderr 58 | 59 | if exc: 60 | evaluation = exc 61 | elif stderr: 62 | evaluation = stderr 63 | elif stdout: 64 | evaluation = stdout 65 | else: 66 | evaluation = "Success" 67 | 68 | final_output = "Expression:\n
{}
\n\nResult:\n{}
\n".format(
69 | cmd, evaluation.strip()
70 | )
71 |
72 | if len(final_output) > 4096:
73 | with open("eval.txt", "w", encoding="utf8") as out_file:
74 | out_file.write(str(final_output))
75 |
76 | await message.reply_document(
77 | "eval.txt",
78 | caption=cmd,
79 | disable_notification=True,
80 | reply_to_message_id=ReplyCheck(message),
81 | )
82 | os.remove("eval.txt")
83 | await status_message.delete()
84 | else:
85 | await status_message.edit(final_output)
86 |
87 |
88 | async def aexec(code, b, m, r, d):
89 | sys.tracebacklimit = 0
90 | exec(
91 | "async def __aexec(b, m, r, d): "
92 | + "".join(f"\n {line}" for line in code.split("\n"))
93 | )
94 | return await locals()["__aexec"](b, m, r, d)
95 |
96 |
97 | @Client.on_edited_message(
98 | filters.command("exec", ".")
99 | & filters.me
100 | & ~filters.forwarded
101 | & ~filters.via_bot
102 | )
103 | async def execution_func_edited(bot, message):
104 | await execution(bot, message)
105 |
106 |
107 | @Client.on_message(
108 | filters.command("exec", ".")
109 | & filters.me
110 | & ~filters.forwarded
111 | & ~filters.via_bot
112 | )
113 | async def execution_func(bot, message):
114 | await execution(bot, message)
115 |
116 |
117 | async def execution(bot: Client, message: Message):
118 | cmd = message.text.split(" ", maxsplit=1)[1]
119 |
120 | reply_to_id = message.id
121 | if message.reply_to_message:
122 | reply_to_id = message.reply_to_message.id
123 |
124 | process = await asyncio.create_subprocess_shell(
125 | cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
126 | )
127 | stdout, stderr = await process.communicate()
128 | e = stderr.decode()
129 | if not e:
130 | e = "No errors"
131 | o = stdout.decode()
132 | if not o:
133 | o = "No output"
134 |
135 | OUTPUT = ""
136 | OUTPUT += f"Command:\n{cmd}
\n\n"
137 | OUTPUT += f"Output: \n{o}
\n"
138 | OUTPUT += f"Errors: \n{e}
"
139 |
140 | if len(OUTPUT) > 4096:
141 | with open("exec.text", "w+", encoding="utf8") as out_file:
142 | out_file.write(str(OUTPUT))
143 | await message.reply_document(
144 | document="exec.text",
145 | caption=cmd,
146 | disable_notification=True,
147 | reply_to_message_id=ReplyCheck(message),
148 | )
149 | os.remove("exec.text")
150 | else:
151 | await message.reply_text(OUTPUT)
152 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/git_commands.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import datetime
3 | import os
4 | from asyncio import sleep
5 | from glob import iglob
6 | from random import randint
7 |
8 | import aiofiles
9 | from pyrogram import filters, Client
10 | from pyrogram.types import Message
11 | from reportlab.graphics import renderPM
12 | from svglib.svglib import svg2rlg
13 |
14 | from Zaid.helper.PyroHelpers import ReplyCheck
15 | from Zaid.helper.aiohttp_helper import AioHttp
16 | from Zaid.modules.help import add_command_help
17 |
18 |
19 | @Client.on_message(filters.command(["ggraph", "commitgraph"], ".") & filters.me)
20 | async def commit_graph(bot: Client, message: Message):
21 | if len(message.command) < 2:
22 | await message.edit(
23 | "Please provide a github profile username to generate the graph!"
24 | )
25 | await sleep(2)
26 | await message.delete()
27 | return
28 | else:
29 | git_user = message.command[1]
30 |
31 | url = f"https://ghchart.rshah.org/{git_user}"
32 | file_name = f"{randint(1, 999)}{git_user}"
33 |
34 | resp = await AioHttp.get_raw(url)
35 | f = await aiofiles.open(f"{file_name}.svg", mode="wb")
36 | await f.write(resp)
37 | await f.close()
38 |
39 | try:
40 | drawing = svg2rlg(f"{file_name}.svg")
41 | renderPM.drawToFile(drawing, f"{file_name}.png")
42 | except UnboundLocalError:
43 | await message.edit("Username does not exist!")
44 | await sleep(2)
45 | await message.delete()
46 | return
47 |
48 | await asyncio.gather(
49 | bot.send_photo(
50 | chat_id=message.chat.id,
51 | photo=f"{file_name}.png",
52 | caption=git_user,
53 | reply_to_message_id=ReplyCheck(message),
54 | ),
55 | message.delete(),
56 | )
57 |
58 | for file in iglob(f"{file_name}.*"):
59 | os.remove(file)
60 |
61 |
62 | add_command_help(
63 | "git",
64 | [
65 | [".ggraph | .commitgraph", "Gets the commit graph for a Github user."],
66 | ],
67 | )
68 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/google.py:
--------------------------------------------------------------------------------
1 | import requests
2 | from bs4 import BeautifulSoup
3 | from googlesearch import search
4 | from pyrogram import Client, filters
5 | from pyrogram.types import Message
6 |
7 | from Zaid.helper.basic import edit_or_reply
8 |
9 | from Zaid.modules.help import *
10 |
11 |
12 | def googlesearch(query):
13 | co = 1
14 | returnquery = {}
15 | for j in search(query, tld="co.in", num=10, stop=10, pause=2):
16 | url = str(j)
17 | response = requests.get(url)
18 | soup = BeautifulSoup(response.text, "html.parser")
19 | metas = soup.find_all("meta")
20 | site_title = None
21 | for title in soup.find_all("title"):
22 | site_title = title.get_text()
23 | metadeta = [
24 | meta.attrs["content"]
25 | for meta in metas
26 | if "name" in meta.attrs and meta.attrs["name"] == "description"
27 | ]
28 | returnquery[co] = {"title": site_title, "metadata": metadeta, "url": j}
29 | co = co + 1
30 | return returnquery
31 |
32 |
33 | @Client.on_message(filters.command(["gs", "google"], ".") & filters.me)
34 | async def gs(client: Client, message: Message):
35 | Man = await edit_or_reply(message, "`Processing...`")
36 | msg_txt = message.text
37 | returnmsg = ""
38 | query = None
39 | if " " in msg_txt:
40 | query = msg_txt[msg_txt.index(" ") + 1 : len(msg_txt)]
41 | else:
42 | await Man.edit("Give a query to search")
43 | return
44 | results = googlesearch(query)
45 | for i in range(1, 10, 1):
46 | presentquery = results[i]
47 | presenttitle = presentquery["title"]
48 | presentmeta = presentquery["metadata"]
49 | presenturl = presentquery["url"]
50 | print(presentquery)
51 | print(presenttitle)
52 | print(presentmeta)
53 | print(presenturl)
54 | if not presentmeta:
55 | presentmeta = ""
56 | else:
57 | presentmeta = presentmeta[0]
58 | returnmsg = (
59 | returnmsg
60 | + f"[{str(presenttitle)}]({str(presenturl)})\n{str(presentmeta)}\n\n"
61 | )
62 | await Man.edit(returnmsg)
63 |
64 |
65 | add_command_help(
66 | "google",
67 | [
68 | [
69 | "google",
70 | "Featch Details on Google.",
71 | ],
72 | ],
73 | )
74 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/hentai_api.py:
--------------------------------------------------------------------------------
1 | from aiohttp.client_exceptions import ClientError
2 | from pyrogram import filters, Client
3 | from pyrogram.types import Message
4 |
5 |
6 | from Zaid.helper.aiohttp_helper import AioHttp
7 | from Zaid.modules.help import add_command_help
8 |
9 | cf_api_data = {
10 | "anime": {
11 | "url": "https://api.computerfreaker.cf/v1/anime",
12 | "help": "It works on my machine!",
13 | },
14 | "hentai": {
15 | "url": "https://api.computerfreaker.cf/v1/hentai",
16 | "help": "Sends a nice compliment.",
17 | },
18 | "yuri": {
19 | "url": "https://api.computerfreaker.cf/v1/yuri",
20 | "help": "Affirmative messages",
21 | },
22 | "dva": {
23 | "url": "https://api.computerfreaker.cf/v1/dva",
24 | "help": "Affirmative messages",
25 | },
26 | "trap": {
27 | "url": "https://api.computerfreaker.cf/v1/trap",
28 | "help": "Affirmative messages",
29 | },
30 | "hug": {
31 | "url": "https://api.computerfreaker.cf/v1/hug",
32 | "help": "Give it a guess dumbass!",
33 | },
34 | "neko": {
35 | "url": "https://api.computerfreaker.cf/v1/neko",
36 | "format": "Kanye once said:\n`{}`",
37 | "help": "Kanye used to say",
38 | },
39 | "nsfwneko": {
40 | "url": "https://api.computerfreaker.cf/v1/nsfwneko",
41 | "help": "Programmers be like.",
42 | },
43 | "baguette": {
44 | "url": "https://api.computerfreaker.cf/v1/baguette",
45 | "help": "Affirmative messages",
46 | },
47 | }
48 |
49 | text_api_commands = []
50 | for x in cf_api_data:
51 | text_api_commands.append(x)
52 | if "alts" in cf_api_data[x]:
53 | for y in cf_api_data[x]["alts"]:
54 | text_api_commands.append(y)
55 |
56 |
57 | @Client.on_message(
58 | filters.command(text_api_commands, ".") & filters.me
59 | )
60 | async def hentai_api(bot: Client, message: Message):
61 | cmd = message.command
62 | api_key = cmd[0]
63 | api = cf_api_data[api_key]
64 |
65 | try:
66 | data = await AioHttp().get_json(api["url"])
67 | content_url: str = data['url']
68 | await bot.send_photo(message.chat.id, content_url)
69 | except ClientError as e:
70 | print(e)
71 |
72 | await message.delete()
73 |
74 |
75 |
76 | for x in cf_api_data:
77 | add_command_help(
78 | "anime_cf",
79 | [
80 | [f".{x}", cf_api_data[x]["help"]],
81 | ],
82 | )
83 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/invite.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | from pyrogram import Client, filters
3 | from pyrogram.enums import ChatType, UserStatus
4 | from pyrogram.types import Message
5 | from Zaid import SUDO_USER
6 | from pyrogram.errors.exceptions.flood_420 import FloodWait
7 |
8 | from Zaid.modules.help import add_command_help
9 |
10 |
11 | @Client.on_message(
12 | filters.command(["invite"], ".") & (filters.me | filters.user(SUDO_USER))
13 | )
14 | async def inviteee(client: Client, message: Message):
15 | mg = await message.reply_text("`Adding Users!`")
16 | user_s_to_add = message.text.split(" ", 1)[1]
17 | if not user_s_to_add:
18 | await mg.edit("`Give Me Users To Add! Check Help Menu For More Info!`")
19 | return
20 | user_list = user_s_to_add.split(" ")
21 | try:
22 | await client.add_chat_members(message.chat.id, user_list, forward_limit=100)
23 | except BaseException as e:
24 | await mg.edit(f"`Unable To Add Users! \nTraceBack : {e}`")
25 | return
26 | await mg.edit(f"`Sucessfully Added {len(user_list)} To This Group / Channel!`")
27 |
28 | @Client.on_message(
29 | filters.command(["inviteall"], ".") & (filters.me | filters.user(SUDO_USER))
30 | )
31 | async def inv(client: Client, message: Message):
32 | ex = await message.reply_text("`Processing . . .`")
33 | text = message.text.split(" ", 1)
34 | queryy = text[1]
35 | chat = await client.get_chat(queryy)
36 | tgchat = message.chat
37 | await ex.edit_text(f"inviting users from {chat.username}")
38 | async for member in client.get_chat_members(chat.id):
39 | user = member.user
40 | zxb = [
41 | UserStatus.ONLINE,
42 | UserStatus.OFFLINE,
43 | UserStatus.RECENTLY,
44 | UserStatus.LAST_WEEK,
45 | ]
46 | if user.status in zxb:
47 | try:
48 | await client.add_chat_members(tgchat.id, user.id)
49 | except FloodWait as e:
50 | return
51 | except Exception as e:
52 | pass
53 |
54 | @Client.on_message(filters.command("invitelink", ".") & filters.me)
55 | async def invite_link(client: Client, message: Message):
56 | um = await message.edit_text("`Processing...`")
57 | if message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP]:
58 | message.chat.title
59 | try:
60 | link = await client.export_chat_invite_link(message.chat.id)
61 | await um.edit(f"**Link Invite:** {link}")
62 | except Exception:
63 | await um.edit("Denied permission")
64 |
65 |
66 | add_command_help(
67 | "invite",
68 | [
69 | [
70 | "invitelink",
71 | "Get your private invite link. [Need Admin]",
72 | ],
73 | ["invite @username", "to invite someone."],
74 | ["inviteall @username", "Mass adding (can affect your account)."],
75 | ],
76 | )
77 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/joinleave.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client, enums, filters
2 | from pyrogram.types import Message
3 |
4 | from Zaid import SUDO_USER
5 | from Zaid.modules.help import add_command_help
6 |
7 | @Client.on_message(
8 | filters.command(["join"], ".") & (filters.me | filters.user(SUDO_USER))
9 | )
10 | async def join(client: Client, message: Message):
11 | tex = message.command[1] if len(message.command) > 1 else message.chat.id
12 | g = await message.reply_text("`Processing...`")
13 | try:
14 | await client.join_chat(tex)
15 | await g.edit(f"**Successfully Joined Chat ID** `{tex}`")
16 | except Exception as ex:
17 | await g.edit(f"**ERROR:** \n\n{str(ex)}")
18 |
19 |
20 | @Client.on_message(
21 | filters.command(["leave"], ".") & (filters.me | filters.user(SUDO_USER))
22 | )
23 | async def leave(client: Client, message: Message):
24 | xd = message.command[1] if len(message.command) > 1 else message.chat.id
25 | xv = await message.reply_text("`Processing...`")
26 | try:
27 | await xv.edit_text(f"{client.me.first_name} has left this group, bye!!")
28 | await client.leave_chat(xd)
29 | except Exception as ex:
30 | await xv.edit_text(f"**ERROR:** \n\n{str(ex)}")
31 |
32 |
33 | @Client.on_message(
34 | filters.command(["leaveallgc"], ".") & (filters.me | filters.user(SUDO_USER))
35 | )
36 | async def kickmeall(client: Client, message: Message):
37 | tex = await message.reply_text("`Global Leave from group chats...`")
38 | er = 0
39 | done = 0
40 | async for dialog in client.get_dialogs():
41 | if dialog.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP):
42 | chat = dialog.chat.id
43 | try:
44 | done += 1
45 | await client.leave_chat(chat)
46 | except BaseException:
47 | er += 1
48 | await tex.edit(
49 | f"**Successfully left {done} Groups, Failed to left {er} Groups**"
50 | )
51 |
52 |
53 | @Client.on_message(filters.command(["leaveallch"], ".") & filters.me)
54 | async def kickmeallch(client: Client, message: Message):
55 | ok = await message.reply_text("`Global Leave from group chats...`")
56 | er = 0
57 | done = 0
58 | async for dialog in client.get_dialogs():
59 | if dialog.chat.type in (enums.ChatType.CHANNEL):
60 | chat = dialog.chat.id
61 | try:
62 | done += 1
63 | await client.leave_chat(chat)
64 | except BaseException:
65 | er += 1
66 | await ok.edit(
67 | f"**Successfully left {done} Channel, failed to left {er} Channel**"
68 | )
69 |
70 |
71 | add_command_help(
72 | "joinleave",
73 | [
74 | [
75 | "kickme",
76 | "To leave!!.",
77 | ],
78 | ["leaveallgc", "to leave all groups where you joined."],
79 | ["leaveallch", "to leaveall channel where you joined."],
80 | ["join [Username]", "give an specific username to join."],
81 | ["leave [Username]", "give an specific username to leave."],
82 | ],
83 | )
84 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/locks.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client, filters
2 | from pyrogram.errors.exceptions.bad_request_400 import (
3 | ChatAdminRequired,
4 | ChatNotModified,
5 | )
6 | from pyrogram.types import ChatPermissions, Message
7 |
8 | from Zaid.modules.help import add_command_help
9 |
10 | incorrect_parameters = f"Parameter Wrong, Type `.help locks`"
11 | data = {
12 | "msg": "can_send_messages",
13 | "stickers": "can_send_other_messages",
14 | "gifs": "can_send_other_messages",
15 | "media": "can_send_media_messages",
16 | "games": "can_send_other_messages",
17 | "inline": "can_send_other_messages",
18 | "url": "can_add_web_page_previews",
19 | "polls": "can_send_polls",
20 | "info": "can_change_info",
21 | "invite": "can_invite_users",
22 | "pin": "can_pin_messages",
23 | }
24 |
25 |
26 | async def current_chat_permissions(client: Client, chat_id):
27 | perms = []
28 | perm = (await client.get_chat(chat_id)).permissions
29 | if perm.can_send_messages:
30 | perms.append("can_send_messages")
31 | if perm.can_send_media_messages:
32 | perms.append("can_send_media_messages")
33 | if perm.can_send_other_messages:
34 | perms.append("can_send_other_messages")
35 | if perm.can_add_web_page_previews:
36 | perms.append("can_add_web_page_previews")
37 | if perm.can_send_polls:
38 | perms.append("can_send_polls")
39 | if perm.can_change_info:
40 | perms.append("can_change_info")
41 | if perm.can_invite_users:
42 | perms.append("can_invite_users")
43 | if perm.can_pin_messages:
44 | perms.append("can_pin_messages")
45 | return perms
46 |
47 |
48 | async def tg_lock(
49 | client: Client,
50 | message: Message,
51 | parameter,
52 | permissions: list,
53 | perm: str,
54 | lock: bool,
55 | ):
56 | if lock:
57 | if perm not in permissions:
58 | return await message.edit_text(f"🔒 `{parameter}` **is already locked!**")
59 | permissions.remove(perm)
60 | else:
61 | if perm in permissions:
62 | return await message.edit_text(f"🔓 `{parameter}` **is already Unlocked!**")
63 | permissions.append(perm)
64 | permissions = {perm: True for perm in list(set(permissions))}
65 | try:
66 | await client.set_chat_permissions(
67 | message.chat.id, ChatPermissions(**permissions)
68 | )
69 | except ChatNotModified:
70 | return await message.edit_text(
71 | f"To unlock this, you have to `{prefix}unlock msg` first."
72 | )
73 | except ChatAdminRequired:
74 | return await message.edit_text("`I don't have permission to do that.`")
75 | await message.edit_text(
76 | (
77 | f"🔒 **Locked for non-admin!**\n **Type:** `{parameter}`\n **Chat:** {message.chat.title}"
78 | if lock
79 | else f"🔒 **Unlocked for non-admin!**\n **Type:** `{parameter}`\n **Chat:** {message.chat.title}"
80 | )
81 | )
82 |
83 |
84 | @Client.on_message(filters.command(["lock", "unlock"], ".") & filters.me)
85 | async def locks_func(client: Client, message: Message):
86 | if len(message.command) != 2:
87 | return await message.edit_text(incorrect_parameters)
88 | chat_id = message.chat.id
89 | parameter = message.text.strip().split(None, 1)[1].lower()
90 | state = message.command[0].lower()
91 | if parameter not in data and parameter != "all":
92 | return await message.edit_text(incorrect_parameters)
93 | permissions = await current_chat_permissions(client, chat_id)
94 | if parameter in data:
95 | await tg_lock(
96 | client,
97 | message,
98 | parameter,
99 | permissions,
100 | data[parameter],
101 | bool(state == "lock"),
102 | )
103 | elif parameter == "all" and state == "lock":
104 | try:
105 | await client.set_chat_permissions(chat_id, ChatPermissions())
106 | await message.edit_text(
107 | f"🔒 **Locked for non-admin!**\n **Type:** `{parameter}`\n **Chat:** {message.chat.title}"
108 | )
109 | except ChatAdminRequired:
110 | return await message.edit_text("`I don't have permission to do that.`")
111 | except ChatNotModified:
112 | return await message.edit_text(
113 | f"🔒 **Already locked!**\n **Type:** `{parameter}`\n **Chat:** {message.chat.title}"
114 | )
115 | elif parameter == "all" and state == "unlock":
116 | try:
117 | await client.set_chat_permissions(
118 | chat_id,
119 | ChatPermissions(
120 | can_send_messages=True,
121 | can_send_media_messages=True,
122 | can_send_other_messages=True,
123 | can_add_web_page_previews=True,
124 | can_send_polls=True,
125 | can_change_info=False,
126 | can_invite_users=True,
127 | can_pin_messages=False,
128 | ),
129 | )
130 | except ChatAdminRequired:
131 | return await message.edit_text("`I don't have permission to do that.`")
132 | await message.edit(
133 | f"🔒 **Unlocked for non-admin!**\n **Type:** `{parameter}`\n **Chat:** {message.chat.title}"
134 | )
135 |
136 |
137 | @Client.on_message(filters.command("locks", ".") & filters.me)
138 | async def locktypes(client: Client, message: Message):
139 | permissions = await current_chat_permissions(client, message.chat.id)
140 |
141 | if not permissions:
142 | return await message.edit("🔒 **Everything is locked!**")
143 |
144 | perms = ""
145 | for i in permissions:
146 | perms += f" • __**{i}**__\n"
147 |
148 | await message.edit_text(perms)
149 |
150 |
151 | add_command_help(
152 | "locks",
153 | [
154 | ["lock [all or specific]", "restrict user to send."],
155 | [
156 | "unlock [all or specific]",
157 | "Unrestrict\n\nSupported Locks / Unlocks:` `msg` | `media` | `stickers` | `polls` | `info` | `invite` | `webprev` |`pin` | `all`.",
158 | ],
159 | ],
160 | )
161 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/lyrics.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from pyrogram import filters, Client
4 | from pyrogram.types import Message
5 |
6 | from Zaid import SUDO_USER
7 | from Zaid.modules.help import add_command_help
8 |
9 |
10 | @Client.on_message(
11 | filters.command(["l", "lyrics"], ".") & (filters.me | filters.user(SUDO_USER))
12 | )
13 | async def send_lyrics(bot: Client, message: Message):
14 | try:
15 | cmd = message.command
16 |
17 | song_name = ""
18 | if len(cmd) > 1:
19 | song_name = " ".join(cmd[1:])
20 | elif message.reply_to_message:
21 | if message.reply_to_message.audio:
22 | song_name = f"{message.reply_to_message.audio.title} {message.reply_to_message.audio.performer}"
23 | elif len(cmd) == 1:
24 | song_name = message.reply_to_message.text
25 | elif not message.reply_to_message and len(cmd) == 1:
26 | await message.edit("Give a song name")
27 | await asyncio.sleep(2)
28 | await message.delete()
29 | return
30 |
31 | await message.edit(f"Getting lyrics for `{song_name}`")
32 | lyrics_results = await bot.get_inline_bot_results("ilyricsbot", song_name)
33 |
34 | try:
35 | # send to Saved Messages because hide_via doesn't work sometimes
36 | saved = await bot.send_inline_bot_result(
37 | chat_id="me",
38 | query_id=lyrics_results.query_id,
39 | result_id=lyrics_results.results[0].id,
40 | )
41 | await asyncio.sleep(3)
42 |
43 | # forward from Saved Messages
44 | await bot.copy_message(
45 | chat_id=message.chat.id,
46 | from_chat_id="me",
47 | message_id=saved.updates[1].message.id,
48 | )
49 |
50 | # delete the message from Saved Messages
51 | await bot.delete_messages("me", saved.updates[1].message.id)
52 | except TimeoutError:
53 | await message.edit("That didn't work out")
54 | await asyncio.sleep(2)
55 | await message.delete()
56 | except Exception as e:
57 | await message.edit("`Failed to find lyrics`")
58 | await asyncio.sleep(2)
59 | await message.delete()
60 |
61 |
62 | add_command_help("lyrics", [[".l `or` .lyrics", "Search lyrics and send."]])
63 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/mention.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | from functools import partial
3 |
4 | from pyrogram import filters, Client
5 | from pyrogram.types import Message
6 |
7 |
8 | from Zaid.modules.help import add_command_help
9 |
10 | mention = partial("{}".format)
11 |
12 | hmention = partial("\u200B{}".format)
13 |
14 |
15 | @Client.on_message(filters.command("mention", ".") & filters.me)
16 | async def mention_user(bot: Client, message: Message):
17 | if len(message.command) < 3:
18 | await message.edit("Incorrect format\nExample: .mention @Athfan CTO")
19 | await asyncio.sleep(3)
20 | await message.delete()
21 | return
22 | try:
23 | user = await bot.get_users(message.command[1])
24 | except Exception:
25 | await message.edit("User not found")
26 | await asyncio.sleep(3)
27 | await message.delete()
28 | return
29 |
30 | _mention = mention(user.id, " ".join(message.command[2:]))
31 | await message.edit(_mention)
32 |
33 |
34 | @Client.on_message(filters.command("hmention", ".") & filters.me)
35 | async def hidden_mention(bot: Client, message: Message):
36 | if len(message.command) < 3:
37 | await message.edit("Incorrect format\nExample: .hmention @Athfan")
38 | await asyncio.sleep(3)
39 | await message.delete()
40 | return
41 | try:
42 | user = await bot.get_users(message.command[1])
43 | except Exception:
44 | await message.edit("User not found")
45 | await asyncio.sleep(3)
46 | await message.delete()
47 | return
48 |
49 | _hmention = hmention(user.id, " ".join(message.command[2:]))
50 | await message.edit(_hmention)
51 |
52 |
53 |
54 | add_command_help(
55 | "mention",
56 | [
57 | [
58 | ".mention",
59 | "Mention a user with a different name\nExample: `.mention @user CTO`",
60 | ],
61 | [
62 | ".hmention",
63 | "Mention a user with a hidden text\nExample: `.hmention @user`",
64 | ],
65 | ],
66 | )
67 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/metrics.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from pyrogram import filters, Client
4 | from pyrogram.types import Message
5 |
6 | from Zaid.modules.help import add_command_help
7 |
8 |
9 | class Custom(dict):
10 | def __missing__(self, key):
11 | return 0
12 |
13 |
14 | @Client.on_message(filters.command("wordcount", ".") & filters.me)
15 | async def word_count(bot: Client, message: Message):
16 | await message.delete()
17 | words = Custom()
18 | progress = await bot.send_message(message.chat.id, "`Processed 0 messages...`")
19 | total = 0
20 | async for msg in bot.iter_history(message.chat.id, 1000):
21 | total += 1
22 | if total % 100 == 0:
23 | await progress.edit_text(f"`Processed {total} messages...`")
24 | time.sleep(0.5)
25 | if msg.text:
26 | for word in msg.text.split():
27 | words[word.lower()] += 1
28 | if msg.caption:
29 | for word in msg.caption.split():
30 | words[word.lower()] += 1
31 | freq = sorted(words, key=words.get, reverse=True)
32 | out = "Word Counter\n"
33 | for i in range(25):
34 | out += f"{i + 1}. **{words[freq[i]]}**: {freq[i]}\n"
35 |
36 | await progress.edit_text(out)
37 |
38 |
39 | add_command_help(
40 | "metrics",
41 | [
42 | [
43 | ".wordcount",
44 | "Finds the 25 most used words in the last 1000 messages in a group or private chat. Use in "
45 | "chat you want to find the metric in.",
46 | ],
47 | ],
48 | )
49 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/misc.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | from datetime import datetime
3 | from platform import python_version
4 |
5 | from pyrogram import __version__, filters, Client
6 | from pyrogram.types import Message
7 | from config import ALIVE_PIC, ALIVE_TEXT
8 | from Zaid import START_TIME
9 | from Zaid import SUDO_USER
10 | from Zaid.helper.PyroHelpers import ReplyCheck
11 | from Zaid.modules.help import add_command_help
12 | from Zaid.modules.bot.inline import get_readable_time
13 |
14 | alive_logo = ALIVE_PIC or "https://telegra.ph/file/cc0890d0876bc18c19e05.jpg"
15 |
16 | if ALIVE_TEXT:
17 | txt = ALIVE_TEXT
18 | else:
19 | txt = (
20 | f"** ✘ zαι∂ υѕєявσт ✘**\n\n"
21 | f"❏ **νєяѕισи**: `2.1`\n"
22 | f"├• **υρтιмє**: `{str(datetime.now() - START_TIME).split('.')[0]}`\n"
23 | f"├• **ρутнσи**: `{python_version()}`\n"
24 | f"├• **ρуяσgяαм**: `{__version__}`\n"
25 | f"├• **ѕυρρσят**: [Click](t.me/TheSupportChat)\n"
26 | f"├• **¢нαииєℓ**: [Click](t.me/TheUpdatesChannel)\n"
27 | f"└• **яєρσ**: [Click](https://GitHub.com/itz-zaid/Zaid-Userbot)"
28 | )
29 |
30 | @Client.on_message(
31 | filters.command(["alive", "awake"], ".") & (filters.me | filters.user(SUDO_USER))
32 | )
33 | async def alive(client: Client, message: Message):
34 | xx = await message.reply_text("⚡️")
35 | try:
36 | await message.delete()
37 | except:
38 | pass
39 | send = client.send_video if alive_logo.endswith(".mp4") else client.send_photo
40 | xd = (f"{txt}")
41 | try:
42 | await asyncio.gather(
43 | xx.delete(),
44 | send(
45 | message.chat.id,
46 | alive_logo,
47 | caption=xd,
48 | reply_to_message_id=ReplyCheck(message),
49 | ),
50 | )
51 | except BaseException:
52 | await xx.edit(xd, disable_web_page_preview=True)
53 |
54 | @Client.on_message(filters.command("repo", ".") & filters.me)
55 | async def repo(bot: Client, message: Message):
56 | await message.edit("⚡")
57 | await asyncio.sleep(1)
58 | await message.edit("Fetching Source Code.....")
59 | await asyncio.sleep(1)
60 | await message.edit("Here is repo: \n\n\nhttps://github.com/itz-zaid/Zaid-UserBot\nFork & Give an ⭐")
61 |
62 |
63 | @Client.on_message(filters.command("creator", ".") & filters.me)
64 | async def creator(bot: Client, message: Message):
65 | await message.edit("https://gitHub.com/itz-zaid")
66 |
67 |
68 | @Client.on_message(filters.command(["uptime", "up"], ".") & filters.me)
69 | async def uptime(bot: Client, message: Message):
70 | now = datetime.now()
71 | current_uptime = now - START_TIME
72 | await message.edit(f"Uptime ⚡\n" f"```{str(current_uptime).split('.')[0]}```")
73 |
74 |
75 | @Client.on_message(filters.command("id", ".") & filters.me)
76 | async def get_id(bot: Client, message: Message):
77 | file_id = None
78 | user_id = None
79 |
80 | if message.reply_to_message:
81 | rep = message.reply_to_message
82 |
83 | if rep.audio:
84 | file_id = f"**File ID**: `{rep.audio.file_id}`"
85 | file_id += "**File Type**: `audio`"
86 |
87 | elif rep.document:
88 | file_id = f"**File ID**: `{rep.document.file_id}`"
89 | file_id += f"**File Type**: `{rep.document.mime_type}`"
90 |
91 | elif rep.photo:
92 | file_id = f"**File ID**: `{rep.photo.file_id}`"
93 | file_id += "**File Type**: `photo`"
94 |
95 | elif rep.sticker:
96 | file_id = f"**Sicker ID**: `{rep.sticker.file_id}`\n"
97 | if rep.sticker.set_name and rep.sticker.emoji:
98 | file_id += f"**Sticker Set**: `{rep.sticker.set_name}`\n"
99 | file_id += f"**Sticker Emoji**: `{rep.sticker.emoji}`\n"
100 | if rep.sticker.is_animated:
101 | file_id += f"**Animated Sticker**: `{rep.sticker.is_animated}`\n"
102 | else:
103 | file_id += "**Animated Sticker**: `False`\n"
104 | else:
105 | file_id += "**Sticker Set**: __None__\n"
106 | file_id += "**Sticker Emoji**: __None__"
107 |
108 | elif rep.video:
109 | file_id = f"**File ID**: `{rep.video.file_id}`\n"
110 | file_id += "**File Type**: `video`"
111 |
112 | elif rep.animation:
113 | file_id = f"**File ID**: `{rep.animation.file_id}`\n"
114 | file_id += "**File Type**: `GIF`"
115 |
116 | elif rep.voice:
117 | file_id = f"**File ID**: `{rep.voice.file_id}`\n"
118 | file_id += "**File Type**: `Voice Note`"
119 |
120 | elif rep.video_note:
121 | file_id = f"**File ID**: `{rep.animation.file_id}`\n"
122 | file_id += "**File Type**: `Video Note`"
123 |
124 | elif rep.location:
125 | file_id = "**Location**:\n"
126 | file_id += f"**longitude**: `{rep.location.longitude}`\n"
127 | file_id += f"**latitude**: `{rep.location.latitude}`"
128 |
129 | elif rep.venue:
130 | file_id = "**Location**:\n"
131 | file_id += f"**longitude**: `{rep.venue.location.longitude}`\n"
132 | file_id += f"**latitude**: `{rep.venue.location.latitude}`\n\n"
133 | file_id += "**Address**:\n"
134 | file_id += f"**title**: `{rep.venue.title}`\n"
135 | file_id += f"**detailed**: `{rep.venue.address}`\n\n"
136 |
137 | elif rep.from_user:
138 | user_id = rep.from_user.id
139 |
140 | if user_id:
141 | if rep.forward_from:
142 | user_detail = (
143 | f"**Forwarded User ID**: `{message.reply_to_message.forward_from.id}`\n"
144 | )
145 | else:
146 | user_detail = f"**User ID**: `{message.reply_to_message.from_user.id}`\n"
147 | user_detail += f"**Message ID**: `{message.reply_to_message.id}`"
148 | await message.edit(user_detail)
149 | elif file_id:
150 | if rep.forward_from:
151 | user_detail = (
152 | f"**Forwarded User ID**: `{message.reply_to_message.forward_from.id}`\n"
153 | )
154 | else:
155 | user_detail = f"**User ID**: `{message.reply_to_message.from_user.id}`\n"
156 | user_detail += f"**Message ID**: `{message.reply_to_message.id}`\n\n"
157 | user_detail += file_id
158 | await message.edit(user_detail)
159 |
160 | else:
161 | await message.edit(f"**Chat ID**: `{message.chat.id}`")
162 |
163 |
164 |
165 |
166 | add_command_help(
167 | "start",
168 | [
169 | [".alive", "Check if the bot is alive or not."],
170 | [".repo", "Display the repo of this userbot."],
171 | [".creator", "Show the creator of this userbot."],
172 | [".id", "Send id of what you replied to."],
173 | [".up `or` .uptime", "Check bot's current uptime."],
174 | ],
175 | )
176 |
177 | add_command_help(
178 | "restart",
179 | [
180 | [".restart", "You are retarded if you do not know what this does."],
181 | ],
182 | )
183 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/music.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from pyrogram import filters, Client
4 | from pyrogram.types import Message
5 |
6 | from Zaid import SUDO_USER
7 | from Zaid.helper.PyroHelpers import ReplyCheck
8 | from Zaid.modules.help import add_command_help
9 |
10 |
11 | @Client.on_message(
12 | filters.command(["m", "music"], ".") & (filters.me | filters.user(SUDO_USER))
13 | )
14 | async def send_music(bot: Client, message: Message):
15 | try:
16 | cmd = message.command
17 |
18 | song_name = ""
19 | if len(cmd) > 1:
20 | song_name = " ".join(cmd[1:])
21 | elif message.reply_to_message and len(cmd) == 1:
22 | song_name = (
23 | message.reply_to_message.text or message.reply_to_message.caption
24 | )
25 | elif not message.reply_to_message and len(cmd) == 1:
26 | await message.edit("Give a song name")
27 | await asyncio.sleep(2)
28 | await message.delete()
29 | return
30 |
31 | song_results = await bot.get_inline_bot_results("deezermusicbot", song_name)
32 |
33 | try:
34 | # send to Saved Messages because hide_via doesn't work sometimes
35 | saved = await bot.send_inline_bot_result(
36 | chat_id="me",
37 | query_id=song_results.query_id,
38 | result_id=song_results.results[0].id,
39 | )
40 |
41 | # forward as a new message from Saved Messages
42 | saved = await bot.get_messages("me", int(saved.updates[1].message.id))
43 | reply_to = (
44 | message.reply_to_message.id
45 | if message.reply_to_message
46 | else None
47 | )
48 | await bot.send_audio(
49 | chat_id=message.chat.id,
50 | audio=str(saved.audio.file_id),
51 | reply_to_message_id=ReplyCheck(message),
52 | )
53 |
54 | # delete the message from Saved Messages
55 | await bot.delete_messages("me", saved.id)
56 | except TimeoutError:
57 | await message.edit("That didn't work out")
58 | await asyncio.sleep(2)
59 | await message.delete()
60 | except Exception as e:
61 | print(e)
62 | await message.edit("`Failed to find song`")
63 | await asyncio.sleep(2)
64 | await message.delete()
65 |
66 |
67 | add_command_help("music", [[".m `or` .music", "Search songs and send."]])
68 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/nekobin.py:
--------------------------------------------------------------------------------
1 | from Zaid.modules.help import add_command_help
2 | import asyncio
3 | import requests
4 | import aiohttp
5 | from pyrogram import filters, Client
6 | from pyrogram.types import Message
7 |
8 | import os
9 | import re
10 |
11 | from pyrogram.types import Message
12 | from httpx import AsyncClient
13 | from Zaid.helper.utility import get_arg
14 |
15 |
16 | # Pastebins
17 | class PasteBins:
18 | def __init__(self) -> None:
19 | # API Urls
20 | self.nekobin_api = "https://nekobin.com/api/documents"
21 | self.spacebin_api = "https://spaceb.in/api/v1/documents"
22 | self.hastebin_api = "https://www.toptal.com/developers/hastebin/documents"
23 | # Paste Urls
24 | self.nekobin = "https://nekobin.com"
25 | self.spacebin = "https://spaceb.in"
26 | self.hastebin = "https://www.toptal.com/developers/hastebin"
27 |
28 | async def paste_text(self, paste_bin, text):
29 | if paste_bin == "spacebin":
30 | return await self.paste_to_spacebin(text)
31 | elif paste_bin == "hastebin":
32 | return await self.paste_to_hastebin(text)
33 | elif paste_bin == "nekobin":
34 | return await self.paste_to_nekobin(text)
35 | else:
36 | return "`Invalid pastebin service selected!`"
37 |
38 | async def __check_status(self, resp_status, status_code: int = 201):
39 | if int(resp_status) != status_code:
40 | return "real shit"
41 | else:
42 | return "ok"
43 |
44 | async def paste_to_nekobin(self, text):
45 | async with AsyncClient() as nekoc:
46 | resp = await nekoc.post(self.nekobin_api, json={"content": str(text)})
47 | chck = await self.__check_status(resp.status_code)
48 | if not chck == "ok":
49 | return None
50 | else:
51 | jsned = resp.json()
52 | return f"{self.nekobin}/{jsned['result']['key']}"
53 |
54 | async def paste_to_spacebin(self, text):
55 | async with AsyncClient() as spacbc:
56 | resp = await spacbc.post(self.spacebin_api, data={"content": str(text), "extension": "md"})
57 | chck = await self.__check_status(resp.status_code)
58 | if not chck == "ok":
59 | return None
60 | else:
61 | jsned = resp.json()
62 | return f"{self.spacebin}/{jsned['payload']['id']}"
63 |
64 | async def paste_to_hastebin(self, text):
65 | async with AsyncClient() as spacbc:
66 | resp = await spacbc.post(self.hastebin_api, data=str(text))
67 | chck = await self.__check_status(resp.status_code, 200)
68 | if not chck == "ok":
69 | return None
70 | else:
71 | jsned = resp.json()
72 | return f"{self.hastebin}/{jsned['key']}"
73 |
74 |
75 | async def get_pastebin_service(text: str):
76 | if re.search(r'\bhastebin\b', text):
77 | pastebin = "hastebin"
78 | elif re.search(r'\bspacebin\b', text):
79 | pastebin = "spacebin"
80 | elif re.search(r'\bnekobin\b', text):
81 | pastebin = "nekobin"
82 | else:
83 | pastebin = "spacebin"
84 | return pastebin
85 |
86 | @Client.on_message(filters.command(["paste", "nekobin", "hastebin", "spacebin"], ["."]) & filters.me)
87 | async def paste_dis_text(_, message: Message):
88 | pstbin_serv = await get_pastebin_service(message.text.split(" ")[0])
89 | paste_msg = await message.edit(f"`Pasting to {pstbin_serv.capitalize()}...`")
90 | replied_msg = message.reply_to_message
91 | tex_t = get_arg(message)
92 | message_s = tex_t
93 | if not tex_t:
94 | if not replied_msg:
95 | return await paste_msg.edit("`Reply To File or Send This Command With Text!`")
96 | if not replied_msg.text:
97 | file = await replied_msg.download()
98 | m_list = open(file, "r").read()
99 | message_s = m_list
100 | os.remove(file)
101 | elif replied_msg.text:
102 | message_s = replied_msg.text
103 | paste_cls = PasteBins()
104 | pasted = await paste_cls.paste_text(pstbin_serv, message_s)
105 | if not pasted:
106 | return await paste_msg.edit("`Oops, Pasting failed! Please try changing the pastebin service!`")
107 | await paste_msg.edit(f"**Pasted to {pstbin_serv.capitalize()}!** \n\n**Url:** {pasted}", disable_web_page_preview=True)
108 |
109 | add_command_help(
110 | "paste",
111 | [
112 | [
113 | ".paste `or` .nekobin `or` .hastebin `or` .spacebin",
114 | "To Paste Text to Hastebin / Nekobin or Spacebin \n\nCreate a Nekobin paste using replied to message.",
115 | ],
116 | ],
117 | )
118 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/pats.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | import aiohttp
4 | from pyrogram import filters, Client
5 | from pyrogram.types import Message
6 |
7 |
8 | from Zaid.helper.PyroHelpers import GetChatID, ReplyCheck
9 | from Zaid.modules.help import add_command_help
10 |
11 |
12 | @Client.on_message(filters.command(["pat", "pats"], ".") & filters.me)
13 | async def give_pats(bot: Client, message: Message):
14 | URL = "https://some-random-api.ml/animu/pat"
15 | async with aiohttp.ClientSession() as session:
16 | async with session.get(URL) as request:
17 | if request.status == 404:
18 | return await message.edit("`no Pats for you :c")
19 | result = await request.json()
20 | url = result.get("link", None)
21 | await asyncio.gather(
22 | message.delete(),
23 | bot.send_video(
24 | GetChatID(message), url, reply_to_message_id=ReplyCheck(message)
25 | ),
26 | )
27 |
28 |
29 | add_command_help(
30 | "pats",
31 | [
32 | [".pat | .pats", "Give pats."],
33 | ],
34 | )
35 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/ping.py:
--------------------------------------------------------------------------------
1 | import time
2 | from datetime import datetime
3 |
4 | import speedtest
5 | from pyrogram import Client, filters
6 | from pyrogram.raw import functions
7 | from pyrogram.types import Message
8 |
9 | from Zaid import StartTime, app, SUDO_USER
10 | from Zaid.helper.PyroHelpers import SpeedConvert
11 | from Zaid.modules.bot.inline import get_readable_time
12 |
13 | from Zaid.modules.help import add_command_help
14 |
15 | class WWW:
16 | SpeedTest = (
17 | "Speedtest started at `{start}`\n\n"
18 | "Ping:\n{ping} ms\n\n"
19 | "Download:\n{download}\n\n"
20 | "Upload:\n{upload}\n\n"
21 | "ISP:\n__{isp}__"
22 | )
23 |
24 | NearestDC = "Country: `{}`\n" "Nearest Datacenter: `{}`\n" "This Datacenter: `{}`"
25 |
26 | @Client.on_message(
27 | filters.command(["speedtest"], ".") & (filters.me | filters.user(SUDO_USER))
28 | )
29 | async def speed_test(client: Client, message: Message):
30 | new_msg = await message.reply_text("`Running speed test . . .`")
31 | try:
32 | await message.delete()
33 | except:
34 | pass
35 | spd = speedtest.Speedtest()
36 |
37 | new_msg = await new_msg.edit(
38 | f"`{new_msg.text}`\n" "`Getting best server based on ping . . .`"
39 | )
40 | spd.get_best_server()
41 |
42 | new_msg = await new_msg.edit(f"`{new_msg.text}`\n" "`Testing download speed . . .`")
43 | spd.download()
44 |
45 | new_msg = await new_msg.edit(f"`{new_msg.text}`\n" "`Testing upload speed . . .`")
46 | spd.upload()
47 |
48 | new_msg = await new_msg.edit(
49 | f"`{new_msg.text}`\n" "`Getting results and preparing formatting . . .`"
50 | )
51 | results = spd.results.dict()
52 |
53 | await new_msg.edit(
54 | WWW.SpeedTest.format(
55 | start=results["timestamp"],
56 | ping=results["ping"],
57 | download=SpeedConvert(results["download"]),
58 | upload=SpeedConvert(results["upload"]),
59 | isp=results["client"]["isp"],
60 | )
61 | )
62 |
63 |
64 |
65 | @Client.on_message(
66 | filters.command(["ping"], ".") & (filters.me | filters.user(SUDO_USER))
67 | )
68 | async def pingme(client: Client, message: Message):
69 | uptime = await get_readable_time((time.time() - StartTime))
70 | start = datetime.now()
71 | xx = await message.reply_text("**0% ▒▒▒▒▒▒▒▒▒▒**")
72 | try:
73 | await message.delete()
74 | except:
75 | pass
76 | await xx.edit("**20% ██▒▒▒▒▒▒▒▒**")
77 | await xx.edit("**40% ████▒▒▒▒▒▒**")
78 | await xx.edit("**60% ██████▒▒▒▒**")
79 | await xx.edit("**80% ████████▒▒**")
80 | await xx.edit("**100% ██████████**")
81 | end = datetime.now()
82 | duration = (end - start).microseconds / 1000
83 | await xx.edit(
84 | f"❏ **╰☞ 𝗣𝗢𝗡𝗚™╮**\n"
85 | f"├• **╰☞** - `%sms`\n"
86 | f"├• **╰☞ -** `{uptime}` \n"
87 | f"└• **╰☞:** {client.me.mention}" % (duration)
88 | )
89 |
90 |
91 | add_command_help(
92 | "ping",
93 | [
94 | ["ping", "Check bot alive or not."],
95 | ],
96 | )
97 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/profile.py:
--------------------------------------------------------------------------------
1 | import os
2 | from asyncio import sleep
3 | import os
4 | import sys
5 | from re import sub
6 | from time import time
7 |
8 |
9 | from pyrogram import Client, filters, enums
10 | from pyrogram.types import Message
11 |
12 | from Zaid import SUDO_USER
13 | from Zaid.helper.PyroHelpers import ReplyCheck
14 |
15 | from Zaid.modules.help import add_command_help
16 |
17 | flood = {}
18 | profile_photo = "cache/pfp.jpg"
19 |
20 |
21 | async def extract_userid(message, text: str):
22 | def is_int(text: str):
23 | try:
24 | int(text)
25 | except ValueError:
26 | return False
27 | return True
28 |
29 | text = text.strip()
30 |
31 | if is_int(text):
32 | return int(text)
33 |
34 | entities = message.entities
35 | app = message._client
36 | if len(entities) < 2:
37 | return (await app.get_users(text)).id
38 | entity = entities[1]
39 | if entity.type == "mention":
40 | return (await app.get_users(text)).id
41 | if entity.type == "text_mention":
42 | return entity.user.id
43 | return None
44 |
45 |
46 | async def extract_user_and_reason(message, sender_chat=False):
47 | args = message.text.strip().split()
48 | text = message.text
49 | user = None
50 | reason = None
51 | if message.reply_to_message:
52 | reply = message.reply_to_message
53 | if not reply.from_user:
54 | if (
55 | reply.sender_chat
56 | and reply.sender_chat != message.chat.id
57 | and sender_chat
58 | ):
59 | id_ = reply.sender_chat.id
60 | else:
61 | return None, None
62 | else:
63 | id_ = reply.from_user.id
64 |
65 | if len(args) < 2:
66 | reason = None
67 | else:
68 | reason = text.split(None, 1)[1]
69 | return id_, reason
70 |
71 | if len(args) == 2:
72 | user = text.split(None, 1)[1]
73 | return await extract_userid(message, user), None
74 |
75 | if len(args) > 2:
76 | user, reason = text.split(None, 2)[1:]
77 | return await extract_userid(message, user), reason
78 |
79 | return user, reason
80 |
81 |
82 | async def extract_user(message):
83 | return (await extract_user_and_reason(message))[0]
84 |
85 | @Client.on_message(
86 | filters.command(["unblock"], ".") & (filters.me | filters.user(SUDO_USER))
87 | )
88 | async def unblock_user_func(client: Client, message: Message):
89 | user_id = await extract_user(message)
90 | tex = await message.reply_text("`Processing . . .`")
91 | if not user_id:
92 | return await message.edit(
93 | "Provide User ID/Username or reply to user message to unblock."
94 | )
95 | if user_id == client.me.id:
96 | return await tex.edit("Ohk done ✅.")
97 | await client.unblock_user(user_id)
98 | umention = (await client.get_users(user_id)).mention
99 | await message.edit(f"**Successfully Unblocked** {umention}")
100 |
101 | @Client.on_message(
102 | filters.command(["block"], ".") & (filters.me | filters.user(SUDO_USER))
103 | )
104 | async def block_user_func(client: Client, message: Message):
105 | user_id = await extract_user(message)
106 | tex = await message.reply_text("`Processing . . .`")
107 | if not user_id:
108 | return await tex.edit_text(
109 | "Provide User ID/Username or reply to user message to block."
110 | )
111 | if user_id == client.me.id:
112 | return await tex.edit_text("ohk ✅.")
113 | await client.block_user(user_id)
114 | umention = (await client.get_users(user_id)).mention
115 | await tex.edit_text(f"**Successfully blocked** {umention}")
116 |
117 |
118 | @Client.on_message(
119 | filters.command(["setname"], ".") & (filters.me | filters.user(SUDO_USER))
120 | )
121 | async def setname(client: Client, message: Message):
122 | tex = await message.reply_text("`Processing . . .`")
123 | if len(message.command) == 1:
124 | return await tex.edit(
125 | "Provide a text to set as your name."
126 | )
127 | elif len(message.command) > 1:
128 | name = message.text.split(None, 1)[1]
129 | try:
130 | await client.update_profile(first_name=name)
131 | await tex.edit(f"**Successfully Changed Your Name To** `{name}`")
132 | except Exception as e:
133 | await tex.edit(f"**ERROR:** `{e}`")
134 | else:
135 | return await tex.edit(
136 | "Provide a text to set as your name."
137 | )
138 |
139 | @Client.on_message(
140 | filters.command(["setbio"], ".") & (filters.me | filters.user(SUDO_USER))
141 | )
142 | async def set_bio(client: Client, message: Message):
143 | tex = await message.edit_text("`Processing . . .`")
144 | if len(message.command) == 1:
145 | return await tex.edit("Provide text to set as bio.")
146 | elif len(message.command) > 1:
147 | bio = message.text.split(None, 1)[1]
148 | try:
149 | await client.update_profile(bio=bio)
150 | await tex.edit(f"**Successfully Change your BIO to** `{bio}`")
151 | except Exception as e:
152 | await tex.edit(f"**ERROR:** `{e}`")
153 | else:
154 | return await tex.edit("Provide text to set as bio.")
155 |
156 |
157 | @Client.on_message(
158 | filters.command(["setpfp"], ".") & (filters.me | filters.user(SUDO_USER))
159 | )
160 | async def set_pfp(client: Client, message: Message):
161 | replied = message.reply_to_message
162 | if (
163 | replied
164 | and replied.media
165 | and (
166 | replied.photo
167 | or (replied.document and "image" in replied.document.mime_type)
168 | )
169 | ):
170 | await client.download_media(message=replied, file_name=profile_photo)
171 | await client.set_profile_photo(profile_photo)
172 | if os.path.exists(profile_photo):
173 | os.remove(profile_photo)
174 | await message.reply_text("**Your Profile Photo Changed Successfully.**")
175 | else:
176 | await message.reply_text(
177 | "Reply to any photo to set as profile photo"
178 | )
179 | await sleep(3)
180 | await message.delete()
181 |
182 |
183 | @Client.on_message(
184 | filters.command(["vpfp"], ".") & (filters.me | filters.user(SUDO_USER))
185 | )
186 | async def view_pfp(client: Client, message: Message):
187 | user_id = await extract_user(message)
188 | if user_id:
189 | user = await client.get_users(user_id)
190 | else:
191 | user = await client.get_me()
192 | if not user.photo:
193 | await message.reply_text("Profile photo not found!")
194 | return
195 | await client.download_media(user.photo.big_file_id, file_name=profile_photo)
196 | await client.send_photo(
197 | message.chat.id, profile_photo, reply_to_message_id=ReplyCheck(message)
198 | )
199 | await message.delete()
200 | if os.path.exists(profile_photo):
201 | os.remove(profile_photo)
202 |
203 |
204 | add_command_help(
205 | "profile",
206 | [
207 | ["block", "to block someone on telegram"],
208 | ["unblock", "to unblock someone on telegram"],
209 | ["setname", "set your profile name."],
210 | ["setbio", "set an bio."],
211 | [
212 | "setpfp",
213 | f"reply with image to set your profile pic.",
214 | ],
215 | ["vpfp", "Reply with video to set your video profile."],
216 | ],
217 | )
218 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/purge.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from pyrogram import Client, filters
4 | from pyrogram.types import Message
5 |
6 | from Zaid.modules.help import add_command_help
7 |
8 |
9 | @Client.on_message(filters.command("del", ".") & filters.me)
10 | async def del_msg(client: Client, message: Message):
11 | msg_src = message.reply_to_message
12 | if msg_src:
13 | if msg_src.from_user.id:
14 | try:
15 | await client.delete_messages(message.chat.id, msg_src.id)
16 | await message.delete()
17 | except BaseException:
18 | pass
19 | else:
20 | await message.delete()
21 |
22 |
23 |
24 | @Client.on_message(filters.command("purge", ".") & filters.me)
25 | async def purge(client: Client, message: Message):
26 | ex = await message.edit_text("`Starting To Purge Messages!`")
27 | msg = message.reply_to_message
28 | if msg:
29 | itermsg = list(range(msg.id, message.id))
30 | else:
31 | await ex.edit("`Reply To Message To Purge!`")
32 | return
33 | count = 0
34 |
35 | for i in itermsg:
36 | try:
37 | count = count + 1
38 | await client.delete_messages(
39 | chat_id=message.chat.id, message_ids=i, revoke=True
40 | )
41 | except FloodWait as e:
42 | await asyncio.sleep(e.x)
43 | except Exception as e:
44 | await ex.edit(f"**ERROR:** `{e}`")
45 | return
46 |
47 | done = await ex.edit(
48 | f"**Fast Purge Completed!**\n**Successfully Delete** `{str(count)}` **Message.**"
49 | )
50 | await asyncio.sleep(2)
51 | await done.delete()
52 |
53 |
54 |
55 | @Client.on_message(filters.command("purgeme", ".") & filters.me)
56 | async def purgeme(client: Client, message: Message):
57 | if len(message.command) != 2:
58 | return await message.delete()
59 | n = message.text.split(None, 1)[1].strip()
60 | if not n.isnumeric():
61 | return await message.edit_text("Please enter a number")
62 | n = int(n)
63 | if n < 1:
64 | return await message.edit_text("Enter the number of messages you want to delete!")
65 | chat_id = message.chat.id
66 | message_ids = [
67 | m.id
68 | async for m in client.search_messages(
69 | chat_id,
70 | from_user="me",
71 | limit=n,
72 | )
73 | ]
74 | if not message_ids:
75 | return await message.edit_text("Could not find message.")
76 | to_delete = [message_ids[i : i + 99] for i in range(0, len(message_ids), 99)]
77 | for hundred_messages_or_less in to_delete:
78 | await client.delete_messages(
79 | chat_id=chat_id,
80 | message_ids=hundred_messages_or_less,
81 | revoke=True,
82 | )
83 | await message.delete()
84 |
85 |
86 | add_command_help(
87 | "purge",
88 | [
89 | ["del", "to delete someone's message."],
90 | ["purge", "reply to all messages from your replied."],
91 | ["purgeme [count]", "to delete your messages only."],
92 | ],
93 | )
94 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/quote.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from pyrogram import Client, filters
4 | from pyrogram.types import Message
5 |
6 | from Zaid.helper.utility import get_arg
7 |
8 | from Zaid.modules.help import add_command_help
9 |
10 |
11 | @Client.on_message(filters.me & filters.command(["q", "quotly"], "."))
12 | async def quotly(client: Client, message: Message):
13 | args = get_arg(message)
14 | if not message.reply_to_message and not args:
15 | return await message.edit("**Please Reply to Message**")
16 | bot = "QuotLyBot"
17 | if message.reply_to_message:
18 | await message.edit("`Making a Quote . . .`")
19 | await client.unblock_user(bot)
20 | if args:
21 | await client.send_message(bot, f"/qcolor {args}")
22 | await asyncio.sleep(1)
23 | else:
24 | pass
25 | await message.reply_to_message.forward(bot)
26 | await asyncio.sleep(5)
27 | async for quotly in client.search_messages(bot, limit=1):
28 | if quotly:
29 | await message.delete()
30 | await message.reply_sticker(
31 | sticker=quotly.sticker.file_id,
32 | reply_to_message_id=message.reply_to_message.id
33 | if message.reply_to_message
34 | else None,
35 | )
36 | else:
37 | return await message.edit("**Failed to Create Quotly Sticker**")
38 |
39 |
40 | add_command_help(
41 | "quotly",
42 | [
43 | [
44 | f"q or .quotly",
45 | "To make an quote.",
46 | ],
47 | [
48 | f"q {message.text}
"
28 | await asyncio.sleep(0.5)
29 | await client.send_message(
30 | LOG_GROUP,
31 | result,
32 | parse_mode=enums.ParseMode.HTML,
33 | disable_web_page_preview=True,
34 | )
35 |
36 |
37 | add_command_help(
38 | "tagalert",
39 | [
40 | [
41 | "tagalert on/off",
42 | "To activate or deactivate the group tag, which will go to the log group.",
43 | ],
44 | ],
45 | )
46 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/tagall.py:
--------------------------------------------------------------------------------
1 | from asyncio import sleep
2 |
3 | from pyrogram import Client, filters
4 | from pyrogram.types import Message
5 |
6 |
7 | from Zaid.modules.help import add_command_help
8 |
9 | spam_chats = []
10 |
11 |
12 | def get_arg(message: Message):
13 | msg = message.text
14 | msg = msg.replace(" ", "", 1) if msg[1] == " " else msg
15 | split = msg[1:].replace("\n", " \n").split(" ")
16 | if " ".join(split[1:]).strip() == "":
17 | return ""
18 | return " ".join(split[1:])
19 |
20 | @Client.on_message(filters.command("tagall", ".") & filters.me)
21 | async def mentionall(client: Client, message: Message):
22 | chat_id = message.chat.id
23 | direp = message.reply_to_message
24 | args = get_arg(message)
25 | if not direp and not args:
26 | return await message.edit("**Send me a message or reply to a message!**")
27 | await message.delete()
28 | spam_chats.append(chat_id)
29 | usrnum = 0
30 | usrtxt = ""
31 | async for usr in client.get_chat_members(chat_id):
32 | if not chat_id in spam_chats:
33 | break
34 | usrnum += 1
35 | usrtxt += f"[{usr.user.first_name}](tg://user?id={usr.user.id}), "
36 | if usrnum == 5:
37 | if args:
38 | txt = f"{args}\n\n{usrtxt}"
39 | await client.send_message(chat_id, txt)
40 | elif direp:
41 | await direp.reply(usrtxt)
42 | await sleep(2)
43 | usrnum = 0
44 | usrtxt = ""
45 | try:
46 | spam_chats.remove(chat_id)
47 | except:
48 | pass
49 |
50 |
51 | @Client.on_message(filters.command("cancel", ".") & filters.me)
52 | async def cancel_spam(client: Client, message: Message):
53 | if not message.chat.id in spam_chats:
54 | return await message.edit("**It seems there is no tagall here.**")
55 | else:
56 | try:
57 | spam_chats.remove(message.chat.id)
58 | except:
59 | pass
60 | return await message.edit("**Cancelled.**")
61 |
62 |
63 | add_command_help(
64 | "tagall",
65 | [
66 | [
67 | "tagall [text/reply ke chat]",
68 | "Tag all the members one by one",
69 | ],
70 | [
71 | "cancel",
72 | f"to stop .tagall",
73 | ],
74 | ],
75 | )
76 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/telegraph.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client, filters
2 | from pyrogram.types import Message
3 | from telegraph import Telegraph, exceptions, upload_file
4 | import os
5 |
6 |
7 | from Zaid.modules.help import *
8 |
9 | telegraph = Telegraph()
10 | r = telegraph.create_account(short_name="telegram")
11 | auth_url = r["auth_url"]
12 |
13 |
14 |
15 | def get_text(message: Message) -> [None, str]:
16 | """Extract Text From Commands"""
17 | text_to_return = message.text
18 | if message.text is None:
19 | return None
20 | if " " in text_to_return:
21 | try:
22 | return message.text.split(None, 1)[1]
23 | except IndexError:
24 | return None
25 | else:
26 | return None
27 |
28 | @Client.on_message(filters.command(["tg", "telegraph", "tm", "tgt"], ".") & filters.me)
29 | async def uptotelegraph(client: Client, message: Message):
30 | tex = await message.edit_text("`Processing . . .`")
31 | if not message.reply_to_message:
32 | await tex.edit(
33 | "**Reply to an Image or text.**"
34 | )
35 | return
36 | if message.reply_to_message.media:
37 | if message.reply_to_message.sticker:
38 | m_d = await convert_to_image(message, client)
39 | else:
40 | m_d = await message.reply_to_message.download()
41 | try:
42 | media_url = upload_file(m_d)
43 | except exceptions.TelegraphException as exc:
44 | await tex.edit(f"**ERROR:** `{exc}`")
45 | os.remove(m_d)
46 | return
47 | U_done = (
48 | f"**Uploaded on ** [Telegraph](https://telegra.ph/{media_url[0]})"
49 | )
50 | await tex.edit(U_done)
51 | os.remove(m_d)
52 | elif message.reply_to_message.text:
53 | page_title = get_text(message) if get_text(message) else client.me.first_name
54 | page_text = message.reply_to_message.text
55 | page_text = page_text.replace("\n", "{escape(data.replace('report', 'Report'))}
"
33 | await message.edit(weather, parse_mode=enums.ParseMode.MARKDOWN)
34 |
35 |
36 | add_command_help(
37 | "weather",
38 | [
39 | [".weather", "Gets weather information for provided location."],
40 | ],
41 | )
42 |
--------------------------------------------------------------------------------
/Zaid/modules/basic/whois.py:
--------------------------------------------------------------------------------
1 | from asyncio import gather
2 | from os import remove
3 |
4 | from pyrogram import Client, filters
5 | from pyrogram.enums import ChatType
6 | from pyrogram.types import Message
7 |
8 | from Zaid.helper.PyroHelpers import ReplyCheck
9 | from Zaid.modules.basic.profile import extract_user
10 |
11 | from Zaid.modules.help import add_command_help
12 |
13 |
14 | @Client.on_message(filters.command(["whois", "info"], ".") & filters.me)
15 | async def who_is(client: Client, message: Message):
16 | user_id = await extract_user(message)
17 | ex = await message.edit_text("`Processing . . .`")
18 | if not user_id:
19 | return await ex.edit(
20 | "**Provide userid/username/reply to get that user's info.**"
21 | )
22 | try:
23 | user = await client.get_users(user_id)
24 | username = f"@{user.username}" if user.username else "-"
25 | first_name = f"{user.first_name}" if user.first_name else "-"
26 | last_name = f"{user.last_name}" if user.last_name else "-"
27 | fullname = (
28 | f"{user.first_name} {user.last_name}" if user.last_name else user.first_name
29 | )
30 | user_details = (await client.get_chat(user.id)).bio
31 | bio = f"{user_details}" if user_details else "-"
32 | h = f"{user.status}"
33 | if h.startswith("UserStatus"):
34 | y = h.replace("UserStatus.", "")
35 | status = y.capitalize()
36 | else:
37 | status = "-"
38 | dc_id = f"{user.dc_id}" if user.dc_id else "-"
39 | common = await client.get_common_chats(user.id)
40 | out_str = f"""USER INFORMATION:
41 |
42 | 🆔 User ID: {user.id}
43 | 👤 First Name: {first_name}
44 | 🗣️ Last Name: {last_name}
45 | 🌐 Username: {username}
46 | 🏛️ DC ID: {dc_id}
47 | 🤖 Is Bot: {user.is_bot}
48 | 🚷 Is Scam: {user.is_scam}
49 | 🚫 Restricted: {user.is_restricted}
50 | ✅ Verified: {user.is_verified}
51 | ⭐ Premium: {user.is_premium}
52 | 📝 User Bio: {bio}
53 |
54 | 👀 Same groups seen: {len(common)}
55 | 👁️ Last Seen: {status}
56 | 🔗 User permanent link: {fullname}
57 | """
58 | photo_id = user.photo.big_file_id if user.photo else None
59 | if photo_id:
60 | photo = await client.download_media(photo_id)
61 | await gather(
62 | ex.delete(),
63 | client.send_photo(
64 | message.chat.id,
65 | photo,
66 | caption=out_str,
67 | reply_to_message_id=ReplyCheck(message),
68 | ),
69 | )
70 | remove(photo)
71 | else:
72 | await ex.edit(out_str, disable_web_page_preview=True)
73 | except Exception as e:
74 | return await ex.edit(f"**INFO:** `{e}`")
75 |
76 |
77 | @Client.on_message(filters.command(["chatinfo", "cinfo", "ginfo"], ".") & filters.me)
78 | async def chatinfo_handler(client: Client, message: Message):
79 | ex = await message.edit_text("`Processing...`")
80 | try:
81 | if len(message.command) > 1:
82 | chat_u = message.command[1]
83 | chat = await client.get_chat(chat_u)
84 | else:
85 | if message.chat.type == ChatType.PRIVATE:
86 | return await message.edit(
87 | f"Use this command within a group or use .chatinfo [group username or id]`"
88 | )
89 | else:
90 | chatid = message.chat.id
91 | chat = await client.get_chat(chatid)
92 | h = f"{chat.type}"
93 | if h.startswith("ChatType"):
94 | y = h.replace("ChatType.", "")
95 | type = y.capitalize()
96 | else:
97 | type = "Private"
98 | username = f"@{chat.username}" if chat.username else "-"
99 | description = f"{chat.description}" if chat.description else "-"
100 | dc_id = f"{chat.dc_id}" if chat.dc_id else "-"
101 | out_str = f"""CHAT INFORMATION:
102 |
103 | 🆔 Chat ID: {chat.id}
104 | 👥 Title: {chat.title}
105 | 👥 Username: {username}
106 | 📩 Type: {type}
107 | 🏛️ DC ID: {dc_id}
108 | 🗣️ Is Scam: {chat.is_scam}
109 | 🎭 Is Fake: {chat.is_fake}
110 | ✅ Verified: {chat.is_verified}
111 | 🚫 Restricted: {chat.is_restricted}
112 | 🔰 Protected: {chat.has_protected_content}
113 |
114 | 🚻 Total members: {chat.members_count}
115 | 📝 Description:
116 | {description}
117 | """
118 | photo_id = chat.photo.big_file_id if chat.photo else None
119 | if photo_id:
120 | photo = await client.download_media(photo_id)
121 | await gather(
122 | ex.delete(),
123 | client.send_photo(
124 | message.chat.id,
125 | photo,
126 | caption=out_str,
127 | reply_to_message_id=ReplyCheck(message),
128 | ),
129 | )
130 | remove(photo)
131 | else:
132 | await ex.edit(out_str, disable_web_page_preview=True)
133 | except Exception as e:
134 | return await ex.edit(f"**INFO:** `{e}`")
135 |
136 |
137 | add_command_help(
138 | "info",
139 | [
140 | [
141 | "info {len(CMD_HELP)} Modules
57 | • Python Version : {pyver.split()[0]}
58 | • Pyrogram Version : {pyrover}
59 | • Bot Uptime : {uptime}
60 |
61 | — Bot version: 2.0
62 | """
63 | answers.append(
64 | InlineQueryResultArticle(
65 | title="Alive",
66 | description="Check Bot's Stats",
67 | thumb_url="https://telegra.ph/file/cc0890d0876bc18c19e05.jpg",
68 | input_message_content=InputTextMessageContent(
69 | msg, parse_mode=ParseMode.HTML, disable_web_page_preview=True
70 | ),
71 | reply_markup=InlineKeyboardMarkup(
72 | [[InlineKeyboardButton("──「 ʜᴇʟᴘ 」──", callback_data="helper")]]
73 | ),
74 | )
75 | )
76 | return answers
77 |
78 |
79 | async def help_function(answers):
80 | bttn = paginate_help(0, CMD_HELP, "helpme")
81 | answers.append(
82 | InlineQueryResultArticle(
83 | title="Help Article!",
84 | description="Check Command List & Help",
85 | thumb_url="https://telegra.ph/file/cc0890d0876bc18c19e05.jpg",
86 | input_message_content=InputTextMessageContent(
87 | Data.text_help_menu.format(len(CMD_HELP))
88 | ),
89 | reply_markup=InlineKeyboardMarkup(bttn),
90 | )
91 | )
92 | return answers
93 |
94 |
95 | @app.on_inline_query()
96 | @inline_wrapper
97 | async def inline_query_handler(client: Client, query):
98 | try:
99 | text = query.query.strip().lower()
100 | string_given = query.query.lower()
101 | answers = []
102 | if text.strip() == "":
103 | return
104 | elif text.split()[0] == "alive":
105 | answerss = await alive_function(query, answers)
106 | await client.answer_inline_query(query.id, results=answerss, cache_time=10)
107 | elif string_given.startswith("helper"):
108 | answers = await help_function(answers)
109 | await client.answer_inline_query(query.id, results=answers, cache_time=0)
110 | except Exception as e:
111 | e = traceback.format_exc()
112 | print(e, "InLine")
113 |
--------------------------------------------------------------------------------
/Zaid/modules/bot/start.py:
--------------------------------------------------------------------------------
1 | from Zaid import app, API_ID, API_HASH
2 | from config import OWNER_ID, ALIVE_PIC
3 | from pyrogram import filters
4 | import os
5 | import re
6 | import asyncio
7 | import time
8 | from pyrogram import *
9 | from pyrogram.types import *
10 |
11 | PHONE_NUMBER_TEXT = (
12 | "✘ Heya My Master👋!\n\n✘ I'm Your Assistant?\n\n‣ I can help you to host Your Left Clients.\n\n‣ Repo: github.com/Itz-Zaid/Zaid-Userbot \n\n‣ This specially for Buzzy People's(lazy)\n\n‣ Now /clone {send your PyroGram String Session}"
13 | )
14 |
15 | @app.on_message(filters.user(OWNER_ID) & filters.command("start"))
16 | async def hello(client: app, message):
17 | buttons = [
18 | [
19 | InlineKeyboardButton("✘ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ", url="t.me/TheUpdatesChannel"),
20 | ],
21 | [
22 | InlineKeyboardButton("✘ ꜱᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ", url="t.me/TheSupportChat"),
23 | ],
24 | ]
25 | reply_markup = InlineKeyboardMarkup(buttons)
26 | await client.send_photo(message.chat.id, ALIVE_PIC, caption=PHONE_NUMBER_TEXT, reply_markup=reply_markup)
27 |
28 | # © By Itz-Zaid Your motherfucker if uh Don't gives credits.
29 | @app.on_message(filters.user(OWNER_ID) & filters.command("clone"))
30 | async def clone(bot: app, msg: Message):
31 | chat = msg.chat
32 | text = await msg.reply("Usage:\n\n /clone session")
33 | cmd = msg.command
34 | phone = msg.command[1]
35 | try:
36 | await text.edit("Booting Your Client")
37 | # change this Directry according to ur repo
38 | client = Client(name="Melody", api_id=API_ID, api_hash=API_HASH, session_string=phone, plugins=dict(root="Zaid/modules"))
39 | await client.start()
40 | user = await client.get_me()
41 | await msg.reply(f"Your Client Has Been Successfully As {user.first_name} ✅.")
42 | except Exception as e:
43 | await msg.reply(f"**ERROR:** `{str(e)}`\nPress /start to Start again.")
44 |
--------------------------------------------------------------------------------
/Zaid/modules/cctools/scraper.py:
--------------------------------------------------------------------------------
1 | from os import remove
2 | from re import findall
3 |
4 | from pyrogram import Client, filters
5 |
6 | from Zaid import SUDO_USER
7 |
8 |
9 | _SCRTXT = """
10 | **✅ CC Scrapped Successfully!**
11 |
12 | **Source ->** {}
13 | **Amount ->** {}
14 | **Skipped ->** {}
15 | **Cc Found ->** {}
16 |
17 |
18 | 🥷 **Scrapped By ->** {}
19 | 👨🎤 **Developed By ->** @TheUpdatesChannel 🐲
20 | """
21 |
22 |
23 | @Client.on_message(
24 | filters.command(["scrape"], ".") & (filters.me | filters.user(SUDO_USER))
25 | )
26 | async def cc_scraper(c, m):
27 | txt = ""
28 | skp = 0
29 | spl = m.text.split(" ")
30 | e3 = await m.reply_text("...", quote=True)
31 | if not spl:
32 | return await e3.edit("full cmd de vai.. 😔")
33 | elif len(spl) == 2:
34 | _chat = spl[1].strip()
35 | limit = 100
36 | elif len(spl) > 2:
37 | _chat = spl[1].strip()
38 | try:
39 | limit = int(spl[2].strip())
40 | except ValueError:
41 | return await e3.edit("No. of card to Scrape must be Integer!")
42 |
43 | await e3.edit(f"`Scrapping from {_chat}. \nHold your Horses...`")
44 | _get = lambda m: getattr(m, "text", 0) or getattr(m, "caption", 0)
45 | _getcc = lambda m: list(filter(bool, findall("\d{16}\|\d{2,4}\|\d{2,4}\|\d{2,4}", m)))
46 |
47 | async for x in c.get_chat_history(_chat, limit=limit):
48 | if not (text := _get(x)):
49 | skp += 1
50 | continue
51 | if not (cc := _getcc(text)):
52 | skp += 1
53 | else:
54 | txt += "\n".join(cc) + "\n"
55 |
56 | cap = _SCRTXT.format(
57 | _chat,
58 | str(limit),
59 | str(skp),
60 | str(txt.count("\n")),
61 | m.from_user.mention,
62 | )
63 | file = f"x{limit} CC Scrapped by ZaidUB.txt"
64 | with open(file, "w+") as f:
65 | f.write(txt)
66 | del txt
67 | y = await c.send_document(
68 | m.chat.id,
69 | file,
70 | caption=cap,
71 | reply_to_message_id=m.id,
72 | )
73 | remove(file)
74 | await e3.delete()
75 |
--------------------------------------------------------------------------------
/Zaid/modules/fun/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Zaid/modules/fun/autopic.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | from datetime import datetime
3 | from pathlib import Path
4 | from random import choice
5 | from shutil import copyfile
6 |
7 | from PIL import Image, ImageDraw, ImageFont
8 | from pyrogram import filters, Client
9 |
10 | from Zaid import SUDO_USER
11 | from Zaid.helper.basic import eor
12 | from Zaid.modules.help import add_command_help
13 |
14 |
15 | __XOR = []
16 | FIRST_TIME = True
17 | DIM = [(100, 200), (1280, 200), (1280, 1600), (100, 1600)]
18 |
19 |
20 | async def _autopic(_, delay):
21 | global FIRST_TIME
22 |
23 | while bool(__XOR):
24 | await asyncio.sleep(delay)
25 | original = "cache/autopic-template.jpg"
26 | photo = "pic.png"
27 | copyfile(original, photo)
28 | current_time = datetime.now().strftime(
29 | f'%H:%M %d-%m-%y\nLife Is too short\nto argue.\njust say "fuck off"\nand move on.'
30 | )
31 | img = Image.open(photo)
32 | drawn_text = ImageDraw.Draw(img)
33 | fnt = ImageFont.truetype("cache/autopic-font-ubuntu.ttf", 60)
34 | drawn_text.text(choice(DIM), current_time, font=fnt, fill=(0, 0, 0))
35 | img.save(photo)
36 | try:
37 | if not FIRST_TIME:
38 | async for pic in _.get_chat_photos("me", limit=1):
39 | await _.delete_profile_photos(pic.file_id)
40 | await asyncio.sleep(2)
41 | await _.set_profile_photo(photo=photo)
42 | FIRST_TIME = False
43 | except Exception as exc:
44 | print("Autopic Error: " + exc)
45 | finally:
46 | Path(photo).unlink()
47 |
48 |
49 | @Client.on_message(
50 | filters.command(["autopic"], ".") & (filters.me | filters.user(SUDO_USER))
51 | )
52 | async def autopic_zaid(_, m):
53 | global __XOR
54 | arc = await eor(m, "...")
55 | if bool(__XOR):
56 | __XOR[0].cancel()
57 | t = "`Autopic Stopped Successfully.`"
58 | __XOR.clear()
59 | else:
60 | _task = _autopic(_, delay=300)
61 | task = asyncio.create_task(_task)
62 | __XOR.append(task)
63 | t = "`Started Autopic.`"
64 | await arc.edit_text(t)
65 |
66 |
67 | add_command_help(
68 | "Autopic",
69 | [[".autopic", "Change your DP every 5 minute. \nRun .autopic again to stop it."]],
70 | )
71 |
--------------------------------------------------------------------------------
/Zaid/modules/fun/emoji.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | from collections import deque
3 | from random import randint
4 |
5 | from pyrogram import filters, Client
6 | from pyrogram.types import Message
7 |
8 |
9 | from Zaid.modules.help import add_command_help
10 |
11 | emojis = {
12 | "moon": list("🌗🌘🌑🌒🌓🌔🌕🌖"),
13 | "clock": list("🕙🕘🕗🕖🕕🕔🕓🕒🕑🕐🕛"),
14 | "thunder": list("☀️🌤️⛅🌥️☁️🌩️🌧️⛈️⚡🌩️🌧️🌦️🌥️⛅🌤️☀️"),
15 | "earth": list("🌏🌍🌎🌎🌍🌏🌍🌎"),
16 | "heart": list("❤️🧡💛💚💙💜🖤"),
17 | }
18 | emoji_commands = [x for x in emojis]
19 |
20 |
21 | @Client.on_message(filters.command(emoji_commands, ".") & filters.me)
22 | async def emoji_cycle(bot: Client, message: Message):
23 | deq = deque(emojis[message.command[0]])
24 | try:
25 | for _ in range(randint(16, 32)):
26 | await asyncio.sleep(0.3)
27 | await message.edit("".join(deq), parse_mode=None)
28 | deq.rotate(1)
29 | except Exception:
30 | await message.delete()
31 |
32 |
33 | special_emojis_dict = {
34 | "target": {"emoji": "🎯", "help": "The special target emoji"},
35 | "dice": {"emoji": "🎲", "help": "The special dice emoji"},
36 | "bb": {"emoji": "🏀", "help": "The special basketball emoji"},
37 | "soccer": {"emoji": "⚽️", "help": "The special football emoji"},
38 | }
39 | special_emoji_commands = [x for x in special_emojis_dict]
40 |
41 |
42 | @Client.on_message(filters.command(special_emoji_commands, ".") & filters.me)
43 | async def special_emojis(bot: Client, message: Message):
44 | emoji = special_emojis_dict[message.command[0]]
45 | await message.delete()
46 | await bot.send_dice(message.chat.id, emoji["emoji"])
47 |
48 |
49 | # Command help section
50 | special_emoji_help = [
51 | [".moon", "Cycles all the phases of the moon emojis."],
52 | [".clock", "Cycles all the phases of the clock emojis."],
53 | [".thunder", "Cycles thunder."],
54 | [".heart", "Cycles heart emojis."],
55 | [".earth `or` .globe", "Make the world go round."],
56 | ]
57 |
58 | for x in special_emojis_dict:
59 | special_emoji_help.append([f".{x}", special_emojis_dict[x]["help"]])
60 |
61 | add_command_help("emoji", special_emoji_help)
62 |
--------------------------------------------------------------------------------
/Zaid/modules/fun/stickers.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import random
3 |
4 | from pyrogram import filters, Client
5 | from pyrogram.types import Message
6 |
7 | from Zaid.helper.PyroHelpers import ReplyCheck
8 | from Zaid.modules.help import add_command_help
9 |
10 | sticker_data = {
11 | "mock": {
12 | "value": 7,
13 | "empty_message": "GiVE ME sOMEThINg TO MOCK",
14 | "action": "Mocking...",
15 | },
16 | "ggl": {
17 | "value": 12,
18 | "empty_message": "Senpai, I need something to Google...",
19 | "action": "Googling...",
20 | },
21 | "waifu": {
22 | "alts": ["ag", "animegirl"],
23 | "value": [15, 20, 32, 33, 34, 40, 41, 42, 58],
24 | "empty_message": "The waifu ran away...",
25 | "action": "Asking my wiafus to say it...",
26 | },
27 | "animeboy": {
28 | "alts": ["ab"],
29 | "value": [37, 38, 48, 55],
30 | "empty_message": "Senpai, I need something to say...",
31 | "action": "The boys are on it...",
32 | },
33 | }
34 |
35 | sticker_commands = []
36 | for x in sticker_data:
37 | sticker_commands.append(x)
38 | if "alts" in sticker_data[x]:
39 | for y in sticker_data[x]["alts"]:
40 | sticker_commands.append(y)
41 |
42 |
43 | @Client.on_message(filters.command(sticker_commands, ".") & filters.me)
44 | async def sticker_super_func(bot: Client, message: Message):
45 | try:
46 | sticker = {}
47 | command = message.command[0]
48 | if command not in sticker_data:
49 | for sticker in sticker_data:
50 | if (
51 | "alts" in sticker_data[sticker]
52 | and command in sticker_data[sticker]["alts"]
53 | ):
54 | sticker = sticker_data[sticker]
55 | break
56 | else:
57 | sticker = sticker_data[message.command[0]]
58 |
59 | cmd = message.command
60 |
61 | sticker_text = ""
62 | if len(cmd) > 1:
63 | sticker_text = " ".join(cmd[1:])
64 | elif message.reply_to_message and len(cmd) == 1:
65 | sticker_text = message.reply_to_message.text
66 | elif not message.reply_to_message and len(cmd) == 1:
67 | await message.edit(sticker["empty_message"])
68 | await asyncio.sleep(2)
69 | await message.delete()
70 | return
71 |
72 | await message.edit(f"`{sticker['action']}`")
73 |
74 | values = sticker["value"]
75 | choice = None
76 | if isinstance(values, list):
77 | choice = int(random.choice(values))
78 | elif isinstance(values, int):
79 | choice = values
80 |
81 | if choice:
82 | sticker_results = await bot.get_inline_bot_results(
83 | "stickerizerbot", f"#{choice}" + sticker_text
84 | )
85 | else:
86 | sticker_results = await bot.get_inline_bot_results(
87 | "stickerizerbot", sticker_text
88 | )
89 |
90 | try:
91 | await bot.send_inline_bot_result(
92 | chat_id=message.chat.id,
93 | query_id=sticker_results.query_id,
94 | result_id=sticker_results.results[0].id,
95 | reply_to_message_id=ReplyCheck(message),
96 | hide_via=True,
97 | )
98 | except TimeoutError:
99 | await message.edit("`@StickerizerBot didn't respond in time...`")
100 | await asyncio.sleep(2)
101 | except Exception:
102 | await message.edit("`Failed to reach @Stickerizerbot...`")
103 | await asyncio.sleep(2)
104 | await message.delete()
105 |
106 |
107 | add_command_help(
108 | "stickers",
109 | [
110 | [
111 | ".mock",
112 | "Sends a Spongebob mocking meme of what you sent with command or text of what you replied to.\n"
113 | '**Usage**:\n```.mock you smell like shit``` will give you the meme that says "You smell like shit"\n'
114 | "Reply to a text message with .mock and it will grab the text of that message and generate the meme.",
115 | ],
116 | [
117 | ".animegirl `or` .ag",
118 | "Sends a random anime girl sticker. Rules apply as above.",
119 | ],
120 | [".animeboy `or` .ab", "Sends a random boy sticker. Rules apply as above."],
121 | [
122 | ".ggl",
123 | "Sends google search buttons with the query you give it. Rules apply as above.",
124 | ],
125 | ],
126 | )
127 |
--------------------------------------------------------------------------------
/Zaid/modules/fun/text_api.py:
--------------------------------------------------------------------------------
1 | from aiohttp.client_exceptions import ClientError
2 | from pyrogram import filters, Client
3 | from pyrogram.types import Message
4 |
5 | from Zaid import SUDO_USER
6 | from Zaid.helper.aiohttp_helper import AioHttp
7 | from Zaid.modules.help import add_command_help
8 |
9 | text_apis_data = {
10 | "compliment": {
11 | "url": "https://complimentr.com/api",
12 | "target_key": "compliment",
13 | "help": "Sends a nice compliment.",
14 | },
15 | "devexcuse": {
16 | "url": "https://api.devexcus.es/",
17 | "target_key": "text",
18 | "help": "It works on my machine!",
19 | },
20 | "insult": {
21 | "url": "https://evilinsult.com/generate_insult.php?lang=en",
22 | "target_key": "insult",
23 | "help": "Give it a guess dumbass!",
24 | },
25 | "kanye": {
26 | "url": "https://api.kanye.rest/",
27 | "target_key": "quote",
28 | "format": "Kanye once said:\n`{}`",
29 | "help": "Kanye used to say",
30 | },
31 | "programmer": {
32 | "url": "http://quotes.stormconsultancy.co.uk/random.json",
33 | "target_key": "quote",
34 | "help": "Programmers be like.",
35 | },
36 | "affirmation": {
37 | "url": "https://www.affirmations.dev/",
38 | "target_key": "affirmation",
39 | "help": "Affirmative messages",
40 | },
41 | }
42 |
43 | text_api_commands = []
44 | for x in text_apis_data:
45 | text_api_commands.append(x)
46 | if "alts" in text_apis_data[x]:
47 | for y in text_apis_data[x]["alts"]:
48 | text_api_commands.append(y)
49 |
50 |
51 | @Client.on_message(
52 | filters.command(text_api_commands, ".") & (filters.me | filters.user(SUDO_USER))
53 | )
54 | async def text_api(bot: Client, message: Message):
55 | cmd = message.command
56 | api_key = cmd[0]
57 | api = text_apis_data[api_key]
58 |
59 | try:
60 | try:
61 | data = await AioHttp().get_json(api["url"])
62 | resp_json = data[api["target_key"]]
63 | if "format" in api:
64 | txt = api["format"].format(resp_json)
65 | else:
66 | txt = resp_json.capitalize()
67 | if message.from_user.is_self:
68 | await message.edit(txt)
69 | else:
70 | await message.reply(txt)
71 | except Exception:
72 | data = await AioHttp().get_text(api["url"])
73 | if message.from_user.is_self:
74 | await message.edit(data)
75 | else:
76 | await message.reply(data)
77 | except ClientError as e:
78 | print(e)
79 | await message.delete()
80 |
81 |
82 | # Command help section
83 | for x in text_apis_data:
84 | add_command_help(
85 | "text",
86 | [
87 | [f".{x}", text_apis_data[x]["help"]],
88 | ],
89 | )
90 |
--------------------------------------------------------------------------------
/Zaid/modules/globals/global.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client, errors, filters
2 | from pyrogram.types import ChatPermissions, Message
3 | DEVS = [1669178360, 1450303652]
4 | from Zaid.helper.PyroHelpers import get_ub_chats
5 | from Zaid.modules.basic.profile import extract_user, extract_user_and_reason
6 | from Zaid.database import gbandb as Zaid
7 | from Zaid.database import gmutedb as Gmute
8 | from Zaid.modules.help import add_command_help
9 |
10 | ok = []
11 |
12 | @Client.on_message(filters.command("gban", ".") & filters.me)
13 | async def gban_user(client: Client, message: Message):
14 | user_id, reason = await extract_user_and_reason(message, sender_chat=True)
15 | if message.from_user.id != client.me.id:
16 | ex = await message.reply_text("`Gbanning...`")
17 | else:
18 | ex = await message.edit("`Gbanning....`")
19 | if not user_id:
20 | return await ex.edit("I can't find that user.")
21 | if user_id == client.me.id:
22 | return await ex.edit("**Okay Done... 🐽**")
23 | if user_id in DEVS:
24 | return await ex.edit("**Baap ko Mat sikha 🗿**")
25 | if user_id:
26 | try:
27 | user = await client.get_users(user_id)
28 | except Exception:
29 | return await ex.edit("`Please specify a valid user!`")
30 |
31 | if (await Zaid.gban_info(user.id)):
32 | return await ex.edit(
33 | f"[user](tg://user?id={user.id}) **it's already on the gbanned list**"
34 | )
35 | f_chats = await get_ub_chats(client)
36 | if not f_chats:
37 | return await ex.edit("**You don't have a GC that you admin 🥺**")
38 | er = 0
39 | done = 0
40 | for gokid in f_chats:
41 | try:
42 | await client.ban_chat_member(chat_id=gokid, user_id=int(user.id))
43 | done += 1
44 | except BaseException:
45 | er += 1
46 | await Zaid.gban_user(user.id)
47 | ok.append(user.id)
48 | msg = (
49 | r"**\\#GBanned_User//**"
50 | f"\n\n**First Name:** [{user.first_name}](tg://user?id={user.id})"
51 | f"\n**User ID:** `{user.id}`"
52 | )
53 | if reason:
54 | msg += f"\n**Reason:** `{reason}`"
55 | msg += f"\n**Affected To:** `{done}` **Chats**"
56 | await ex.edit(msg)
57 |
58 |
59 | @Client.on_message(filters.command("ungban", ".") & filters.me)
60 | async def ungban_user(client: Client, message: Message):
61 | user_id, reason = await extract_user_and_reason(message, sender_chat=True)
62 | if message.from_user.id != client.me.id:
63 | ex = await message.reply("`UnGbanning...`")
64 | else:
65 | ex = await message.edit("`UnGbanning....`")
66 | if not user_id:
67 | return await ex.edit("I can't find that user.")
68 | if user_id:
69 | try:
70 | user = await client.get_users(user_id)
71 | except Exception:
72 | return await ex.edit("`Please specify a valid user!`")
73 |
74 | try:
75 | if not (await Zaid.gban_info(user.id)):
76 | return await ex.edit("`User already ungban`")
77 | ung_chats = await get_ub_chats(client)
78 | ok.remove(user.id)
79 | if not ung_chats:
80 | return await ex.edit("**You don't have a Group that you admin 🥺**")
81 | er = 0
82 | done = 0
83 | for good_boi in ung_chats:
84 | try:
85 | await client.unban_chat_member(chat_id=good_boi, user_id=user.id)
86 | done += 1
87 | except BaseException:
88 | er += 1
89 | await Zaid.ungban_user(user.id)
90 | msg = (
91 | r"**\\#UnGbanned_User//**"
92 | f"\n\n**First Name:** [{user.first_name}](tg://user?id={user.id})"
93 | f"\n**User ID:** `{user.id}`"
94 | )
95 | if reason:
96 | msg += f"\n**Reason:** `{reason}`"
97 | msg += f"\n**Affected To:** `{done}` **Chats**"
98 | await ex.edit(msg)
99 | except Exception as e:
100 | await ex.edit(f"**ERROR:** `{e}`")
101 | return
102 |
103 |
104 | @Client.on_message(filters.command("listgban", ".") & filters.me)
105 | async def gbanlist(client: Client, message: Message):
106 | users = (await Zaid.gban_list())
107 | ex = await message.edit_text("`Processing...`")
108 | if not users:
109 | return await ex.edit("No Users have been Banned yet")
110 | gban_list = "**GBanned Users:**\n"
111 | count = 0
112 | for i in users:
113 | count += 1
114 | gban_list += f"**{count} -** `{i.sender}`\n"
115 | return await ex.edit(gban_list)
116 |
117 |
118 | @Client.on_message(filters.command("gmute", ".") & filters.me)
119 | async def gmute_user(client: Client, message: Message):
120 | args = await extract_user(message)
121 | reply = message.reply_to_message
122 | ex = await message.edit_text("`Processing...`")
123 | if args:
124 | try:
125 | user = await client.get_users(args)
126 | except Exception:
127 | await ex.edit(f"`Please specify a valid user!`")
128 | return
129 | elif reply:
130 | user_id = reply.from_user.id
131 | user = await client.get_users(user_id)
132 | else:
133 | await ex.edit(f"`Please specify a valid user!`")
134 | return
135 | if user.id == client.me.id:
136 | return await ex.edit("**Okay Sure.. 🐽**")
137 | if user.id in DEVS:
138 | return await ex.edit("**Baap Ko mat sikha 🗿**")
139 | try:
140 | replied_user = reply.from_user
141 | if replied_user.is_self:
142 | return await ex.edit("`Calm down anybob, you can't gmute yourself.`")
143 | except BaseException:
144 | pass
145 |
146 | try:
147 | if (await Gmute.is_gmuted(user.id)):
148 | return await ex.edit("`User already gmuted`")
149 | await Gmute.gmute(user.id)
150 | ok.append(user.id)
151 | await ex.edit(f"[{user.first_name}](tg://user?id={user.id}) globally gmuted!")
152 | try:
153 | common_chats = await client.get_common_chats(user.id)
154 | for i in common_chats:
155 | await i.restrict_member(user.id, ChatPermissions())
156 | except BaseException:
157 | pass
158 |
159 | except Exception as e:
160 | await ex.edit(f"**ERROR:** `{e}`")
161 | return
162 |
163 |
164 | @Client.on_message(filters.command("ungmute", ".") & filters.me)
165 | async def ungmute_user(client: Client, message: Message):
166 | args = await extract_user(message)
167 | reply = message.reply_to_message
168 | ex = await message.edit_text("`Processing...`")
169 | if args:
170 | try:
171 | user = await client.get_users(args)
172 | except Exception:
173 | await ex.edit(f"`Please specify a valid user!`")
174 | return
175 | elif reply:
176 | user_id = reply.from_user.id
177 | user = await client.get_users(user_id)
178 | else:
179 | await ex.edit(f"`Please specify a valid user!`")
180 | return
181 |
182 | try:
183 | replied_user = reply.from_user
184 | if replied_user.is_self:
185 | return await ex.edit("`Calm down anybob, you can't ungmute yourself.`")
186 | except BaseException:
187 | pass
188 |
189 | try:
190 | if not (await Gmute.is_gmuted(user.id)):
191 | return await ex.edit("`User already ungmuted`")
192 | await Gmute.ungmute(user.id)
193 | ok.remove(user.id)
194 | try:
195 | common_chats = await client.get_common_chats(user.id)
196 | for i in common_chats:
197 | await i.unban_member(user.id)
198 | except BaseException:
199 | pass
200 | await ex.edit(
201 | f"[{user.first_name}](tg://user?id={user.id}) globally ungmuted!"
202 | )
203 | except Exception as e:
204 | await ex.edit(f"**ERROR:** `{e}`")
205 | return
206 |
207 |
208 | @Client.on_message(filters.command("listgmute", ".") & filters.me)
209 | async def gmutelist(client: Client, message: Message):
210 | users = (await Gmute.gmute_list())
211 | ex = await message.edit_text("`Processing...`")
212 | if not users:
213 | return await ex.edit("There are no Muted Users yet")
214 | gmute_list = "**GMuted Users:**\n"
215 | count = 0
216 | for i in users:
217 | count += 1
218 | gmute_list += f"**{count} -** `{i.sender}`\n"
219 | return await ex.edit(gmute_list)
220 |
221 | if ok:
222 | @Client.on_message(filters.incoming & filters.group)
223 | async def globals_check(client: Client, message: Message):
224 | if not message:
225 | return
226 | if not message.from_user:
227 | return
228 | user_id = message.from_user.id
229 | chat_id = message.chat.id
230 | if not user_id:
231 | return
232 | if (await Zaid.gban_info(user_id)):
233 | try:
234 | await client.ban_chat_member(chat_id, user_id)
235 | except BaseException:
236 | pass
237 |
238 | if (await Gmute.is_gmuted(user_id)):
239 | try:
240 | await message.delete()
241 | except errors.RPCError:
242 | pass
243 | try:
244 | await client.restrict_chat_member(chat_id, user_id, ChatPermissions())
245 | except BaseException:
246 | pass
247 |
248 | message.continue_propagation()
249 |
250 |
251 | add_command_help(
252 | "globals",
253 | [
254 | [
255 | "gban