Skip to content

Commit

Permalink
Few things left
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgojoof6eyes committed Jul 2, 2024
1 parent 84c5b82 commit 67f2e3f
Show file tree
Hide file tree
Showing 24 changed files with 312 additions and 127 deletions.
26 changes: 15 additions & 11 deletions Powers/plugins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,27 @@ async def adminlist_show(_, m: Message):
return



@Gojo.on_message(command("zombies") & admin_filter)
async def zombie_clean(c: Gojo, m: Message):
zombie = 0
wait = await m.reply_text("Searching ... and banning ...")
failed = 0
async for member in c.get_chat_members(m.chat.id):
if member.user.is_deleted:
zombie += 1
try:
await c.ban_chat_member(m.chat.id, member.user.id)
except UserAdminInvalid:
zombie -= 1
failed += 1
except FloodWait as e:
await sleep(e.x)
if zombie == 0:
return await wait.edit_text("Group is clean!")
return await wait.edit_text(
text=f"<b>{zombie}</b> Zombies found and has been banned!",
)

await wait.delete()
txt=f"<b>{zombie}</b> Zombies found and {zombie - failed} has been banned!\n{failed} zombies' are immune to me",
await m.reply_animation("https://graph.org/file/02a1dcf7788186ffb36cb.mp4", caption=txt)
return

@Gojo.on_message(command("admincache"))
async def reload_admins(_, m: Message):
Expand Down Expand Up @@ -163,8 +165,8 @@ async def fullpromote_usr(c: Gojo, m: Message):
user_id, user_first_name, user_name = await extract_user(c, m)
except Exception:
return
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
if user_id == Config.BOT_ID:
bot = await c.get_chat_member(m.chat.id, c.me.id)
if user_id == c.me.id:
await m.reply_text("Huh, how can I even promote myself?")
return
if not bot.privileges.can_promote_members:
Expand Down Expand Up @@ -259,8 +261,8 @@ async def promote_usr(c: Gojo, m: Message):
user_id, user_first_name, user_name = await extract_user(c, m)
except Exception:
return
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
if user_id == Config.BOT_ID:
bot = await c.get_chat_member(m.chat.id, c.me.id)
if user_id == c.me.id:
await m.reply_text("Huh, how can I even promote myself?")
return
if not bot.privileges.can_promote_members:
Expand Down Expand Up @@ -290,6 +292,8 @@ async def promote_usr(c: Gojo, m: Message):
can_pin_messages=bot.privileges.can_pin_messages,
can_manage_chat=bot.privileges.can_manage_chat,
can_manage_video_chats=bot.privileges.can_manage_video_chats,
can_post_messages=bot.privileges.can_post_messages,
can_edit_messages=bot.privileges.can_edit_messages
),
)
title = ""
Expand Down Expand Up @@ -358,7 +362,7 @@ async def demote_usr(c: Gojo, m: Message):
user_id, user_first_name, _ = await extract_user(c, m)
except Exception:
return
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Get an admin to demote me!")
return
# If user not already admin
Expand Down Expand Up @@ -511,7 +515,7 @@ async def set_user_title(c: Gojo, m: Message):
return
if not user_id:
return await m.reply_text("Cannot find user!")
if user_id == Config.BOT_ID:
if user_id == c.me.id:
return await m.reply_text("Huh, why ?")
if not reason:
return await m.reply_text("Read /help please!")
Expand Down
7 changes: 4 additions & 3 deletions Powers/plugins/antispam.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def gban(c: Gojo, m: Message):
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
return

if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text(
text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......"
)
Expand Down Expand Up @@ -99,7 +99,7 @@ async def ungban(c: Gojo, m: Message):
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
return

