mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-11 06:36:24 +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])
|
dice_sides = (data['message'].split(' ')[found_at_index + 1])
|
||||||
if dice_sides.isdigit():
|
if dice_sides.isdigit():
|
||||||
dice_sides = int(dice_sides)
|
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:
|
else:
|
||||||
dice_sides = 6
|
dice_sides = 6
|
||||||
|
|
||||||
result = random.randint(1, dice_sides)
|
result = random.randint(1, dice_sides)
|
||||||
|
|
||||||
connection.send_back(data['nick'] + ' wirft einen ' + str(dice_sides) + '-seitigen Würfel und bekommt ' + str(result), data)
|
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