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

View File

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

13
main.py
View File

@ -1,3 +1,4 @@
import asyncio
from datetime import datetime from datetime import datetime
from threading import Thread from threading import Thread
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
@ -644,7 +645,7 @@ async def get_contact(app, msg):
@app.on_message(~ filters.scheduled & filters.private) @app.on_message(~ filters.scheduled & filters.private)
async def any_stage(app, msg): 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)) user_stage = configGet("stage", file=str(msg.from_user.id))
@ -703,6 +704,16 @@ async def any_stage(app, msg):
else: else:
if not configGet("approved", file=str(msg.from_user.id)) and not configGet("refused", file=str(msg.from_user.id)): 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")) 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() @app.on_inline_query()
async def inline_answer(client, 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( await inline_query.answer(
results=[ results=[
InlineQueryResultArticle( InlineQueryResultArticle(