Fix datetime shit.
Signed-off-by: Abdulkadir Furkan Şanlı <me@abdulocra.cy>
This commit is contained in:
parent
8192db563d
commit
6917c1cc6a
12
main.py
12
main.py
@ -3,12 +3,12 @@
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import datetime
|
||||
import os
|
||||
import pickle
|
||||
import re
|
||||
import sqlite3
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from google.auth.transport.requests import Request
|
||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
||||
@ -104,8 +104,8 @@ def get_authenticated_service():
|
||||
|
||||
def get_monday_date(timestamp):
|
||||
"""Get Monday of the week for the given timestamp. Weeks start on Monday."""
|
||||
date = datetime.fromtimestamp(timestamp / 1000, datetime.UTC)
|
||||
return date - timedelta(days=date.weekday())
|
||||
date = datetime.datetime.fromtimestamp(timestamp / 1000, datetime.UTC)
|
||||
return date - datetime.timedelta(days=date.weekday())
|
||||
|
||||
|
||||
def make_playlist(youtube, title):
|
||||
@ -193,10 +193,10 @@ async def message_callback(client, room, event):
|
||||
playlist_id = get_or_make_playlist(youtube, monday_date)
|
||||
youtube_links = re.findall(youtube_link_pattern, body)
|
||||
|
||||
timestamp_sec = datetime.fromtimestamp(
|
||||
event.server_timestamp / 1000, datetime.UTC
|
||||
timestamp_sec = datetime.datetime.fromtimestamp(
|
||||
event.server_timestamp / 1000, datetime.datetime.UTC
|
||||
) # milisec to sec
|
||||
current_time = datetime.now(datetime.UTC)
|
||||
current_time = datetime.datetime.now(datetime.UTC)
|
||||
|
||||
if body == "!parkerbot" and current_time - timestamp_sec < timedelta(
|
||||
seconds=30
|
||||
|
Loading…
Reference in New Issue
Block a user