summaryrefslogtreecommitdiff
path: root/damnspam.py
diff options
context:
space:
mode:
authorjomo <github@jomo.tv>2014-07-14 05:57:27 +0200
committerjomo <github@jomo.tv>2014-07-14 05:57:27 +0200
commit4df5a18831d301539aca5f1c3f30beb5a3c1e1ef (patch)
tree3bbcac3d2f03ab0231f49956a07c1bc74783e055 /damnspam.py
parent502aa3acc5315e1942a50c0c756e379b5dd9704c (diff)
using floats for timeout
Diffstat (limited to 'damnspam.py')
-rw-r--r--damnspam.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/damnspam.py b/damnspam.py
index b06848e..9f8698e 100644
--- a/damnspam.py
+++ b/damnspam.py
@@ -50,29 +50,29 @@ def onDammnspamCommand(sender, args):
# /damnspam <secs>
if len(args) == 1:
timeout_on = args[0]
- if not timeout_on.isdigit():
- msg(sender, "&cThe timeout must be a digit.")
- return True
- else:
- timeout_on = int(timeout_on)
+ try:
+ timeout_on = round(float(timeout_on), 2)
timeout_off = timeout_on
if not 0 <= timeout_on <= 60:
msg(sender, "&cThe timeout must be within 0-60.")
return True
+ except ValueError:
+ msg(sender, "&cThe timeout must be a number")
+ return True
# /damnspam <off> <on>
elif len(args) == 2:
timeout_on = args[0]
timeout_off = args[1]
- if not timeout_on.isdigit() or not timeout_off.isdigit():
- msg(sender, "&cThe timeout must be a digit.")
- return True
- else:
- timeout_on = int(timeout_on)
- timeout_off = int(timeout_off)
+ try:
+ timeout_on = round(float(timeout_on), 2)
+ timeout_off = round(float(timeout_off), 2)
if not 0 <= timeout_on <= 60 or not 0 <= timeout_off <= 60:
msg(sender, "&cThe timeout must be within 0-60.")
return True
+ except ValueError:
+ msg(sender, "&cThe timeout must be a number")
+ return True
# get the block we're looking at
target = sender.getTargetBlock(None, 10)
@@ -130,4 +130,4 @@ def onInteract(event):
plugHeader(sender, "DamnSpam")
msg(sender, "&cThis %s has a timeout of %ss." % (btype, checktime))
else:
- inputs[pos_str]["last_time"] = int(now()) \ No newline at end of file
+ inputs[pos_str]["last_time"] = round(now(), 2) \ No newline at end of file