Skip to content

Commit

Permalink
fixed gban and fake stats issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Noob-mukesh committed Jun 23, 2024
1 parent 9d53d56 commit b0f3341
Show file tree
Hide file tree
Showing 18 changed files with 317 additions and 1,069 deletions.
29 changes: 11 additions & 18 deletions MukeshRobot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from telegram.utils.helpers import escape_markdown
from telethon import __version__ as tlhver

import MukeshRobot.modules.no_sql.users_db as sql
from MukeshRobot.modules.no_sql import get_served_chats,get_served_users
from MukeshRobot import (
BOT_NAME,
BOT_USERNAME,
Expand Down Expand Up @@ -78,11 +78,7 @@ def get_readable_time(seconds: int) -> str:
*ʜᴇʏ* {} , 🥀
*๏ ɪ'ᴍ {} ʜᴇʀᴇ ᴛᴏ ʜᴇʟᴘ ʏᴏᴜ ᴍᴀɴᴀɢᴇ ʏᴏᴜʀ ɢʀᴏᴜᴘs!
ʜɪᴛ ʜᴇʟᴘ ᴛᴏ ғɪɴᴅ ᴏᴜᴛ ᴍᴏʀᴇ ᴀʙᴏᴜᴛ ʜᴏᴡ ᴛᴏ ᴜsᴇ ᴍᴇ ɪɴ ᴍʏ ғᴜʟʟ ᴘᴏᴛᴇɴᴛɪᴀʟ!*
➻ *ᴛʜᴇ ᴍᴏsᴛ ᴩᴏᴡᴇʀғᴜʟ ᴛᴇʟᴇɢʀᴀᴍ ɢʀᴏᴜᴩ ᴍᴀɴᴀɢᴇᴍᴇɴᴛ ➕ ᴍᴜsɪᴄ ᴍᴀɴᴀɢᴇᴍᴇɴᴛ ʙᴏᴛ ᴀɴᴅ ɪ ʜᴀᴠᴇ sᴏᴍᴇ ᴀᴡᴇsᴏᴍᴇ ᴀɴᴅ ᴜsᴇғᴜʟ ғᴇᴀᴛᴜʀᴇs.*
─────────────────
*➻ ᴜsᴇʀs »* {}
*➻ ᴄʜᴀᴛs »* {}
─────────────────
➻ *ᴛʜᴇ ᴍᴏsᴛ ᴩᴏᴡᴇʀғᴜʟ ᴛᴇʟᴇɢʀᴀᴍ ɢʀᴏᴜᴩ ᴍᴀɴᴀɢᴇᴍᴇɴᴛ ʙᴏᴛ ᴀɴᴅ ɪ ʜᴀᴠᴇ sᴏᴍᴇ ᴀᴡᴇsᴏᴍᴇ ᴀɴᴅ ᴜsᴇғᴜʟ ғᴇᴀᴛᴜʀᴇs.*
"""

buttons = [
Expand Down Expand Up @@ -112,7 +108,7 @@ def get_readable_time(seconds: int) -> str:
DONATE_STRING = f"""ʜᴇʏ ʙᴀʙʏ,
ʜᴀᴩᴩʏ ᴛᴏ ʜᴇᴀʀ ᴛʜᴀᴛ ʏᴏᴜ ᴡᴀɴɴᴀ ᴅᴏɴᴀᴛᴇ.
ʏᴏᴜ ᴄᴀɴ ᴅɪʀᴇᴄᴛʟʏ ᴄᴏɴᴛᴀᴄᴛ ᴍʏ ᴅᴇᴠᴇʟᴏᴘᴇʀ @Legend\_coder ғᴏʀ ᴅᴏɴᴀᴛɪɴɢ ᴏʀ ʏᴏᴜ ᴄᴀɴ ᴠɪsɪᴛ ᴍʏ sᴜᴩᴩᴏʀᴛ ᴄʜᴀᴛ @the\_support\_chat ᴀɴᴅ ᴀsᴋ ᴛʜᴇʀᴇ ᴀʙᴏᴜᴛ ᴅᴏɴᴀᴛɪᴏɴ."""
ʏᴏᴜ ᴄᴀɴ ᴅɪʀᴇᴄᴛʟʏ ᴄᴏɴᴛᴀᴄᴛ ᴍʏ ᴅᴇᴠᴇʟᴏᴘᴇʀ ғᴏʀ ᴅᴏɴᴀᴛɪɴɢ ᴏʀ ʏᴏᴜ ᴄᴀɴ ᴠɪsɪᴛ ᴍʏ sᴜᴩᴩᴏʀᴛ ᴄʜᴀᴛ ᴀɴᴅ ᴀsᴋ ᴛʜᴇʀᴇ ᴀʙᴏᴜᴛ ᴅᴏɴᴀᴛɪᴏɴ."""

IMPORTED = {}
MIGRATEABLE = []
Expand Down Expand Up @@ -171,7 +167,6 @@ def send_help(chat_id, text, keyboard=None):
parse_mode=ParseMode.MARKDOWN,
reply_markup=keyboard,
)

