From 74dfdb580d6a901924694dafec8fe976dc944a71 Mon Sep 17 00:00:00 2001
From: shillingp
Date: Fri, 19 Dec 2014 23:28:33 +0000
Subject: [PATCH] Added support for damnspam -1 time arguments
---
damnspam.py | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/damnspam.py b/damnspam.py
index e4d7a61..e74702d 100644
--- a/damnspam.py
+++ b/damnspam.py
@@ -43,8 +43,10 @@ def on_dammnspam_command(sender, args):
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.")
+ if 60 >= timeout_on <= -2 or timeout_on == 0:
+ timeout_on = False
+ if timeout_on == False:
+ msg(sender, "&cThe timeout must be within 0-60 or -1.")
return True
except ValueError:
msg(sender, "&cThe timeout must be a number")
@@ -57,8 +59,12 @@ def on_dammnspam_command(sender, args):
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.")
+ if 60 >= timeout_on <= -2 or timeout_on == 0:
+ timeout_on = False
+ if 60 >= timeout_off <= -2 or timeout_off == 0:
+ timeout_off = False
+ if timeout_on == False or timeout_off == False:
+ msg(sender, "&cThe timeout must be within 0-60 or -1.")
return True
except ValueError:
msg(sender, "&cThe timeout must be a number")
@@ -137,9 +143,13 @@ def on_interact(event):
data = inputs.get(pos_str)
if data:
checktime = data["timeout_on"] if powered else data["timeout_off"]
- if data["last_time"] + checktime > now():
+ if checktime == -1:
+ event.setCancelled(True)
+ plugin_header(sender, "DamnSpam")
+ msg(sender, "&cThis %s is locked permanently." % (btype))
+ elif data["last_time"] + checktime > now():
event.setCancelled(True)
plugin_header(sender, "DamnSpam")
msg(sender, "&cThis %s has a timeout of %ss." % (btype, checktime))
else:
- inputs[pos_str]["last_time"] = round(now(), 2)
\ No newline at end of file
+ inputs[pos_str]["last_time"] = round(now(), 2)