Skip to content

Commit c1e24c4

Browse files
committed
added count_votes
1 parent 0c1b70e commit c1e24c4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/pycamp_bot/commands/voting.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,13 @@ async def end_voting(update, context):
118118
await update.message.reply_text("Selección cerrada")
119119
await msg_to_active_pycamp_chat(context.bot, "La selección de proyectos ha finalizado.")
120120

121-
#def vote_count(update, context):
122-
121+
async def vote_count(update, context):
122+
votes = [vote.pycampista_id for vote in Vote.select()]
123+
vote_count = len(set(votes))
124+
await context.bot.send_message(
125+
chat_id=update.message.chat_id,
126+
text=f"Votaron: {vote_count}"
127+
)
123128

124129

125130
def set_handlers(application):
@@ -131,5 +136,5 @@ def set_handlers(application):
131136
CommandHandler('votar', vote))
132137
application.add_handler(
133138
CommandHandler('terminar_votacion_proyectos', end_voting))
134-
# application.add_handler(
135-
# CommandHandler('contar_votos', vote_count))
139+
application.add_handler(
140+
CommandHandler('contar_votos', vote_count))

0 commit comments

Comments
 (0)