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