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.
27 lines
986 B
27 lines
986 B
import time
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Event:
|
|
def __init__(self, tick_start, tick_stop, chance, repeat, command):
|
|
self.tick_start = tick_start
|
|
self.tick_stop = tick_stop
|
|
self.chance = chance
|
|
self.repeat = repeat
|
|
self.command = command
|
|
self.executed = 0
|
|
def __str__(self):
|
|
return str("Event starting at time {}".format(self.tick_start))
|
|
def loop(self, bot, tick):
|
|
if tick >= self.tick_start:
|
|
if tick < self.tick_stop:
|
|
self.execute(bot, tick)
|
|
elif (self.tick_stop == 0 or self.tick_stop == self.tick_start) and self.executed == 0:
|
|
self.execute(bot, tick)
|
|
def execute(self, bot, tick):
|
|
logger.info("event executed for " + bot.name + ". current tick: " + str(tick) + " event: " + str(self.command))
|
|
if self.command.startswith('printtime'):
|
|
print(time.time()//1000)
|
|
self.executed += 1
|
|
|