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.
35 lines
1.3 KiB
35 lines
1.3 KiB
import time
|
|
|
|
class ChatItem:
|
|
def __init__(self, event_id, timestamp, user_name, is_own_message, relates_to_event, message):
|
|
self.event_id = event_id
|
|
self.timestamp = timestamp
|
|
self.user_name = user_name
|
|
self.is_own_message = is_own_message
|
|
self.relates_to_event = relates_to_event
|
|
self.message = message
|
|
self.num_tokens = None
|
|
def __str__(self):
|
|
return str("{}: {}".format(self.user_name, self.message))
|
|
def getLine(self):
|
|
return str("{}: {}".format(self.user_name, self.message))
|
|
|
|
class Event:
|
|
def __init__(self, time_start, time_stop, chance, command):
|
|
self.time_start = time_start
|
|
self.time_stop = time_stop
|
|
self.chance = chance
|
|
self.command = command
|
|
self.executed = 0
|
|
def __str__(self):
|
|
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
|
|
|