File size: 2,950 Bytes
78b07ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from pyrogram import Client, filters
from pyrogram.types import Message

from . import BotHelp, Config, Symbols, hellbot


@hellbot.bot.on_message(

    filters.command("addauth") & Config.AUTH_USERS

)
async def addauth(client: Client, message: Message):
    if not message.reply_to_message:
        if len(message.command) < 2:
            return await message.reply_text(
                "Reply to a user or give me a userid/username to add them as an auth user!"
            )
        try:
            user = await client.get_users(message.command[1])
        except Exception:
            return await message.reply_text(
                "Give me a valid userid/username to add them as an auth user!"
            )
    else:
        user = message.reply_to_message.from_user

    if user.is_self:
        return await message.reply_text("I can't add myself as an auth user!")

    if user.id in Config.AUTH_USERS:
        return await message.reply_text(f"**{user.mention} is already authorized**")

    Config.AUTH_USERS.add(user.id)
    await message.reply_text(f"**Added {user.mention} to auth users!**")


@hellbot.bot.on_message(

    filters.command("delauth") & Config.AUTH_USERS

)
async def delauth(client: Client, message: Message):
    if not message.reply_to_message:
        if len(message.command) < 2:
            return await message.reply_text(
                "Reply to a user or give me a userid/username to add them as an auth user!"
            )
        try:
            user = await client.get_users(message.command[1])
        except Exception:
            return await message.reply_text(
                "Give me a valid userid/username to add them as an auth user!"
            )
    else:
        user = message.reply_to_message.from_user

    if user.id in Config.AUTH_USERS:
        Config.AUTH_USERS.remove(user.id)
        await message.reply_text(f"**Removed {user.mention} from auth users!**")
    else:
        await message.reply_text(f"**{user.mention} is not authorized**")


@hellbot.bot.on_message(

    filters.command("authlist") & Config.AUTH_USERS

)
async def authlist(client: Client, message: Message):
    text = "**🍀 Authorized Users:**\n\n"
    for i, userid in enumerate(Config.AUTH_USERS):
        try:
            user = await client.get_users(userid)
            text += f"    {Symbols.anchor} {user.mention} (`{user.id}`)\n"
        except:
            text += f"    {Symbols.anchor} Auth User #{i+1} (`{userid}`)\n"

    await message.reply_text(text)


BotHelp("Users").add(
    "addauth",
    "This command is used to add a user as an authorized user. An authorized user can create and manage userbot session!",
).add("delauth", "This command is used to remove a user from authorized users.").add(
    "authlist", "This command is used to list all authorized users."
).info(
    "Users Command 🚀"
).done()