bot enabled exp

This commit is contained in:
Administrator 2024-02-18 00:48:29 +03:00
parent 86a3b891f1
commit 0e07ebdc61
3 changed files with 18 additions and 18 deletions

View File

@ -3,9 +3,7 @@ import os
import telebot
from telebot.types import Message
import settings
from helpers.mongo import mongo
from helpers.sprint_platform import platform
bot = telebot.TeleBot(os.getenv("TELEGRAM_TOKEN"))
@ -18,7 +16,5 @@ def on_start(message: Message):
@bot.message_handler()
def do_action(message: Message):
if settings.STAGE == 'development' and not platform.is_staff(telegram_id=message.chat.id):
return
from helpers.answer import Answer
Answer(message).process()

View File

@ -14,6 +14,15 @@ from helpers.sprint_platform import platform
from helpers.ruz import ruz
class User:
def __init__(self, telegram_id):
self.telegram_id = telegram_id
@property
def platform_staff(self):
return platform.is_staff(telegram_id=self.telegram_id)
class Answer:
user: dict
@ -43,6 +52,14 @@ class Answer:
self.user = user
def process(self):
user = User(self.user['chat_id'])
try:
bot_enabled_exp = platform.get_experiment('bot_enabled')
if not bot_enabled_exp['enabled'] or not eval(bot_enabled_exp['condition']):
return
except Exception as exc:
logging.info(exc)
return
getattr(
self,
"handle_state_" + self.user['state'],
@ -148,14 +165,6 @@ class Answer:
alice_exp = platform.get_experiment('alice')
telegram_id = self.user['chat_id']
try:
class User:
def __init__(self, telegram_id):
self.telegram_id = telegram_id
@property
def platform_staff(self):
return platform.is_staff(telegram_id=self.telegram_id)
user = User(telegram_id)
alice_exp_enabled = alice_exp['enabled'] and eval(alice_exp['condition'])
except Exception as exc:

View File

@ -13,12 +13,7 @@ def main_keyboard(telegram_id):
kb.row("Ежедневные уведомления")
alice_exp = platform.get_experiment('alice')
try:
class User:
def __init__(self, telegram_id):
self.telegram_id = telegram_id
@property
def platform_staff(self):
return platform.is_staff(telegram_id=self.telegram_id)
from helpers.answer import User
user = User(telegram_id)
alice_exp_enabled = alice_exp['enabled'] and eval(alice_exp['condition'])
except Exception as exc: