mirror of
https://github.com/UiO-Gaming/mustafa.git
synced 2026-11-05 13:56:48 +01:00
lint using new pre-commit
This commit is contained in:
1 parent
13215b0391
commit
53c7e92304
11 files changed
+57
-105
No files matched your search
+6
-12
@@ -36,14 +36,12 @@ class Birthday(commands.Cog):
|
||||
Create the necessary tables for the birthday cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS birthdays (
|
||||
discord_id BIGINT PRIMARY KEY,
|
||||
birthday DATE
|
||||
);
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
birthday_group = app_commands.Group(
|
||||
name="bursdag", description="Se, endre eller fjern bursdager for brukere på serveren"
|
||||
@@ -59,14 +57,12 @@ class Birthday(commands.Cog):
|
||||
|
||||
self.bot.logger.info("Checking for birthdays")
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT *
|
||||
FROM birthdays
|
||||
WHERE EXTRACT(MONTH FROM birthday) = EXTRACT(MONTH FROM current_date)
|
||||
AND EXTRACT(DAY FROM birthday) = EXTRACT(DAY FROM current_date);
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
birthdays = self.cursor.fetchall()
|
||||
self.bot.logger.info(f"Found the following birthdays: {birthdays}")
|
||||
@@ -192,13 +188,11 @@ class Birthday(commands.Cog):
|
||||
(list[tuple[int, datetime, datetime]]): List of tuples containing the user ID, date of birth and next birthday
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT *, CAST(birthday + ((EXTRACT(YEAR FROM AGE(birthday)) + 1) * interval '1' YEAR) AS DATE) AS next_bday
|
||||
FROM birthdays
|
||||
ORDER BY next_bday ASC
|
||||
"""
|
||||
)
|
||||
""")
|
||||
results = self.cursor.fetchall()
|
||||
|
||||
# Convert date objects to datetime objects
|
||||
|
||||
+2
-4
@@ -59,14 +59,12 @@ class Galtinn(commands.Cog):
|
||||
data = data.json()
|
||||
|
||||
if not data["results"]:
|
||||
embed = embed_templates.error_warning(
|
||||
"""
|
||||
embed = embed_templates.error_warning("""
|
||||
Du har ikke registrert din Discord-konto i Galtinn. Vi lar bare folk med brukere i Galtinn se data.
|
||||
|
||||
For å koble brukerene dine sammen, besøk [DNS sin Discord](https://discord.gg/SE2ChXjVeV) og skriv:
|
||||
`/galtinn registrer`
|
||||
"""
|
||||
)
|
||||
""")
|
||||
return await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||
|
||||
# Only make new request if given user is different from command invoker
|
||||
|
||||
+12
-24
@@ -24,31 +24,25 @@ class Gullkorn(commands.Cog):
|
||||
Create the necessary tables for the gullkorn cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS gullkorn (
|
||||
discord_id BIGINT PRIMARY KEY,
|
||||
times_cited INT NOT NULL DEFAULT 0,
|
||||
citations_posted INT NOT NULL DEFAULT 0
|
||||
);
|
||||
"""
|
||||
)
|
||||
self.cursor.execute(
|
||||
"""
|
||||
""")
|
||||
self.cursor.execute("""
|
||||
CREATE OR REPLACE VIEW most_cited AS
|
||||
SELECT discord_id, times_cited
|
||||
FROM gullkorn
|
||||
ORDER BY times_cited DESC;
|
||||
"""
|
||||
)
|
||||
self.cursor.execute(
|
||||
"""
|
||||
""")
|
||||
self.cursor.execute("""
|
||||
CREATE OR REPLACE VIEW most_frequent_posters AS
|
||||
SELECT discord_id, citations_posted
|
||||
FROM gullkorn
|
||||
ORDER BY citations_posted DESC;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def construct_data_string(self, data: list[tuple[int, int, int]]) -> str:
|
||||
"""
|
||||
@@ -151,30 +145,24 @@ class Gullkorn(commands.Cog):
|
||||
embed.add_field(name="Antall gullkorn postet", value=result[2])
|
||||
return await interaction.response.send_message(embed=embed, ephemeral=False)
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT SUM(citations_posted)
|
||||
FROM gullkorn;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
summary = self.cursor.fetchone()
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT *
|
||||
FROM most_cited
|
||||
LIMIT 5;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
most_cited = self.cursor.fetchall()
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT *
|
||||
FROM most_frequent_posters
|
||||
LIMIT 5;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
citations_posted = self.cursor.fetchall()
|
||||
|
||||
most_cited_string = self.construct_data_string(most_cited)
|
||||
|
||||
@@ -26,14 +26,12 @@ class MCWhitelist(commands.Cog):
|
||||
Create the necessary tables for the mc_whitelist cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS mc_whitelist (
|
||||
discord_id BIGINT PRIMARY KEY,
|
||||
minecraft_id TEXT NOT NULL
|
||||
);
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
whitelist_group = app_commands.Group(
|
||||
name="whitelist", description="Registrer eller fjern deg selv fra vår Minecraft whitelist"
|
||||
|
||||
@@ -14,13 +14,13 @@ class RepeatedMessages(commands.Cog):
|
||||
self.bot = bot
|
||||
self.general_channel = 747542544291987597
|
||||
|
||||
#self.fredag.start()
|
||||
#self.mandag.start()
|
||||
# self.fredag.start()
|
||||
# self.mandag.start()
|
||||
self.new_year.start()
|
||||
|
||||
def cog_unload(self):
|
||||
#self.fredag.cancel()
|
||||
#self.mandag.cancel()
|
||||
# self.fredag.cancel()
|
||||
# self.mandag.cancel()
|
||||
self.new_year.cancel()
|
||||
|
||||
@tasks.loop(time=misc_utils.MIDNIGHT)
|
||||
|
||||
@@ -48,14 +48,12 @@ class SocialCredit(commands.Cog):
|
||||
Create the necessary tables for the social credit cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS social_credit (
|
||||
user_id BIGINT PRIMARY KEY,
|
||||
credit_score SMALLINT NOT NULL
|
||||
);
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def add_new_citizen(func):
|
||||
"""
|
||||
@@ -239,12 +237,10 @@ class SocialCredit(commands.Cog):
|
||||
|
||||
await interaction.response.defer()
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT * FROM social_credit
|
||||
ORDER BY credit_score DESC
|
||||
"""
|
||||
)
|
||||
""")
|
||||
result = self.cursor.fetchall()
|
||||
|
||||
if not result:
|
||||
|
||||
@@ -34,26 +34,22 @@ class StarboardScraper(commands.Cog):
|
||||
Create the necessary tables for the cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS starboard_messages (
|
||||
id SERIAL PRIMARY KEY,
|
||||
starboard_message_id BIGINT UNIQUE,
|
||||
original_message_id BIGINT,
|
||||
original_channel_id BIGINT
|
||||
)
|
||||
"""
|
||||
)
|
||||
self.cursor.execute(
|
||||
"""
|
||||
""")
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS starboard_scraper_state (
|
||||
id INTEGER PRIMARY KEY DEFAULT 1,
|
||||
last_scraped_message_id BIGINT,
|
||||
last_scrape_time TIMESTAMP,
|
||||
CHECK (id = 1)
|
||||
)
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def get_last_scraped_message_id(self):
|
||||
"""
|
||||
@@ -63,13 +59,11 @@ class StarboardScraper(commands.Cog):
|
||||
-------
|
||||
int or None: Last scraped message ID or None if never scraped
|
||||
"""
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT last_scraped_message_id
|
||||
FROM starboard_scraper_state
|
||||
WHERE id = 1
|
||||
"""
|
||||
)
|
||||
""")
|
||||
result = self.cursor.fetchone()
|
||||
return result[0] if result else None
|
||||
|
||||
|
||||
+8
-16
@@ -38,16 +38,14 @@ class Streak(commands.Cog):
|
||||
Create the necessary tables for the streak cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS streak (
|
||||
discord_id BIGINT PRIMARY KEY,
|
||||
streak_start_id TEXT NOT NULL,
|
||||
streak_start_time timestamp NOT NULL,
|
||||
latest_post_time timestamp NOT NULL
|
||||
);
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
async def cog_unload(self):
|
||||
self.bot.logger.info("Unloading cog")
|
||||
@@ -60,12 +58,10 @@ class Streak(commands.Cog):
|
||||
Populate the cache with the current streaks
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT *
|
||||
FROM streak;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
streaks = self.cursor.fetchall()
|
||||
|
||||
for streak in streaks:
|
||||
@@ -149,12 +145,10 @@ class Streak(commands.Cog):
|
||||
if self.streak_cache:
|
||||
await self.insert_cache()
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT discord_id, latest_post_time
|
||||
FROM streak;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
streaks = self.cursor.fetchall()
|
||||
|
||||
for streak in streaks:
|
||||
@@ -250,13 +244,11 @@ class Streak(commands.Cog):
|
||||
|
||||
await interaction.response.defer()
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT discord_id, streak_start_time
|
||||
FROM streak
|
||||
ORDER BY streak_start_time;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
streaks = self.cursor.fetchall()
|
||||
|
||||
if not streaks:
|
||||
|
||||
@@ -41,15 +41,13 @@ class UserFacts(commands.Cog):
|
||||
Create the necessary tables for the birthday cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS user_facts (
|
||||
discord_id BIGINT PRIMARY KEY,
|
||||
mbti CHAR(4),
|
||||
height INT
|
||||
);
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
height_group = app_commands.Group(name="høyde", description="Se, endre eller fjern høyde for brukere på serveren")
|
||||
|
||||
@@ -162,13 +160,11 @@ class UserFacts(commands.Cog):
|
||||
interaction (discord.Interaction): The interaction object
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT discord_id, height FROM user_facts
|
||||
WHERE height IS NOT NULL
|
||||
ORDER BY height DESC;
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
if not (result := self.cursor.fetchall()):
|
||||
return await interaction.response.send_message(
|
||||
|
||||
@@ -305,7 +305,9 @@ class _KickSelectMenu(discord.ui.Select):
|
||||
def __init__(self, parent_view: LobbyView):
|
||||
self.parent_view = parent_view
|
||||
options = [
|
||||
discord.SelectOption(label=p.display_name, value=str(p.id), emoji="🔨", description=f"Kick {p.display_name}")
|
||||
discord.SelectOption(
|
||||
label=p.display_name, value=str(p.id), emoji="🔨", description=f"Kick {p.display_name}"
|
||||
)
|
||||
for p in self.parent_view.lobby.players
|
||||
]
|
||||
super().__init__(placeholder="Kick en spiller", max_values=1, min_values=1, options=options)
|
||||
|
||||
+6
-12
@@ -55,25 +55,21 @@ class WordCloud(commands.Cog):
|
||||
Create the necessary tables for the Ordsky cog to work
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS wordcloud_metadata (
|
||||
discord_user_id BIGINT PRIMARY KEY,
|
||||
tracked_since_message_channel_id BIGINT NOT NULL,
|
||||
tracked_since_message_id BIGINT NOT NULL UNIQUE
|
||||
)
|
||||
"""
|
||||
)
|
||||
self.cursor.execute(
|
||||
"""
|
||||
""")
|
||||
self.cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS wordcloud_words (
|
||||
discord_user_id BIGINT NOT NULL,
|
||||
word TEXT NOT NULL,
|
||||
frequency INTEGER NOT NULL,
|
||||
PRIMARY KEY (discord_user_id, word)
|
||||
)
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
async def cog_unload(self):
|
||||
"""
|
||||
@@ -89,12 +85,10 @@ class WordCloud(commands.Cog):
|
||||
Populates the cached list of consenting users
|
||||
"""
|
||||
|
||||
self.cursor.execute(
|
||||
"""
|
||||
self.cursor.execute("""
|
||||
SELECT discord_user_id
|
||||
FROM wordcloud_metadata
|
||||
"""
|
||||
)
|
||||
""")
|
||||
self.consenting_users = [row[0] for row in self.cursor.fetchall()]
|
||||
|
||||
async def insert_cache(self):
|
||||
|
||||
Reference in new issue
Block a user