-
Notifications
You must be signed in to change notification settings - Fork 1
/
loop.py
51 lines (48 loc) · 1.6 KB
/
loop.py
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
from pyrogram import filters
from pyrogram.types import Message
from strings.filters import command
from config import BANNED_USERS
from strings import get_command
from AnonX import app
from AnonX.utils.database.memorydatabase import (get_loop,
set_loop)
from AnonX.utils.decorators import AdminRightsCheck
# Commands
LOOP_COMMAND = get_command("LOOP_COMMAND")
@app.on_message(
command(LOOP_COMMAND)
& filters.group
& ~BANNED_USERS
)
@AdminRightsCheck
async def admins(cli, message: Message, _, chat_id):
usage = _["admin_24"]
if len(message.command) != 2:
return await message.reply_text(usage)
state = message.text.split(None, 1)[1].strip()
if state.isnumeric():
state = int(state)
if 1 <= state <= 10:
got = await get_loop(chat_id)
if got != 0:
state = got + state
if int(state) > 10:
state = 10
await set_loop(chat_id, state)
return await message.reply_text(
_["admin_25"].format(
message.from_user.first_name, state
)
)
else:
return await message.reply_text(_["admin_26"])
elif state.lower() == "enable":
await set_loop(chat_id, 10)
return await message.reply_text(
_["admin_25"].format(message.from_user.first_name, state)
)
elif state.lower() == "disable":
await set_loop(chat_id, 0)
return await message.reply_text(_["admin_27"])
else:
return await message.reply_text(usage)