using floats for timeout
This commit is contained in:
24
damnspam.py
24
damnspam.py
@@ -50,29 +50,29 @@ def onDammnspamCommand(sender, args):
|
|||||||
# /damnspam <secs>
|
# /damnspam <secs>
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
timeout_on = args[0]
|
timeout_on = args[0]
|
||||||
if not timeout_on.isdigit():
|
try:
|
||||||
msg(sender, "&cThe timeout must be a digit.")
|
timeout_on = round(float(timeout_on), 2)
|
||||||
return True
|
|
||||||
else:
|
|
||||||
timeout_on = int(timeout_on)
|
|
||||||
timeout_off = timeout_on
|
timeout_off = timeout_on
|
||||||
if not 0 <= timeout_on <= 60:
|
if not 0 <= timeout_on <= 60:
|
||||||
msg(sender, "&cThe timeout must be within 0-60.")
|
msg(sender, "&cThe timeout must be within 0-60.")
|
||||||
return True
|
return True
|
||||||
|
except ValueError:
|
||||||
|
msg(sender, "&cThe timeout must be a number")
|
||||||
|
return True
|
||||||
|
|
||||||
# /damnspam <off> <on>
|
# /damnspam <off> <on>
|
||||||
elif len(args) == 2:
|
elif len(args) == 2:
|
||||||
timeout_on = args[0]
|
timeout_on = args[0]
|
||||||
timeout_off = args[1]
|
timeout_off = args[1]
|
||||||
if not timeout_on.isdigit() or not timeout_off.isdigit():
|
try:
|
||||||
msg(sender, "&cThe timeout must be a digit.")
|
timeout_on = round(float(timeout_on), 2)
|
||||||
return True
|
timeout_off = round(float(timeout_off), 2)
|
||||||
else:
|
|
||||||
timeout_on = int(timeout_on)
|
|
||||||
timeout_off = int(timeout_off)
|
|
||||||
if not 0 <= timeout_on <= 60 or not 0 <= timeout_off <= 60:
|
if not 0 <= timeout_on <= 60 or not 0 <= timeout_off <= 60:
|
||||||
msg(sender, "&cThe timeout must be within 0-60.")
|
msg(sender, "&cThe timeout must be within 0-60.")
|
||||||
return True
|
return True
|
||||||
|
except ValueError:
|
||||||
|
msg(sender, "&cThe timeout must be a number")
|
||||||
|
return True
|
||||||
|
|
||||||
# get the block we're looking at
|
# get the block we're looking at
|
||||||
target = sender.getTargetBlock(None, 10)
|
target = sender.getTargetBlock(None, 10)
|
||||||
@@ -130,4 +130,4 @@ def onInteract(event):
|
|||||||
plugHeader(sender, "DamnSpam")
|
plugHeader(sender, "DamnSpam")
|
||||||
msg(sender, "&cThis %s has a timeout of %ss." % (btype, checktime))
|
msg(sender, "&cThis %s has a timeout of %ss." % (btype, checktime))
|
||||||
else:
|
else:
|
||||||
inputs[pos_str]["last_time"] = int(now())
|
inputs[pos_str]["last_time"] = round(now(), 2)
|
||||||
Reference in New Issue
Block a user