def start(update: Update, context: CallbackContext):
args = context.args
global uptime
Expand Down Expand Up @@ -215,16 +210,13 @@ def start(update: Update, context: CallbackContext):
lol = update.effective_message.reply_text(
PM_START_TEX.format(usr.first_name), parse_mode=ParseMode.MARKDOWN
)
time.sleep(0.4)
lol.edit_text("❤")
time.sleep(0.5)
lol.edit_text("⚡")
time.sleep(0.3)
lol.edit_text("❤")
time.sleep(0.2)
lol.edit_text("ꜱᴛᴀʀᴛɪɴɢ... ")
time.sleep(0.4)
time.sleep(0.2)
lol.delete()

update.effective_message.reply_photo(START_IMG,PM_START_TEXT.format(escape_markdown(first_name), BOT_NAME,sql.num_users(),sql.num_chats()),
update.effective_message.reply_photo(START_IMG,PM_START_TEXT.format(escape_markdown(first_name), BOT_NAME),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
Expand Down Expand Up @@ -359,15 +351,16 @@ def help_button(update, context):

def Mukesh_about_callback(update: Update, context: CallbackContext):
query = update.callback_query

if query.data == "mukesh_":
uptime = get_readable_time((time.time() - StartTime))
query.message.edit_caption(f"*ʜᴇʏ,*🥀\n *ᴛʜɪs ɪs {dispatcher.bot.first_name}*"
"\n*ᴀ ᴘᴏᴡᴇʀꜰᴜʟ ɢʀᴏᴜᴘ ᴍᴀɴᴀɢᴇᴍᴇɴᴛ ➕ ᴍᴜsɪᴄ ᴍᴀɴᴀɢᴇᴍᴇɴᴛ ʙᴜɪʟᴛ ᴛᴏ ʜᴇʟᴘ ʏᴏᴜ ᴍᴀɴᴀɢᴇ ʏᴏᴜʀ ɢʀᴏᴜᴘ ᴇᴀꜱɪʟʏ ᴀɴᴅ ᴛᴏ ᴘʀᴏᴛᴇᴄᴛ ʏᴏᴜʀ ɢʀᴏᴜᴘ ꜰʀᴏᴍ ꜱᴄᴀᴍᴍᴇʀꜱ ᴀɴᴅ ꜱᴘᴀᴍᴍᴇʀꜱ.*"
"\n*ᴡʀɪᴛᴛᴇɴ ɪɴ ᴩʏᴛʜᴏɴ ᴡɪᴛʜ sǫʟᴀʟᴄʜᴇᴍʏ ᴀɴᴅ ᴍᴏɴɢᴏᴅʙ ᴀs ᴅᴀᴛᴀʙᴀsᴇ.*"
"\n\n────────────────────"
f"\n*➻ ᴜᴩᴛɪᴍᴇ »* {uptime}"
f"\n*➻ ᴜsᴇʀs »* {sql.num_users()}"
f"\n* ᴄʜᴀᴛs »* {sql.num_chats()}"
f"\n* ᴜꜱᴇʀꜱ : {len(get_served_users())} ",
f"\n* ᴄʜᴀᴛs : {len(get_served_chats())} ",
"\n────────────────────"
"\n\n➲ ɪ ᴄᴀɴ ʀᴇꜱᴛʀɪᴄᴛ ᴜꜱᴇʀꜱ."
"\n➲ ɪ ʜᴀᴠᴇ ᴀɴ ᴀᴅᴠᴀɴᴄᴇᴅ ᴀɴᴛɪ-ꜰʟᴏᴏᴅ ꜱʏꜱᴛᴇᴍ."
Expand Down Expand Up @@ -446,7 +439,7 @@ def Mukesh_about_callback(update: Update, context: CallbackContext):
)
elif query.data == "mukesh_back":
first_name = update.effective_user.first_name
query.message.edit_caption(PM_START_TEXT.format(escape_markdown(first_name), BOT_NAME,sql.num_users(),sql.num_chats()),
query.message.edit_caption(PM_START_TEXT.format(escape_markdown(first_name), BOT_NAME),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
Expand Down
37 changes: 15 additions & 22 deletions MukeshRobot/config.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@

class Config(object):
LOGGER = True
# REQUIRED
# Login to https://my.telegram.org and fill in these slots with the details given by it

API_ID = "" # integer value, dont use ""
API_ID =None
API_HASH = ""
TOKEN = "" # This var used to be API_KEY but it is now TOKEN, adjust accordingly.
OWNER_ID = 2145093972 # If you dont know, run the bot and do /id in your private chat with it, also an integer
TOKEN = ""
OWNER_ID=None

SUPPORT_CHAT = "the_support_chat" # Your own group for support, do not add the @
SUPPORT_CHAT = ""
START_IMG = ""
EVENT_LOGS = () # Prints information like gbans, sudo promotes, AI enabled disable states that may help in debugging and shit
EVENT_LOGS = ()
MONGO_DB_URI= ""
# RECOMMENDED

DATABASE_URL = "" # A sql database url from elephantsql.com
CASH_API_KEY = (
"" # Get your API key from https://www.alphavantage.co/support/#api-key
""
)
TIME_API_KEY = ""

# Get your API key from https://timezonedb.com/api


# Optional fields
BL_CHATS = [] # List of groups that you want blacklisted.
DRAGONS = [] # User id of sudo users
DEV_USERS = [] # User id of dev users
DEMONS = [] # User id of support users
TIGERS = [] # User id of tiger users
WOLVES = [] # User id of whitelist users

BL_CHATS = []
DRAGONS = []
DEV_USERS = []
DEMONS = []
TIGERS = []
WOLVES = []

ALLOW_CHATS = True
ALLOW_EXCL = True
Expand All @@ -47,4 +40,4 @@ class Production(Config):


class Development(Config):
LOGGER = True
LOGGER = True
22 changes: 18 additions & 4 deletions MukeshRobot/modules/alive.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import asyncio
from platform import python_version as pyver

from pyrogram.enums import ChatType
from pyrogram import __version__ as pver
from pyrogram import filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from telegram import __version__ as lver
from telethon import __version__ as tver

from MukeshRobot.modules.no_sql import add_served_chat,save_id
from MukeshRobot import SUPPORT_CHAT, pbot,BOT_USERNAME, OWNER_ID,BOT_NAME,START_IMG

async def member_permissions(chat_id: int, user_id: int):
Expand Down Expand Up @@ -66,16 +66,17 @@ async def restart(client, m: Message):

await accha.delete()
await asyncio.sleep(0.3)

umm = await m.reply_sticker(
"CAACAgUAAxkDAAJHbmLuy2NEfrfh6lZSohacEGrVjd5wAAIOBAACl42QVKnra4sdzC_uKQQ"
)
await umm.delete()
# OWNER_name=
owner=await pbot.get_users(OWNER_ID)
await m.reply_photo(
START_IMG,
caption=f"""**ʜᴇʏ, ɪ ᴀᴍ 『[{BOT_NAME}](f"t.me/{BOT_USERNAME}")』**
━━━━━━━━━━━━━━━━━━━
» **ᴍʏ ᴏᴡɴᴇʀ :** {await client.get_users(OWNER_ID).mention}
» **ᴍʏ ᴏᴡɴᴇʀ :** {owner.mention()}
» **ʟɪʙʀᴀʀʏ ᴠᴇʀsɪᴏɴ :** `{lver}`
Expand All @@ -87,3 +88,16 @@ async def restart(client, m: Message):
━━━━━━━━━━━━━━━━━━━""",
reply_markup=InlineKeyboardMarkup(Mukesh)
)

@pbot.on_message(group=1)
async def save_statss(_, m):
try:
if m.chat.type == ChatType.PRIVATE:
save_id(m.from_user.id)
elif m.chat.type==ChatType.SUPERGROUP:
add_served_chat(m.chat.id)
else:
add_served_chat(m.chat.id)

except Exception as e:
await _.send_message(OWNER_ID,f"db error {e}")
86 changes: 86 additions & 0 deletions MukeshRobot/modules/gban_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# -----------CREDITS -----------
# telegram : @legend_coder
# github : noob-mukesh
from pyrogram import filters
from .. import pbot as Mukesh,OWNER_ID
from pyrogram.types import ChatPrivileges,ChatPermissions
from pyrogram.types import *
from MukeshRobot.modules.no_sql import add_gban,remove_gban,is_gban,get_served_chats,get_gban_list,is_user_ingbanned
@Mukesh.on_message(filters.command("gban") & filters.user(OWNER_ID) & ( filters.group | filters.channel) )
async def banuser(b,message):
reason=""
if message.reply_to_message:
user = message.reply_to_message.from_user.id
r=message.text.split()[1:] if message.reply_to_message else None
reason+=r
u=is_user_ingbanned(user)
if u:
return await message.reply_text("User is already gbanned")
elif not message.reply_to_message and len(message.command) != 1:
user = message.text.split(None, 1)[1].split()[0]
r= " ".join(message.command[2:]) if len(message.command) > 2 else None
print(r)
reason+=r
success=0
hm = await Mukesh.get_users(user)
try:
all_chats =get_served_chats()
for chat in all_chats:

try:
sts=await b.ban_chat_member(chat["chat_id"],user)
add_gban(user_id=user,gban_reason=reason)
success += 1
except Exception as e:
print(e)
await message.reply_text(f"gbanned from {success} chats \n user :> {hm.mention()} reason {reason}")
except Exception as e:
await message.reply_text(f"failed due to {e}")
@Mukesh.on_message(filters.command("ungban") & filters.user(OWNER_ID) & ( filters.group | filters.channel) )
async def unbanuser(b,message):
if message.reply_to_message:
user = message.reply_to_message.from_user.id
u=is_user_ingbanned(user)
if not u:
return await message.reply_text("User is not gbanned yet")
elif not message.reply_to_message and len(message.command) != 1:
user = message.text.split(None, 1)[1]

success=0
hm = await Mukesh.get_users(user)
try:
all_chats =get_served_chats()
for chat in all_chats:

try:
sts=await b.unban_chat_member(chat["chat_id"],user)
remove_gban(user_id=user)
success += 1
except Exception as e:
print(e)
await message.reply_text(f"ungbanned from {success} chats \n user :> {hm.mention()}")
except Exception as e:
await message.reply_text(f"failed due to {e}")
@Mukesh.on_message(filters.command("gbanlist") & filters.user(OWNER_ID))
async def get_gban_listss(_,m) :
banned=get_gban_list()
if len(get_gban_list())==0:
return await m.reply_text("No users are gbanned")
text="Gbanned Users:\n"
for user in banned :
text+=f"• {user['user_id']} - {user['gban_reason']}\n"
if len(text) > 4096:
filename = "gbanlist.txt"
with open(filename, "w+", encoding="utf8") as out_file:
out_file.write(str(text))

return await m.reply_document(
document=filename)
else:
await m.reply_text(text)



def __stats__():
return f"• {len(get_gban_list())} ɢʙᴀɴɴᴇᴅ ᴜsᴇʀs."
__mod_name__ = "Gʙᴀɴ​"
Loading

0 comments on commit b0f3341

Please sign in to comment.