Skip to content

Commit

Permalink
Zeit wurde UTC-abhängig gemacht. Verhindert, dass die Zeit ortsabhäng…
Browse files Browse the repository at this point in the history
…ig ist (wichtig für den Server)
  • Loading branch information
LuminatiHD committed Jan 28, 2022
1 parent 6798433 commit e90245e
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 53 deletions.
9 changes: 5 additions & 4 deletions Briefing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
39 changes: 4 additions & 35 deletions Buttons.py
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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"

Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Items/editItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
5 changes: 3 additions & 2 deletions Items/searchItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<?", (str(date.today()),))
timeset = str((datetime.datetime.utcnow()+datetime.timedelta(hours=1)).date())
database.cursor().execute(f"DELETE FROM {Itemtable} WHERE datum<?", (timeset,))
database.commit()
search = ctx.message.content[len("!todo "):]
timeset = str(date.today())

bfore_or_after = ">="


Expand Down
2 changes: 1 addition & 1 deletion Items/specialcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Mensa/Webscraping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions Mensa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Stundenplan/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]))
Expand All @@ -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)


Expand Down

0 comments on commit e90245e

Please sign in to comment.