This commit closes #9
This commit is contained in:
@@ -72,6 +72,5 @@ async def callback_verify(app: PyroClient, callback: CallbackQuery):
|
||||
kick_unverified,
|
||||
"date",
|
||||
[app, user.id, group.id, captcha_message.id],
|
||||
run_date=datetime.now()
|
||||
+ timedelta(seconds=app.config["timeouts"]["verify"]),
|
||||
run_date=datetime.now() + timedelta(seconds=group.timeout_verify),
|
||||
)
|
||||
|
55
plugins/commands/timeout_join.py
Normal file
55
plugins/commands/timeout_join.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import logging
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.enums.chat_member_status import ChatMemberStatus
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from classes.pyrogroup import PyroGroup
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled
|
||||
& filters.group
|
||||
& filters.command(["timeout_join"], prefixes=["/"]) # type: ignore
|
||||
)
|
||||
async def command_timeout_join(app: PyroClient, message: Message):
|
||||
group = await PyroGroup.create_if_not_exists(message.chat.id, None, True)
|
||||
locale = group.select_locale(app, message.from_user)
|
||||
|
||||
if (await app.get_chat_member(group.id, message.from_user.id)).status not in [
|
||||
ChatMemberStatus.ADMINISTRATOR,
|
||||
ChatMemberStatus.OWNER,
|
||||
]:
|
||||
await message.reply_text(
|
||||
app._("permission_denied", "messages", locale=locale), quote=True
|
||||
)
|
||||
return
|
||||
|
||||
if len(message.command) < 2 or not message.command[1].isdigit():
|
||||
await message.reply_text(
|
||||
app._("timeout_join_invalid", "messages", locale=locale), quote=True
|
||||
)
|
||||
return
|
||||
|
||||
timeout = int(message.command[1])
|
||||
|
||||
if timeout < 10 or timeout > 600:
|
||||
await message.reply_text(
|
||||
app._("timeout_invalid_number", "messages", locale=locale), quote=True
|
||||
)
|
||||
return
|
||||
|
||||
await message.reply_text(
|
||||
app._("timeout_join_set", "messages", locale=locale).format(timeout=timeout)
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Timeout on join in group %s has been set to %s",
|
||||
group.id,
|
||||
timeout,
|
||||
)
|
||||
|
||||
await group.set_timeout_join(timeout)
|
55
plugins/commands/timeout_verify.py
Normal file
55
plugins/commands/timeout_verify.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import logging
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.enums.chat_member_status import ChatMemberStatus
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from classes.pyrogroup import PyroGroup
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled
|
||||
& filters.group
|
||||
& filters.command(["timeout_verify"], prefixes=["/"]) # type: ignore
|
||||
)
|
||||
async def command_timeout_verify(app: PyroClient, message: Message):
|
||||
group = await PyroGroup.create_if_not_exists(message.chat.id, None, True)
|
||||
locale = group.select_locale(app, message.from_user)
|
||||
|
||||
if (await app.get_chat_member(group.id, message.from_user.id)).status not in [
|
||||
ChatMemberStatus.ADMINISTRATOR,
|
||||
ChatMemberStatus.OWNER,
|
||||
]:
|
||||
await message.reply_text(
|
||||
app._("permission_denied", "messages", locale=locale), quote=True
|
||||
)
|
||||
return
|
||||
|
||||
if len(message.command) < 2 or not message.command[1].isdigit():
|
||||
await message.reply_text(
|
||||
app._("timeout_verify_invalid", "messages", locale=locale), quote=True
|
||||
)
|
||||
return
|
||||
|
||||
timeout = int(message.command[1])
|
||||
|
||||
if timeout < 10 or timeout > 600:
|
||||
await message.reply_text(
|
||||
app._("timeout_invalid_number", "messages", locale=locale), quote=True
|
||||
)
|
||||
return
|
||||
|
||||
await message.reply_text(
|
||||
app._("timeout_verify_set", "messages", locale=locale).format(timeout=timeout)
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Verification timeout in group %s has been set to %s",
|
||||
group.id,
|
||||
timeout,
|
||||
)
|
||||
|
||||
await group.set_timeout_verify(timeout)
|
Reference in New Issue
Block a user