├── README.md ├── bot.py ├── config.py └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | # CheckedUser_bot 2 | 3 | ## Change BOT_TOKEN and GROUP_ID in config.py 4 | 5 | ### [+] Create venv 6 | ```python -m venv venv``` 7 | 8 | ##### Activate venv 9 | 10 | - For Debian (Ubuntu, Kali-Linux, Parrot) 11 | 12 | ```source venv/bin/activate``` 13 | 14 | - For Windows 15 | 16 | ```venv/Scripts/activate``` 17 | 18 | 19 | ### [*]Install library 20 | 21 | ```pip install -r requirements.txt``` 22 | 23 | ### [*] Run Bot 24 | 25 | ```python bot.py ``` 26 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from aiogram import Bot, Dispatcher, types 3 | from aiogram.types import ParseMode 4 | from aiogram.contrib.middlewares.logging import LoggingMiddleware 5 | from aiogram.utils import executor 6 | from datetime import datetime, timedelta 7 | from config import TOKEN_v2, GROUP_ID 8 | 9 | 10 | bot = Bot(token=TOKEN_v2) 11 | dp = Dispatcher(bot) 12 | dp.middleware.setup(LoggingMiddleware()) 13 | 14 | USER_ACTIVITY = {} 15 | 16 | async def check_user_activity(): 17 | while True: 18 | current_time = datetime.now() 19 | for user_id, last_message_time in list(USER_ACTIVITY.items()): 20 | if current_time - last_message_time > timedelta(hours=24): 21 | try: 22 | await bot.kick_chat_member(chat_id=GROUP_ID, user_id=user_id) 23 | del USER_ACTIVITY[user_id] 24 | print(f"User {user_id} kicked for inactivity") 25 | except Exception as e: 26 | print(f"Error kicking user {user_id}: {e}") 27 | await asyncio.sleep(1) 28 | 29 | 30 | @dp.message_handler(commands=['start']) 31 | async def send_welcome(message: types.Message): 32 | USER_ACTIVITY[message.from_user.id] = datetime.now() 33 | await message.reply("Salom! Bu bot orqali sizni kuzatib boraman!") 34 | 35 | 36 | 37 | @dp.message_handler() 38 | async def track_activity(message: types.Message): 39 | USER_ACTIVITY[message.from_user.id] = datetime.now() 40 | 41 | if __name__ == '__main__': 42 | loop = asyncio.get_event_loop() 43 | loop.create_task(check_user_activity()) 44 | 45 | executor.start_polling(dp, skip_updates=True) 46 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | TOKEN_v2 = "YOUR_BOT_TOKEN" 2 | GROUP_ID = "YOUR_GROUP_ID" -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiogram==2.25.1 2 | aiohttp==3.8.6 3 | aiosignal==1.3.2 4 | async-timeout==4.0.3 5 | attrs==25.1.0 6 | Babel==2.9.1 7 | certifi==2025.1.31 8 | charset-normalizer==3.4.1 9 | frozenlist==1.5.0 10 | idna==3.10 11 | magic-filter==1.0.12 12 | multidict==6.1.0 13 | propcache==0.2.1 14 | pytz==2025.1 15 | typing_extensions==4.12.2 16 | yarl==1.18.3 17 | --------------------------------------------------------------------------------