mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-10 22:26:23 +02:00
Update DiceObserver.py
Exception handling
This commit is contained in:
@@ -27,8 +27,16 @@ class DiceObserver(PrivMsgObserverPrototype):
|
||||
dice_sides = (data['message'].split(' ')[found_at_index + 1])
|
||||
if dice_sides.isdigit():
|
||||
dice_sides = int(dice_sides)
|
||||
if dice_sides == 0:
|
||||
connection.send_back(data['nick'] + ' wirft einen 0-seitigen Würfel und bekommt Unendlich.', data)
|
||||
return
|
||||
elif dice_sides < 0:
|
||||
connection.send_back(data['nick'] + ' wirft einen ' + str(dice_sides) + '-seitigen Würfel und nichts passiert.', data)
|
||||
return
|
||||
else:
|
||||
dice_sides = 6
|
||||
|
||||
result = random.randint(1, dice_sides)
|
||||
|
||||
connection.send_back(data['nick'] + ' wirft einen ' + str(dice_sides) + '-seitigen Würfel und bekommt ' + str(result), data)
|
||||
|
||||
Reference in New Issue
Block a user