Refactor bot handlers and keyboards; implement admin features
- Removed unused prehandling, referrals, support, and states files. - Updated admin and client handlers to improve structure and functionality. - Introduced admin filters and routers for better access control. - Added new billing and deposit functionalities for client interactions. - Enhanced keyboard layouts for admin and client menus. - Implemented promotion handling for admin users. - Updated configuration to include admin settings. - Improved utility functions for quote fetching and menu text building. - Added common handlers for undefined commands and message deletions.
This commit is contained in:
@@ -14,6 +14,7 @@ from repositories.subscriptions import SubscriptionRepository
|
||||
from schemas.subscriptions import InternalSquads, SubscriptionPlan, SubscriptionStatus
|
||||
from schemas.users import NewUserDTO
|
||||
from services import rw
|
||||
from config import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -220,3 +221,22 @@ class UserService:
|
||||
|
||||
remaining_days = max(0, (rw_user.expire_at - datetime.datetime.now(datetime.UTC)).days)
|
||||
return math.floor(db_sub.plan_price_paid * remaining_days / db_sub.duration_days)
|
||||
|
||||
async def launch_promotion(
|
||||
self,
|
||||
session: AsyncSession,
|
||||
promo_msg: Message
|
||||
) -> int:
|
||||
users = await self.user_repository.get_users(session)
|
||||
|
||||
sent = 0
|
||||
for user in users:
|
||||
if user.id in settings.admins:
|
||||
continue
|
||||
try:
|
||||
await promo_msg.copy_to(user.id)
|
||||
sent += 1
|
||||
except Exception:
|
||||
logger.exception("caught an exception while launching promo, skipping user...")
|
||||
|
||||
return sent
|
||||
Reference in New Issue
Block a user