diff --git a/src/spotted/config/db/post_db_init.sql b/src/spotted/config/db/post_db_init.sql index 5339cdd9..14d1e9a7 100644 --- a/src/spotted/config/db/post_db_init.sql +++ b/src/spotted/config/db/post_db_init.sql @@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS warned_users ( user_id BIGINT NOT NULL, warn_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - valid_until_date TIMESTAMP NOT NULL, + expire_date TIMESTAMP NOT NULL, PRIMARY KEY (user_id, warn_date) ); ----- @@ -91,5 +91,5 @@ CREATE TRIGGER IF NOT EXISTS drop_old_warns BEFORE INSERT ON warned_users FOR EACH ROW BEGIN -DELETE FROM warned_users WHERE user_id=NEW.user_id and valid_until_date < DATETIME('now'); +DELETE FROM warned_users WHERE user_id=NEW.user_id and expire_date < DATETIME('now'); END; \ No newline at end of file diff --git a/src/spotted/data/user.py b/src/spotted/data/user.py index 6fa2be3d..1308baa8 100644 --- a/src/spotted/data/user.py +++ b/src/spotted/data/user.py @@ -166,14 +166,14 @@ async def unmute(self, bot: Bot | None): def warn(self): """Increase the number of warns of a user - If this is number would reach 3 the user is banned + If the number of warns is greater than the maximum allowed, the user is banned Args: bot: the telegram bot """ valid_until_date = datetime.now() + timedelta(days=Config.post_get("warn_expiration_days")) DbManager.insert_into( - table_name="warned_users", columns=("user_id", "valid_until_date"), values=(self.user_id, valid_until_date) + table_name="warned_users", columns=("user_id", "expire_date"), values=(self.user_id, valid_until_date) ) def become_anonym(self) -> bool: diff --git a/src/spotted/handlers/mute.py b/src/spotted/handlers/mute.py index 5ec79810..22ba0e08 100644 --- a/src/spotted/handlers/mute.py +++ b/src/spotted/handlers/mute.py @@ -30,12 +30,13 @@ async def mute_cmd(update: Update, context: CallbackContext): except ValueError: pass user = User(g_message.from_user.id) + mute_days_text = f"{days} giorn{'o' if days == 1 else 'i'}" await user.mute(info.bot, days) await info.bot.send_message( chat_id=Config.post_get("admin_group_id"), - text=f"L'utente {user.user_id} è stato mutato per {days} giorn{'o' if days == 1 else 'i'}.", + text=f"L'utente {user.user_id} è stato mutato per {mute_days_text}.", ) await info.bot.send_message( - chat_id=user.user_id, text=f"Sei stato mutato da Spotted DMI" f"per {days} giorn{'o' if days == 1 else 'i'}" + chat_id=user.user_id, text=f"Sei stato mutato da Spotted DMI per {mute_days_text}." ) await info.message.delete()