Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. from datetime import datetime
  2. x=datetime.now().strftime('%M') # Current time in mins can be changed ('%Y-%m-%d %H:%M:%S')
  3. spam_count=[] # Holds up to two values, the values are the current time when p was pressed
  4. def anti_spam(key_pressed):
  5. try:
  6. if key_pressed == "p" and len(spam_count) <= 2: # If key pressed is p and spam count is less or equal to #2
  7. spam_count.append(x) # Append current time in mins to spam count // You can get hours days etc ('%Y-%m-%d %H:%M:%S')
  8. if int(spam_count[1]) <= int(x)+5: # If the time from when the seccond p key was pressed is less or equal to current time + 5 mins
  9. print("Spamming 5 min cool down") # Print Spam
  10. else:
  11. print("Not Spamming") # Else if its been 5 mins Clear the spam_count and restart
  12. spam_count.clear()
  13. except IndexError:
  14. pass
  15. print(f"You Pressed: {key_pressed}")
  16.  
  17. while 1 == 1: # This is just a infinate loop, Like how the game should be running i would expect
  18. anti_spam(input()) # Calls the function requiers a input or char
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement