Chatbot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
790 B

2 years ago
import time
2 years ago
class Event:
2 years ago
def __init__(self, time_start, time_stop, chance, command):
self.time_start = time_start
self.time_stop = time_stop
2 years ago
self.chance = chance
2 years ago
self.command = command
2 years ago
self.executed = 0
def __str__(self):
2 years ago
return str("Event starting at timestamp {}".format(self.time_start))
def loop(self, bot):
if time.time() - bot.timestamp >= self.time_start:
if time.time() - bot.timestamp < self.time_stop:
self.execute()
elif (self.time_stop == 0 or self.time_stop == self.time_start) and self.executed == 0:
self.execute()
def execute(self, bot):
if self.command.startswith('printtime'):
print(time.time())
self.executed += 1