Skip to content

Commit b6d9190

Browse files
authored
Merge branch 'master' into cantidad_de_votos_por_proyecto
2 parents 3b251fa + d16331b commit b6d9190

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/pycamp_bot/commands/projects.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,14 @@ async def project_topic(update, context):
118118
user = Pycampista.get_or_create(username=username, chat_id=chat_id)[0]
119119

120120
new_project.owner = user
121-
122-
new_project.save()
121+
try:
122+
new_project.save()
123+
except peewee.IntegrityError:
124+
await context.bot.send_message(
125+
chat_id=update.message.chat_id,
126+
text="Ups ese proyecto ya fue cargado"
127+
)
128+
return ConversationHandler.END
123129

124130
await context.bot.send_message(
125131
chat_id=update.message.chat_id,
@@ -196,7 +202,6 @@ async def show_projects(update, context):
196202
if participants_count > 0:
197203
project_text += "\n Interesades: {}".format(participants_count)
198204
text.append(project_text)
199-
text.append(project_text)
200205

201206
if text:
202207
text = "\n\n".join(text)

src/pycamp_bot/commands/voting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async def wrap(*args):
1919
if pycamp.vote_authorized:
2020
await func(update, context)
2121
else:
22-
context.bot.send_message(
22+
await context.bot.send_message(
2323
chat_id=update.message.chat_id,
2424
text="La eleccion no está autorizada. Avisale a un admin (/admins)!")
2525
return wrap

src/pycamp_bot/commands/wizard.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from telegram.ext import CommandHandler
22
from pycamp_bot.models import Pycampista
3+
import random
34

45

56
async def become_wizard(update, context):
@@ -24,19 +25,23 @@ async def become_wizard(update, context):
2425

2526
async def summon_wizard(update, context):
2627
username = update.message.from_user.username
27-
try:
28-
wizard = Pycampista.get(Pycampista.wizard is True)
28+
wizard_list = list(Pycampista.select().where(Pycampista.wizard==True))
29+
if len(wizard_list) == 0:
30+
await context.bot.send_message(
31+
chat_id=update.message.chat_id,
32+
text="No hay ningunx magx todavia"
33+
)
34+
else:
35+
wizard = random.choice(wizard_list)
2936
await context.bot.send_message(
3037
chat_id=wizard.chat_id,
3138
text="PING PING PING MAGX! @{} te necesesita!".format(username)
3239
)
33-
except Pycampista.DoesNotExist:
3440
await context.bot.send_message(
35-
chat_id=update.chat_id,
36-
text="Hubo un accidente, el mago esta en otro plano.".format(username)
41+
chat_id=update.message.chat_id,
42+
text="Tu magx asignadx es: @{}".format(wizard.username)
3743
)
3844

39-
4045
def set_handlers(application):
4146
application.add_handler(
4247
CommandHandler('evocar_magx', summon_wizard))

0 commit comments

Comments
 (0)