diff --git a/docker-compose.yml b/docker-compose.yml index 21b31ab..85a9bae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,10 @@ version: "3" services: - wallamanta-bot: + wallamanta-bot-multiuser: build: wallamanta - container_name: wallamanta-bot + image: wallamanta:multiuser + container_name: wallamanta-bot-multiuser volumes: - ./data:/app/data restart: unless-stopped diff --git a/wallamanta/helpers.py b/wallamanta/helpers.py index afa693c..3ca4c50 100644 --- a/wallamanta/helpers.py +++ b/wallamanta/helpers.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta #TELEGRAM_ESCAPE_CHARACTERS = ['_', '*', '[', ']', '(', ')', '~', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'] -TELEGRAM_ESCAPE_CHARACTERS = ['_', '*', '[', ']', '(', ')', '~', '>', '+', '-', '=', '|', '{', '}', '.', '!'] +TELEGRAM_ESCAPE_CHARACTERS = ['_', '*', '[', ']', '(', ')', '~', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'] ADMIN_IDS = [10101691] def telegram_escape_characters(text): diff --git a/wallamanta/walladb.py b/wallamanta/walladb.py index fd161bd..58c9990 100644 --- a/wallamanta/walladb.py +++ b/wallamanta/walladb.py @@ -62,7 +62,7 @@ def add_premium_user(telegram_user_id, until): cur.execute(f"INSERT INTO users VALUES ({telegram_user_id}, True, 'premium', '{until}')") con.commit() else: - cur.execute(f"UPDATE users SET active = True, type = 'premium', until = {until} WHERE telegram_user_id={telegram_user_id}") + cur.execute(f"UPDATE users SET active = True, type = 'premium', until = '{until}' WHERE telegram_user_id={telegram_user_id}") con.commit() found = True con.close() diff --git a/wallamanta/wallamanta.py b/wallamanta/wallamanta.py index ef56509..797d844 100644 --- a/wallamanta/wallamanta.py +++ b/wallamanta/wallamanta.py @@ -54,13 +54,13 @@ async def add_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> Non valid = False if walladb.is_user_testing(telegram_user_id): valid = True - if number_of_products > 5: - message = "Tienes más de 5 productos en seguimiento. Con premium puedes tener hasta 20." + if number_of_products >= 5: + message = "Ya tienes 5 productos en seguimiento. Con premium puedes tener hasta 20." valid = False elif walladb.is_user_premium(telegram_user_id): valid = True - if number_of_products > 20: - message = "Tienes más de 20 productos en seguimiento. Borra algunos para añadir más." + if number_of_products >= 20: + message = "Ya tienes 20 productos en seguimiento. Borra algunos para añadir más." valid = False if valid: args = update.message.text.split("/add ") @@ -135,10 +135,10 @@ async def admin_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N async def add_premium_user_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: if helpers.is_user_admin(update.message.chat_id): - telegram_user_id = update.message.text.split('/add_premium_user ')[1] - days = update.message.text.split('/add_premium_user ')[2] - until = helpers.get_date_ahead(days) - if walladb.add_premium_user(telegram_user_id, until): + telegram_user_id = update.message.text.split('/add_premium_user ')[1].split(' ')[0] + days = update.message.text.split('/add_premium_user ')[1].split(' ')[1] + until = helpers.get_date_ahead(int(days)) + if not walladb.add_premium_user(telegram_user_id, until): products = walladb.get_products_from_user(telegram_user_id) for product in products: diff --git a/wallamanta/worker.py b/wallamanta/worker.py index af2c2c3..6d657ff 100644 --- a/wallamanta/worker.py +++ b/wallamanta/worker.py @@ -23,7 +23,7 @@ logger = logging.getLogger(__name__) class Worker: - def is_valid_request(product): + def is_valid_request(self, product): is_valid = True if not walladb.get_product(product): is_valid = False