mirror of https://github.com/stijndcl/didier
Reminders work
parent
6682327f1e
commit
95bdc576e1
|
@ -61,8 +61,7 @@ class School(commands.Cog):
|
|||
|
||||
# Add all the user's courses
|
||||
def customizeSchedule(self, ctx, year, semester):
|
||||
with open("files/schedules/{}{}.json".format(year, semester), "r") as fp:
|
||||
schedule = json.load(fp)
|
||||
schedule = les.getSchedule(semester, year)
|
||||
|
||||
member = self.client.get_guild(int(constants.CallOfCode)).get_member(ctx.author.id)
|
||||
for role in member.roles:
|
||||
|
|
|
@ -5,7 +5,7 @@ from enums.numbers import Numbers
|
|||
from functions import timeFormatters
|
||||
from functions.database import currency, poke, prison, birthdays, stats
|
||||
import json
|
||||
from random import random
|
||||
import random
|
||||
import requests
|
||||
import time
|
||||
|
||||
|
@ -183,7 +183,7 @@ class Tasks(commands.Cog):
|
|||
# Don't do it multiple times a day if bot dc's, ...
|
||||
with open("files/lastTasks.json", "r") as fp:
|
||||
lastTasks = json.load(fp)
|
||||
if int(self.getCurrentHour()) == 21 and int(time.time()) - int(lastTasks["remind"]) > 10000:
|
||||
if int(self.getCurrentHour()) == 22 and int(time.time()) - int(lastTasks["remind"]) > 10000:
|
||||
reminders = Reminders()
|
||||
|
||||
for category in reminders.categories:
|
||||
|
@ -200,9 +200,9 @@ class Tasks(commands.Cog):
|
|||
else:
|
||||
await userInstance.send(random.choice(category["messages"]), embed=category["embed"])
|
||||
|
||||
# with open("files/lastTasks.json", "w") as fp:
|
||||
# lastTasks["remind"] = round(time.time())
|
||||
# json.dump(lastTasks, fp)
|
||||
with open("files/lastTasks.json", "w") as fp:
|
||||
lastTasks["remind"] = round(time.time())
|
||||
json.dump(lastTasks, fp)
|
||||
|
||||
def getCurrentHour(self):
|
||||
return timeFormatters.dateTimeNow().hour
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from functions import les
|
||||
from functions.database import remind
|
||||
|
||||
|
||||
|
@ -11,6 +12,13 @@ class Reminders:
|
|||
|
||||
self._les = [int(user[0]) for user in rows if user[2]]
|
||||
self._lesMessages = ["Lessenrooster voor vandaag:"]
|
||||
self.les = {"users": self._les, "messages": self._lesMessages, "embed": None}
|
||||
self.les = {"users": self._les, "messages": self._lesMessages, "embed": self.lesEmbed()}
|
||||
|
||||
self.categories = [self.nightly, self.les]
|
||||
|
||||
def lesEmbed(self):
|
||||
day, dayDatetime, semester, year = les.parseArgs([])[1:]
|
||||
|
||||
schedule = les.getSchedule(semester, year)
|
||||
|
||||
return les.createEmbed(day, dayDatetime, semester, year, schedule)
|
|
@ -17,7 +17,7 @@ def getOrAddUser(userid):
|
|||
res = cursor.fetchall()
|
||||
|
||||
if not res:
|
||||
cursor.execute("INSERT INTO remind(userid) VALUES %s", (int(userid),))
|
||||
cursor.execute("INSERT INTO remind(userid) VALUES(%s)", (int(userid),))
|
||||
connection.commit()
|
||||
|
||||
return getOrAddUser(userid)
|
||||
|
@ -36,7 +36,7 @@ def switchReminder(userid, column):
|
|||
# Switch the column value
|
||||
to = not (res[columns.index(column)])
|
||||
|
||||
cursor.execute("UPDATE remind SET %s = %s WHERE userid = %s", (column, to, int(userid),))
|
||||
cursor.execute("UPDATE remind SET {} = %s WHERE userid = %s".format(column), (to, int(userid),))
|
||||
connection.commit()
|
||||
|
||||
return to
|
||||
|
|
Loading…
Reference in New Issue