diff --git a/main.py b/main.py index bcc0e8a..31b2e34 100644 --- a/main.py +++ b/main.py @@ -63,8 +63,8 @@ class VotingSystem: self.votes[command][user_uuid] = current_time vote_count = len(self.votes[command]) - # Check if we just reached the threshold - newly_passed = vote_count >= self.REQUIRED_VOTES and not already_voted + # Check if we just reached the threshold (exactly equals, not >=) + newly_passed = vote_count == self.REQUIRED_VOTES and not already_voted return vote_count, newly_passed @@ -262,7 +262,9 @@ async def trigger_command(message_content, recipient, user_uuid=None): async def handle_voting_command(command, user_uuid, recipient): """Handle commands that require voting.""" global last_command_time, warning_sent - vote_count, newly_passed = voting_system.add_vote("traps", user_uuid) + # Use a normalized command key for voting (both !trap and !traps map to same vote) + vote_key = "traps" + vote_count, newly_passed = voting_system.add_vote(vote_key, user_uuid) required = VotingSystem.REQUIRED_VOTES timeout = VotingSystem.VOTE_TIMEOUT_MINUTES @@ -277,13 +279,13 @@ async def handle_voting_command(command, user_uuid, recipient): send_message(f"Głosowanie zakończone! ({vote_count}/{required}) Wysyłam obrazek...", recipient) await send_trap_image(recipient) - voting_system.reset_votes("traps") + voting_system.reset_votes(vote_key) last_command_time = current_time warning_sent = False elif vote_count >= required: # Already passed in a previous vote, just inform send_message("Już wysłano obrazek. Głosowanie zresetowane.", recipient) - voting_system.reset_votes("traps") + voting_system.reset_votes(vote_key) else: remaining_votes = required - vote_count send_message(