From e90245e756c38cb3c74769e49c6e89b373145fbd Mon Sep 17 00:00:00 2001 From: LuminatiHD Date: Fri, 28 Jan 2022 14:39:18 +0100 Subject: [PATCH] =?UTF-8?q?Zeit=20wurde=20UTC-abh=C3=A4ngig=20gemacht.=20V?= =?UTF-8?q?erhindert,=20dass=20die=20Zeit=20ortsabh=C3=A4ngig=20ist=20(wic?= =?UTF-8?q?htig=20f=C3=BCr=20den=20Server)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Briefing/main.py | 9 +++++---- Buttons.py | 39 ++++----------------------------------- Items/editItem.py | 4 +++- Items/searchItem.py | 5 +++-- Items/specialcmds.py | 2 +- Mensa/Webscraping.py | 2 +- Mensa/main.py | 8 ++++---- Stundenplan/main.py | 4 ++-- main.py | 6 +++--- 9 files changed, 26 insertions(+), 53 deletions(-) diff --git a/Briefing/main.py b/Briefing/main.py index 8ffd94a..6542b99 100644 --- a/Briefing/main.py +++ b/Briefing/main.py @@ -76,11 +76,12 @@ def setup(client): def outputbriefing(user, ef, sf, kf, mint): weekdays = FuncLibrary.weekdays - output = nextcord.Embed(title=f"{weekdays[date.today().weekday()]}, " - f"{date.today().day}.{date.today().month}.{str(date.today().year)[2:]} " - f"({datetime.now().hour}:{datetime.now().minute:02})") + today = (datetime.utcnow()+timedelta(hours=1)) + output = nextcord.Embed(title=f"{weekdays[today.weekday()]}, " + f"{today.day}.{today.month}.{str(today.year)[2:]} " + f"({today.hour}:{today.minute:02})") - timeset = date.today()+timedelta(days=7) + timeset = today+timedelta(days=7) items = cs.execute(f"SELECT * FROM items WHERE datum <= ? AND (access = 'all' " \ f"OR access = ? OR access = ? " \ f"OR access = ? OR access = ?) ORDER BY datum", diff --git a/Buttons.py b/Buttons.py index 84e1072..b696a9c 100644 --- a/Buttons.py +++ b/Buttons.py @@ -1,6 +1,6 @@ import nextcord from nextcord.ext.commands.context import Context -from datetime import date +from datetime import date, datetime, timedelta import json maxdayspermonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] @@ -647,39 +647,6 @@ async def callback(self, interaction: nextcord.Interaction): self.menu.stop() -class TimeForReminder(nextcord.ui.View): - def __init__(self, ctx): - self.ctx = ctx - super().__init__(timeout = 120) - - self.hour = None - self.minute = None - - hours = Dropdown() - hours.placeholder = "Stunden" - hours.options = [nextcord.SelectOption(label=str(i%24)) for i in range(7, 24+7)] - hours.custom_id = "hour" - - minutes = Dropdown() - minutes.placeholder = "Minuten" - minutes.options = [nextcord.SelectOption(label=str(i)) for i in range(0, 60, 3)] - minutes.custom_id = "minute" - - self.add_item(hours) - self.add_item(minutes) - - @nextcord.ui.button(label="bestätigen", style=nextcord.ButtonStyle.primary) - async def confirm(self, button:nextcord.Button, interaction:nextcord.Interaction): - if await testinter(interaction, self.ctx) and self.children[1].values and self.children[2].values: - self.hour = int(self.children[1].values[0]) - self.minute = int(self.children[2].values[0]) - self.stop() - - @nextcord.ui.button(label="zurück", style=nextcord.ButtonStyle.red) - async def exit(self, button:nextcord.Button, interaction:nextcord.Interaction): - self.stop() - - class ChooseDatum(nextcord.ui.View): def __init__(self, ctx, day=None, month=None, year=None): self.exit = False @@ -692,6 +659,8 @@ def __init__(self, ctx, day=None, month=None, year=None): self.month = month self.year = year + today = (datetime.utcnow()+timedelta(hours=1)) + dayselect = DayDropdown(self, self.day) dayselect.custom_id = "day" @@ -702,7 +671,7 @@ def __init__(self, ctx, day=None, month=None, year=None): yearselect = Dropdown() yearselect.placeholder = "Jahr:" - yearselect.options = [nextcord.SelectOption(label=str(i)) for i in range(date.today().year, date.today().year+3)] + yearselect.options = [nextcord.SelectOption(label=str(i)) for i in range(today.year, today.year+3)] yearselect.custom_id = "year" self.add_item(dayselect) diff --git a/Items/editItem.py b/Items/editItem.py index 8092414..3eb8432 100644 --- a/Items/editItem.py +++ b/Items/editItem.py @@ -2,11 +2,13 @@ import sqlite3 import datetime import FuncLibrary + Itemfile = "ItemFiles.db" Alltables = "testitems", "items" Itemtable = "items" tablecategories = ("datum", "kategorie", "fach", "aufgabe", "access") -database = sqlite3.connect(Itemfile) + +database = sqlite3.connect(Itemfile, timeout=10) Itemkategorien = ("Test", "Aufgabe") diff --git a/Items/searchItem.py b/Items/searchItem.py index fccb326..731756c 100644 --- a/Items/searchItem.py +++ b/Items/searchItem.py @@ -28,10 +28,11 @@ def __init__(self, bot: commands.Bot): ) async def todo(self, ctx: Context): # aui Elemänt wo scho düre si wärde glöschet. - database.cursor().execute(f"DELETE FROM {Itemtable} WHERE datum=" diff --git a/Items/specialcmds.py b/Items/specialcmds.py index 4745827..4a496ec 100644 --- a/Items/specialcmds.py +++ b/Items/specialcmds.py @@ -29,7 +29,7 @@ async def recommend(self, ctx:Context): if not suggestion.lower().replace(" ", "") in ["ligma", "sugma", "you suck", "u suck", "ligmaballs"]: confirm = await ctx.channel.send("Wird eingetragen...") - time = datetime.now() + time = datetime.utcnow()+timedelta(hours=1) time = f"{time.hour:02}:{time.minute:02}:{time.second:02}, {time.day:02}.{time.month:02}.{str(time.year)[-2::]}" # ds {time.x:02} isch eifach nur da für weme z.B. ä uhrzit vo 9:16:1 het, dass drus när 09:16:1 wird. # So isch ds Layout nicer. diff --git a/Mensa/Webscraping.py b/Mensa/Webscraping.py index 3938085..6df42b4 100644 --- a/Mensa/Webscraping.py +++ b/Mensa/Webscraping.py @@ -11,7 +11,7 @@ def menuoutput(output): menuselect = 1 output = [] - if datetime.now().time() > time(hour=14, minute=30) and weekday <5: + if (datetime.utcnow()+timedelta(hours=1)).time() > time(hour=14, minute=30) and weekday <5: menuselect=2 weekday = (date.today()+timedelta(1)).weekday() diff --git a/Mensa/main.py b/Mensa/main.py index c5e4197..9012ee0 100644 --- a/Mensa/main.py +++ b/Mensa/main.py @@ -15,10 +15,10 @@ def __init__(self, bot): @commands.command(name="menu", aliases=["Menu", "m", "M"], help="Gibt das heutige Menu in der Mensa zurück") async def menu(self, ctx:Context): - datum = date.today() + datum = (datetime.utcnow()+timedelta(hours=1)).date() - if datetime.now().time() > time(hour=14, minute=30): - datum = date.today() + timedelta(1) + if (datetime.utcnow()+timedelta(hours=1)).time() > time(hour=14, minute=30): + datum = datum + timedelta(1) if datum.weekday() > 4: datum += timedelta(7-datum.weekday()) @@ -44,7 +44,7 @@ async def menu(self, ctx:Context): @commands.command(name = "wochenplan", aliases=["Wochenplan", "wp", "WP"], help="Gibt das Menu der momentanen Woche zurück") async def weekly(self, ctx:Context): - datum = date.today() + datum = (datetime.utcnow()+timedelta(hours=1)).date() output = await ctx.channel.send("Einen Moment...") weekm = await Webscraping.menuweekly(output) diff --git a/Stundenplan/main.py b/Stundenplan/main.py index f8197cd..29f77a6 100644 --- a/Stundenplan/main.py +++ b/Stundenplan/main.py @@ -25,7 +25,7 @@ def __init__(self, bot): @commands.command(name="nextlesson", aliases=["nl"], help="Gibt einem die nächste Lektion zurück, falls heue noch welche anstehen.") async def next(self, ctx:Context): - tag = datetime.now() + tag = datetime.utcnow()+timedelta(hours=1) zeit = tag.time() sf, ef, kf, mint= access(ctx.author) @@ -67,7 +67,7 @@ async def next(self, ctx:Context): @commands.command(name = "tagesplan", aliases = ["t", "T"], help="Gibt alle heutigen Lektionen zurück.") async def day(self, ctx:Context): table = "Stundenplan_23b" - currdate = (datetime.now()+timedelta(hours=24-17)).date() + currdate = ((datetime.utcnow()+timedelta(hours=1))+timedelta(hours=24-17)).date() tag = currdate.weekday() if tag>4: diff --git a/main.py b/main.py index 21bc94a..2da9acb 100644 --- a/main.py +++ b/main.py @@ -57,7 +57,6 @@ async def on_ready(): client.load_extension("Stundenplan.main") client.load_extension("Briefing.main") client.load_extension("Mensa.main") -client.load_extension("reminders") @tasks.loop(minutes = 10) @@ -66,7 +65,8 @@ async def briefing(): zeit = (datetime.now()+timedelta(hours=24-17)).date() weekdays = ["mo", "di", "mi", "do", "fr", "sa", "so"] users = cs.execute(f"SELECT user_id, sf, ef, kf, mint FROM briefing WHERE "\ - f"{weekdays[zeit.weekday()]} LIKE ?", (f"%{datetime.now().hour:02}:00%",)) + f"{weekdays[zeit.weekday()]} LIKE ?", + (f"%{(datetime.utcnow()+timedelta(hours=1)).hour:02}:00%",)) if users: for user in users: await client.get_user(user[0]).send(embed=main.outputbriefing(client.get_user(user[0]), user[1], user[2], user[3], user[4])) @@ -92,7 +92,7 @@ async def download_pdf(): @tasks.loop(hours=1) async def news(): - if datetime.now().hour == 10: + if (datetime.utcnow()+timedelta(hours=1)).hour == 10: await news_scraper.post_news(client)