Added auto-removal of applications in group

This commit is contained in:
Profitroll 2022-12-01 11:06:54 +01:00
parent 0fcd67d322
commit 97325b4ff5
4 changed files with 17 additions and 4 deletions

View File

@ -2,6 +2,7 @@
"locale": "uk",
"debug": false,
"owner": 0,
"bot_id": 0,
"age_allowed": 0,
"birthdays_notify": true,
"birthdays_time": "09:00",
@ -9,6 +10,7 @@
"inline_preview_count": 7,
"admin_group": 0,
"destination_group": 0,
"remove_application_time": -1,
"admins": [],
"bot": {
"api_id": 0,

View File

@ -138,8 +138,8 @@
},
"not_pm": {
"title": "Дія недоступна",
"description": "Ця команда доступна тільки в приватних повідомленнях в чаті з самим ботом",
"message_content": "Дія доступна тільки в ПП."
"description": "Ця команда недоступна в каналах",
"message_content": "Дія недоступна в каналах."
},
"user": {
"title": "",

13
main.py
View File

@ -1,3 +1,4 @@
import asyncio
from datetime import datetime
from threading import Thread
from dateutil.relativedelta import relativedelta
@ -644,7 +645,7 @@ async def get_contact(app, msg):
@app.on_message(~ filters.scheduled & filters.private)
async def any_stage(app, msg):
if msg.via_bot == None:
if msg.via_bot is None:
user_stage = configGet("stage", file=str(msg.from_user.id))
@ -703,6 +704,16 @@ async def any_stage(app, msg):
else:
if not configGet("approved", file=str(msg.from_user.id)) and not configGet("refused", file=str(msg.from_user.id)):
await msg.reply_text(locale("already_sent", "message"))
@app.on_message(~ filters.scheduled & filters.group)
async def message_in_group(app, msg):
if (msg.chat is not None) and (msg.via_bot is not None):
if (msg.via_bot.id == configGet("bot_id")) and (msg.chat.id == configGet("destination_group")):
if configGet("remove_application_time") > 0:
logWrite(f"User {msg.from_user.id} requested application in destination group, removing in {configGet('remove_application_time')} minutes")
await asyncio.sleep(configGet("remove_application_time")*60)
await msg.delete()
logWrite(f"Removed application requested by {msg.from_user.id} in destination group")
# ==============================================================================================================================

View File

@ -11,7 +11,7 @@ from modules.utils import configGet, jsonLoad, locale
@app.on_inline_query()
async def inline_answer(client, inline_query):
if inline_query.chat_type not in [ChatType.BOT, ChatType.PRIVATE]:
if inline_query.chat_type in [ChatType.CHANNEL]:
await inline_query.answer(
results=[
InlineQueryResultArticle(