if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text(
text="""You can't gban me nigga!
Fuck yourself.......!"""
Expand Down Expand Up @@ -156,7 +156,8 @@ async def gban_list(_, m: Message):

banfile = "Here are all the globally banned geys!\n\n"
for user in banned_users:
banfile += f"[x] <b>{Users.get_user_info(user['_id'])['name']}</b> - <code>{user['_id']}</code>\n"
USER = Users.get_user_info(user['_id'])
banfile += f"[x] <b>{USER['name'] if USER else 'Name NA'}</b> - <code>{user['_id']}</code>\n"
if user["reason"]:
banfile += f"<b>Reason:</b> {user['reason']}\n"

Expand Down
18 changes: 9 additions & 9 deletions Powers/plugins/bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def tban_usr(c: Gojo, m: Message):
if not user_id:
await m.reply_text("Cannot find user to ban")
return
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("WTF?? Why would I ban myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -171,7 +171,7 @@ async def stban_usr(c: Gojo, m: Message):
if not user_id:
await m.reply_text("Cannot find user to ban")
return
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("What the heck? Why would I ban myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -265,7 +265,7 @@ async def dtban_usr(c: Gojo, m: Message):
if not user_id:
await m.reply_text("Cannot find user to ban")
return
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Huh, why would I ban myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -395,7 +395,7 @@ async def kick_usr(c: Gojo, m: Message):
await m.reply_text("Cannot find user to kick")
return

if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Huh, why would I kick myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -486,7 +486,7 @@ async def skick_usr(c: Gojo, m: Message):
await m.reply_text("Cannot find user to kick")
return

if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Nuh Hu, why would I kick myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -560,7 +560,7 @@ async def dkick_usr(c: Gojo, m: Message):
await m.reply_text("Cannot find user to kick")
return

if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Huh, why would I kick myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -711,7 +711,7 @@ async def sban_usr(c: Gojo, m: Message):
if user_id == m.chat.id:
await m.reply_text("That's an admin!")
await m.stop_propagation()
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Huh, why would I ban myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -792,7 +792,7 @@ async def dban_usr(c: Gojo, m: Message):
if user_id == m.chat.id:
await m.reply_text("That's an admin!")
await m.stop_propagation()
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Huh, why would I ban myself?")
await m.stop_propagation()

Expand Down Expand Up @@ -893,7 +893,7 @@ async def ban_usr(c: Gojo, m: Message):
if user_id == m.chat.id:
await m.reply_text("That's an admin!")
await m.stop_propagation()
if user_id == Config.BOT_ID:
if user_id == c.me.id:
await m.reply_text("Huh, why would I ban myself?")
await m.stop_propagation()

Expand Down
18 changes: 6 additions & 12 deletions Powers/plugins/clean_db.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import time
from asyncio import sleep
from traceback import format_exc

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from pyrogram.enums import ChatMemberStatus as CMS
from pyrogram.errors import PeerIdInvalid, UserNotParticipant
from pyrogram.errors import UserNotParticipant

from Powers import LOGGER, MESSAGE_DUMP, TIME_ZONE
from Powers import LOGGER, MESSAGE_DUMP
from Powers.bot_class import Gojo
from Powers.database.approve_db import Approve
from Powers.database.blacklist_db import Blacklist
Expand All @@ -20,18 +18,17 @@
from Powers.database.reporting_db import Reporting
# from Powers.database.users_db import Users
from Powers.database.warns_db import Warns, WarnSettings
from Powers.utils.custom_filters import command
from Powers.vars import Config


async def clean_my_db(c:Gojo,is_cmd=False, id=None):
async def clean_my_db(c: Gojo, is_cmd=False, id=None):
to_clean = list()
chats_list = Chats.list_chats_by_id()
to_clean.clear()
start = time.time()
for chats in chats_list:
try:
stat = await c.get_chat_member(chat_id=chats,user_id=Config.BOT_ID)
stat = await c.get_chat_member(chat_id=chats, user_id=c.me.id)
if stat.status not in [CMS.MEMBER, CMS.ADMINISTRATOR, CMS.OWNER]:
to_clean.append(chats)
except UserNotParticipant:
Expand Down Expand Up @@ -64,12 +61,9 @@ async def clean_my_db(c:Gojo,is_cmd=False, id=None):
if is_cmd:
txt += f"\nClean type: Forced\nInitiated by: {(await c.get_users(user_ids=id)).mention}"
txt += f"\nClean type: Manual\n\tTook {round(nums,2)} seconds to complete the process"
await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
await c.send_message(chat_id=MESSAGE_DUMP, text=txt)
return txt
else:
txt += f"\nClean type: Auto\n\tTook {round(nums,2)} seconds to complete the process"
await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
await c.send_message(chat_id=MESSAGE_DUMP, text=txt)
return txt



47 changes: 47 additions & 0 deletions Powers/plugins/dev.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess as subp
import sys
from asyncio import create_subprocess_shell, sleep, subprocess
from importlib.metadata import PackageNotFoundError, metadata
from io import BytesIO, StringIO
from os import execvp
from sys import executable
Expand Down Expand Up @@ -209,6 +210,52 @@ async def ping(_, m: Message):
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
return

"""
['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', 'Author-email', 'License', 'Download-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Keywords', 'Platform', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Python', 'Description-Content-Type', 'License-File', 'License-File', 'License-File', 'Requires-Dist', 'Requires-Dist', 'Description']
"""

@Gojo.on_message(command(["minfo", "moduleinfo"], dev_cmd=True))
async def check_module_info(_, m: Message):
if len(m.command) != 2:
await m.reply_text("**USAGE**\n/minfo [module name]")
return

module = m.command[-1]

try:
minfo = metadata(module)
except PackageNotFoundError:
await m.reply_text(f"No module found with name {module}")
return

name = minfo["Name"]
version = minfo["Version"]
summary = minfo["Summary"]
home_page = minfo["Home-Page"]
author = minfo["Author"]
license = minfo["License"]
download = minfo["Download-URL"]

txt = f"""
Here are the info about the module **{name}**
• Version: {version}
• Summary: {summary}
• Home page: {home_page}
• Author: {author}
• License: {license}
• Download: {download}
"""
await m.reply_text(txt, disable_web_page_preview=True)
return



@Gojo.on_message(command("logs", dev_cmd=True))
async def send_log(c: Gojo, m: Message):
Expand Down
3 changes: 1 addition & 2 deletions Powers/plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def add_filter(_, m: Message):
async def stop_filter(_, m: Message):
args = m.command

if len(args) < 1:
if len(args) <= 1:
return await m.reply_text("What should I stop replying to?")

chat_filters = db.get_all_filters(m.chat.id)
Expand Down Expand Up @@ -283,7 +283,6 @@ async def filters_watcher(c: Gojo, m: Message):
if match:
try:
msgtype = await send_filter_reply(c, m, trigger)
LOGGER.info(f"Replied with {msgtype} to {trigger} in {m.chat.id}")
except Exception as ef:
await m.reply_text(f"Error: {ef}")
LOGGER.error(ef)
Expand Down
4 changes: 2 additions & 2 deletions Powers/plugins/flood.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def get_what_temp(what):
@Gojo.on_message(command(['floodaction','actionflood']) & admin_filter)
async def flood_action(c: Gojo, m: Message):
Flood = Floods()
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
bot = await c.get_chat_member(m.chat.id, c.me.id)
status = bot.status
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
if not bot.privileges.can_restrict_members:
Expand Down Expand Up @@ -189,7 +189,7 @@ async def flood_on_off(c: Gojo, m: Message):

@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
async def flood_set(c: Gojo, m: Message):
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
bot = await c.get_chat_member(m.chat.id, c.me.id)
Flood = Floods()
status = bot.status
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
Expand Down
6 changes: 4 additions & 2 deletions Powers/plugins/greetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pyrogram import emoji, enums, filters
from pyrogram.enums import ChatMemberStatus as CMS
from pyrogram.errors import ChatAdminRequired, RPCError
from pyrogram.errors import ChannelPrivate, ChatAdminRequired, RPCError
from pyrogram.types import ChatMemberUpdated, Message

from Powers import LOGGER
Expand Down Expand Up @@ -257,7 +257,7 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):
db = Greetings(member.chat.id)
banned_users = gdb.check_gban(user.id)
try:
if user.id == Config.BOT_ID:
if user.id == c.me.id:
return
if user.id in DEV_USERS:
await c.send_animation(
Expand Down Expand Up @@ -332,6 +332,8 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):

if jj:
db.set_cleanwlcm_id(int(jj.id))
except ChannelPrivate:
return
except RPCError as e:
LOGGER.error(e)
LOGGER.error(format_exc(e))
Expand Down
6 changes: 3 additions & 3 deletions Powers/plugins/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ async def user_info(c: Gojo, user, already=False):
is_restricted = user.is_restricted
photo_id = user.photo.big_file_id if user.photo else None
is_support = True if user_id in SUPPORT_STAFF else False
if user_id == Config.BOT_ID:
if user_id == c.me.id:
is_support = "A person is a great support to himself"
omp = "Hmmm.......Who is that again?"
if is_support or Config.BOT_ID:
if is_support or c.me.id:
if user_id in DEV_USERS:
omp = "Dev"
elif user_id in SUDO_USERS:
omp = "Sudoer"
elif user_id in WHITELIST_USERS:
omp = "Whitelist"
elif user_id == Config.BOT_ID:
elif user_id == c.me.id:
omp = "I am the targeted user"
elif user_id == OWNER_ID:
omp = "Owner of the bot"
Expand Down
Loading

0 comments on commit 67f2e3f

Please sign in to comment.