@@ -324,10 +324,10 @@ def _get_poll_display(self, poll_id, question, status, display, anonymous, multi
324
324
text += f'anonymous: { "Yes" if anonymous else "No" } \n '
325
325
text += f'multiple choice: { "Yes" if multiple_choice else "No" } \n '
326
326
327
- if status is not None :
327
+ if status :
328
328
text += f'status: { ["inactive" , "active" , "closed" ][status ]} \n '
329
329
330
- if display is not None :
330
+ if display :
331
331
text += f'{ "Results are shown" if display else "Results are hidden" } \n '
332
332
333
333
text += '\n '
@@ -400,10 +400,10 @@ def _get_options(args):
400
400
else :
401
401
arguments .append (arg .strip ())
402
402
403
- anonymous = int ( bool (options & ANONYM ) )
404
- multiple_choice = int ( bool (options & MULTIPLE ) )
405
- display = int ( bool (options & DISPLAY ) )
406
- start = int ( bool (options & START ) )
403
+ anonymous = bool (options & ANONYM )
404
+ multiple_choice = bool (options & MULTIPLE )
405
+ display = bool (options & DISPLAY )
406
+ start = bool (options & START )
407
407
408
408
return (arguments , err , (anonymous , multiple_choice , display , start ))
409
409
@@ -436,7 +436,7 @@ async def _new(args):
436
436
status = 1 if poll_id is None else 0
437
437
438
438
if display :
439
- await self .store .conn .execute ('UPDATE polls SET display = 0 ' )
439
+ await self .store .conn .execute ('UPDATE polls SET display = false ' )
440
440
441
441
poll_id = await self .store .conn .fetchval (
442
442
'''INSERT INTO polls (question, status, display, anonymous, multiple_choice)
@@ -486,7 +486,7 @@ async def _update(poll_id, args):
486
486
await send_text_to_room (self .client , self .room .room_id , f"Format Error: { err_message } " )
487
487
return
488
488
489
- if anonymous == 0 and multiple_choice == 0 and start == 0 and len (arguments ) == 0 and display == 1 : # only the display is changed
489
+ if not anonymous and not multiple_choice and not start and len (arguments ) == 0 and display == 1 : # only the display is changed
490
490
await self .store .conn .execute ('UPDATE polls SET display = CASE WHEN poll_id = $1 THEN 1 ELSE 0 END' , poll_id )
491
491
await send_text_to_room (self .client , self .room .room_id , f'Poll { poll_id } is now displayed. \n ' )
492
492
return
@@ -495,7 +495,7 @@ async def _update(poll_id, args):
495
495
496
496
if len (arguments ) <= 1 : # only update the question
497
497
if display :
498
- await self .store .conn .execute ('UPDATE polls SET display = 0 ' , poll_id )
498
+ await self .store .conn .execute ('UPDATE polls SET display = false ' , poll_id )
499
499
500
500
question = arguments [0 ] if len (arguments ) == 1 else question_db
501
501
@@ -749,7 +749,7 @@ async def _close():
749
749
await _close ()
750
750
751
751
elif self .args [0 ] == 'clear-display' :
752
- await self .store .conn .execute ('UPDATE polls SET display = 0 ' )
752
+ await self .store .conn .execute ('UPDATE polls SET display = false ' )
753
753
await send_text_to_room (self .client , self .room .room_id , "Display cleared." )
754
754
755
755
else :
0 commit comments