TimberBot – commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f6b30a1)
raw | patch | inline | side by side (parent: f6b30a1)
author | Julian Fietkau <git@fietkau.software> | |
Fri, 1 Nov 2024 13:20:23 +0000 (14:20 +0100) | ||
committer | Julian Fietkau <git@fietkau.software> | |
Fri, 1 Nov 2024 13:20:23 +0000 (14:20 +0100) |
timberbot.py | patch | blob | history | |
twitch.py | patch | blob | history |
diff --git a/timberbot.py b/timberbot.py
index 181520dd6f62def783412d9d917803ff40bcd069..3e8a2af6baa2b20d30fe05bfac754882cbd1ab9d 100755 (executable)
--- a/timberbot.py
+++ b/timberbot.py
def error_log(self, line, timestamp = True):
logstr = ''
if timestamp:
- logstr = '[' + datetime.datetime.utcnow().strftime('%H:%M:%S') + '] '
+ logstr = '[' + datetime.datetime.now(datetime.UTC).strftime('%H:%M:%S') + '] '
logstr = logstr + line
print('[' + self.config_calls['get']('main', 'channel') + '] ' + logstr)
- log_path = os.path.join(self.data_dir, 'error_logs', datetime.datetime.utcnow().strftime('%Y-%m-%d')+'.txt')
+ log_path = os.path.join(self.data_dir, 'error_logs', datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d')+'.txt')
if not os.path.exists(os.path.dirname(log_path)):
os.makedirs(os.path.dirname(log_path))
with codecs.open(log_path, 'a', 'utf-8') as log_file:
diff --git a/twitch.py b/twitch.py
index de59869976319666f0a315e3e87eb3938aa261eb..432eeede942a93ba4986dafafbf6c32676a59017 100644 (file)
--- a/twitch.py
+++ b/twitch.py
def socket_send(self, message):
if self.ws == None:
return
- while len(self.sent_timestamps) > 0 and self.sent_timestamps[0] + datetime.timedelta(seconds = 30) < datetime.datetime.utcnow():
+ while len(self.sent_timestamps) > 0 and self.sent_timestamps[0] + datetime.timedelta(seconds = 30) < datetime.datetime.now(datetime.UTC):
self.sent_timestamps.pop(0)
if len(self.sent_timestamps) < 20: # ensures we do not send >20 msgs per 30 seconds.
msg = 'PRIVMSG #' + self.config['channel'].lower() + ' :' + message
# Twitch's tolerance for quick messages may be changing,
# this default used to be 0.5.
time.sleep(1.0)
- self.sent_timestamps.append(datetime.datetime.utcnow())
+ self.sent_timestamps.append(datetime.datetime.now(datetime.UTC))
else:
raise IOError('Message queue full, outgoing message skipped: ' + message)