Skip to content

Commit 781a5ef

Browse files
authored
Merge pull request #36 from MakelMagus/Modified_Vote_to_Choose
Modified vote to choose
2 parents fc66f3d + 6afdee5 commit 781a5ef

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

src/pycamp_bot/commands/voting.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ def wrap(*args, **kargs):
2424
else:
2525
bot.send_message(
2626
chat_id=update.message.chat_id,
27-
text="La votacion no está autorizada. Avisale a un admin\
27+
text="La eleccion no está autorizada. Avisale a un admin\
2828
(/admins)!")
2929
return wrap
3030

3131

3232
@admin_needed
3333
@active_needed
3434
def start_voting(bot, update):
35-
logger.info("Empezando la votacion")
35+
logger.info("Empezando la seleccion.")
3636

3737
is_active, pycamp = get_active_pycamp()
3838

3939
if not pycamp.vote_authorized:
4040
pycamp.vote_authorized = True
4141
pycamp.save()
42-
update.message.reply_text("Autorizadx \nVotación Abierta")
43-
msg_to_active_pycamp_chat(bot, "La Votación esta abierta")
42+
update.message.reply_text("Autorizadx. \nSelección Abierta.")
43+
msg_to_active_pycamp_chat(bot, "La elección de proyectos esta abierta!")
4444
else:
45-
update.message.reply_text("La votacion ya estaba abierta")
45+
update.message.reply_text("La eleccion ya estaba abierta.")
4646

4747

4848
def button(bot, update):
@@ -60,34 +60,31 @@ def button(bot, update):
6060
new_vote = Vote(
6161
pycampista=user,
6262
project=project,
63-
_project_pycampista_id="{}-{}".format(project.id, user.id),
63+
_project_pycampista_id=f"{project.id}-{user.id}"
6464
)
6565

66-
# Save vote in the database and send a message
66+
# Save vote in the database and confirm the chosen proyects.
67+
6768
if query.data == "si":
68-
result = 'Interesadx en: ' + project_name + ' 👍'
69+
result = f"✅ Sumade a {project_name}!"
6970
new_vote.interest = True
7071
else:
7172
new_vote.interest = False
72-
result = 'No te interesa el proyecto ' + project_name
73+
result = f'❌ Proyecto {project_name} salteado.'
7374

7475
try:
7576
new_vote.save()
7677
bot.edit_message_text(text=result,
7778
chat_id=query.message.chat_id,
7879
message_id=query.message.message_id)
7980
except peewee.IntegrityError:
80-
logger.warning("Error al guardar el voto de {} del proyecto {}".format(
81-
username,
82-
project_name
83-
))
81+
logger.warning(f"Error al guardar la eleccion de {username} en el proyecto {project_name}")
8482
bot.edit_message_text(
85-
text="Ya habías votado el proyecto {}!!".format(project_name),
83+
text=f"Ya te habías sumado al proyecto {project_name}!",
8684
chat_id=query.message.chat_id,
8785
message_id=query.message.message_id
8886
)
8987

90-
9188
@vote_authorized
9289
def vote(bot, update):
9390
logger.info("Vote message")
@@ -102,8 +99,8 @@ def vote(bot, update):
10299

103100
# ask user for each project in the database
104101
for project in Project.select():
105-
keyboard = [[InlineKeyboardButton("Si!", callback_data="si"),
106-
InlineKeyboardButton("Nop", callback_data="no")]]
102+
keyboard = [[InlineKeyboardButton("Me Sumo!", callback_data="si"),
103+
InlineKeyboardButton("Paso", callback_data="no")]]
107104

108105
reply_markup = InlineKeyboardMarkup(keyboard)
109106

@@ -121,16 +118,16 @@ def end_voting(bot, update):
121118

122119
pycamp.vote_authorized = False
123120
pycamp.save()
124-
update.message.reply_text("Votación cerrada")
125-
msg_to_active_pycamp_chat(bot, "La Votación esta cerrada")
121+
update.message.reply_text("Selección cerrada")
122+
msg_to_active_pycamp_chat(bot, "La selección de proyectos ha finalizado.")
126123

127124

128125
def set_handlers(updater):
129126
updater.dispatcher.add_handler(
130127
CallbackQueryHandler(button))
131128
updater.dispatcher.add_handler(
132-
CommandHandler('empezar_votacion', start_voting))
129+
CommandHandler('empezar_seleccion_proyectos', start_voting))
133130
updater.dispatcher.add_handler(
134-
CommandHandler('votar', vote))
131+
CommandHandler('elegir_proyectos', vote))
135132
updater.dispatcher.add_handler(
136-
CommandHandler('terminar_votacion', end_voting))
133+
CommandHandler('terminar_seleccion_proyectos', end_voting))

0 commit comments

Comments
 (0)