-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add admin features and update user controls
- added ban / unban features - update database schema to keep track of files a user has downloaded / uploaded
- Loading branch information
Showing
7 changed files
with
103 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) 2023 Itz-fork | ||
# Author: https://github.com/Itz-fork | ||
# Project: https://github.com/Itz-fork/Mega.nz-Bot | ||
# Description: Admin functions | ||
|
||
from pyrogram import filters | ||
from pyrogram.types import Message | ||
|
||
from megadl import MeganzClient | ||
|
||
|
||
@MeganzClient.on_message(filters.command("ban")) | ||
@MeganzClient.handle_checks | ||
async def admin_ban_user(client: MeganzClient, msg: Message): | ||
sender = msg.from_user.id | ||
if sender not in client.auth_users: | ||
return await msg.reply("Banning users can only be done by admins!") | ||
buid = None | ||
try: | ||
buid = int(msg.text.split(None, 1)[1]) | ||
except: | ||
pass | ||
if not buid or not buid.isnumeric(): | ||
return await msg.reply("Provide a user id to ban \n\nEx: `/ban 12345`") | ||
|
||
await client.database.ban_user(buid) | ||
await msg.reply(f"Banned user `{buid}`") | ||
|
||
|
||
@MeganzClient.on_message(filters.command("unban")) | ||
@MeganzClient.handle_checks | ||
async def admin_unban_user(client: MeganzClient, msg: Message): | ||
sender = msg.from_user.id | ||
if sender not in client.auth_users: | ||
return await msg.reply("Unbanning users can only be done by admins!") | ||
buid = None | ||
try: | ||
buid = int(msg.text.split(None, 1)[1]) | ||
except: | ||
pass | ||
if not buid or not buid.isnumeric(): | ||
return await msg.reply("Provide a user id to unban \n\nEx: `/ban 12345`") | ||
|
||
await client.database.unban_user(buid) | ||
await msg.reply(f"Unbanned user `{buid}`") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters