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
|
Create the necessary tables for the birthday cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS birthdays (
|
CREATE TABLE IF NOT EXISTS birthdays (
|
||||||
discord_id BIGINT PRIMARY KEY,
|
discord_id BIGINT PRIMARY KEY,
|
||||||
birthday DATE
|
birthday DATE
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
birthday_group = app_commands.Group(
|
birthday_group = app_commands.Group(
|
||||||
name="bursdag", description="Se, endre eller fjern bursdager for brukere på serveren"
|
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.bot.logger.info("Checking for birthdays")
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM birthdays
|
FROM birthdays
|
||||||
WHERE EXTRACT(MONTH FROM birthday) = EXTRACT(MONTH FROM current_date)
|
WHERE EXTRACT(MONTH FROM birthday) = EXTRACT(MONTH FROM current_date)
|
||||||
AND EXTRACT(DAY FROM birthday) = EXTRACT(DAY FROM current_date);
|
AND EXTRACT(DAY FROM birthday) = EXTRACT(DAY FROM current_date);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
birthdays = self.cursor.fetchall()
|
birthdays = self.cursor.fetchall()
|
||||||
self.bot.logger.info(f"Found the following birthdays: {birthdays}")
|
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
|
(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
|
SELECT *, CAST(birthday + ((EXTRACT(YEAR FROM AGE(birthday)) + 1) * interval '1' YEAR) AS DATE) AS next_bday
|
||||||
FROM birthdays
|
FROM birthdays
|
||||||
ORDER BY next_bday ASC
|
ORDER BY next_bday ASC
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
results = self.cursor.fetchall()
|
results = self.cursor.fetchall()
|
||||||
|
|
||||||
# Convert date objects to datetime objects
|
# Convert date objects to datetime objects
|
||||||
|
|||||||
+2
-4
@@ -59,14 +59,12 @@ class Galtinn(commands.Cog):
|
|||||||
data = data.json()
|
data = data.json()
|
||||||
|
|
||||||
if not data["results"]:
|
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.
|
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:
|
For å koble brukerene dine sammen, besøk [DNS sin Discord](https://discord.gg/SE2ChXjVeV) og skriv:
|
||||||
`/galtinn registrer`
|
`/galtinn registrer`
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
return await interaction.response.send_message(embed=embed, ephemeral=True)
|
return await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
|
|
||||||
# Only make new request if given user is different from command invoker
|
# 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
|
Create the necessary tables for the gullkorn cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS gullkorn (
|
CREATE TABLE IF NOT EXISTS gullkorn (
|
||||||
discord_id BIGINT PRIMARY KEY,
|
discord_id BIGINT PRIMARY KEY,
|
||||||
times_cited INT NOT NULL DEFAULT 0,
|
times_cited INT NOT NULL DEFAULT 0,
|
||||||
citations_posted 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
|
CREATE OR REPLACE VIEW most_cited AS
|
||||||
SELECT discord_id, times_cited
|
SELECT discord_id, times_cited
|
||||||
FROM gullkorn
|
FROM gullkorn
|
||||||
ORDER BY times_cited DESC;
|
ORDER BY times_cited DESC;
|
||||||
"""
|
""")
|
||||||
)
|
self.cursor.execute("""
|
||||||
self.cursor.execute(
|
|
||||||
"""
|
|
||||||
CREATE OR REPLACE VIEW most_frequent_posters AS
|
CREATE OR REPLACE VIEW most_frequent_posters AS
|
||||||
SELECT discord_id, citations_posted
|
SELECT discord_id, citations_posted
|
||||||
FROM gullkorn
|
FROM gullkorn
|
||||||
ORDER BY citations_posted DESC;
|
ORDER BY citations_posted DESC;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
def construct_data_string(self, data: list[tuple[int, int, int]]) -> str:
|
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])
|
embed.add_field(name="Antall gullkorn postet", value=result[2])
|
||||||
return await interaction.response.send_message(embed=embed, ephemeral=False)
|
return await interaction.response.send_message(embed=embed, ephemeral=False)
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT SUM(citations_posted)
|
SELECT SUM(citations_posted)
|
||||||
FROM gullkorn;
|
FROM gullkorn;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
summary = self.cursor.fetchone()
|
summary = self.cursor.fetchone()
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM most_cited
|
FROM most_cited
|
||||||
LIMIT 5;
|
LIMIT 5;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
most_cited = self.cursor.fetchall()
|
most_cited = self.cursor.fetchall()
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM most_frequent_posters
|
FROM most_frequent_posters
|
||||||
LIMIT 5;
|
LIMIT 5;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
citations_posted = self.cursor.fetchall()
|
citations_posted = self.cursor.fetchall()
|
||||||
|
|
||||||
most_cited_string = self.construct_data_string(most_cited)
|
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
|
Create the necessary tables for the mc_whitelist cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS mc_whitelist (
|
CREATE TABLE IF NOT EXISTS mc_whitelist (
|
||||||
discord_id BIGINT PRIMARY KEY,
|
discord_id BIGINT PRIMARY KEY,
|
||||||
minecraft_id TEXT NOT NULL
|
minecraft_id TEXT NOT NULL
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
whitelist_group = app_commands.Group(
|
whitelist_group = app_commands.Group(
|
||||||
name="whitelist", description="Registrer eller fjern deg selv fra vår Minecraft whitelist"
|
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.bot = bot
|
||||||
self.general_channel = 747542544291987597
|
self.general_channel = 747542544291987597
|
||||||
|
|
||||||
#self.fredag.start()
|
# self.fredag.start()
|
||||||
#self.mandag.start()
|
# self.mandag.start()
|
||||||
self.new_year.start()
|
self.new_year.start()
|
||||||
|
|
||||||
def cog_unload(self):
|
def cog_unload(self):
|
||||||
#self.fredag.cancel()
|
# self.fredag.cancel()
|
||||||
#self.mandag.cancel()
|
# self.mandag.cancel()
|
||||||
self.new_year.cancel()
|
self.new_year.cancel()
|
||||||
|
|
||||||
@tasks.loop(time=misc_utils.MIDNIGHT)
|
@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
|
Create the necessary tables for the social credit cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS social_credit (
|
CREATE TABLE IF NOT EXISTS social_credit (
|
||||||
user_id BIGINT PRIMARY KEY,
|
user_id BIGINT PRIMARY KEY,
|
||||||
credit_score SMALLINT NOT NULL
|
credit_score SMALLINT NOT NULL
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
def add_new_citizen(func):
|
def add_new_citizen(func):
|
||||||
"""
|
"""
|
||||||
@@ -239,12 +237,10 @@ class SocialCredit(commands.Cog):
|
|||||||
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT * FROM social_credit
|
SELECT * FROM social_credit
|
||||||
ORDER BY credit_score DESC
|
ORDER BY credit_score DESC
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
|
|||||||
@@ -34,26 +34,22 @@ class StarboardScraper(commands.Cog):
|
|||||||
Create the necessary tables for the cog to work
|
Create the necessary tables for the cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS starboard_messages (
|
CREATE TABLE IF NOT EXISTS starboard_messages (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
starboard_message_id BIGINT UNIQUE,
|
starboard_message_id BIGINT UNIQUE,
|
||||||
original_message_id BIGINT,
|
original_message_id BIGINT,
|
||||||
original_channel_id BIGINT
|
original_channel_id BIGINT
|
||||||
)
|
)
|
||||||
"""
|
""")
|
||||||
)
|
self.cursor.execute("""
|
||||||
self.cursor.execute(
|
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS starboard_scraper_state (
|
CREATE TABLE IF NOT EXISTS starboard_scraper_state (
|
||||||
id INTEGER PRIMARY KEY DEFAULT 1,
|
id INTEGER PRIMARY KEY DEFAULT 1,
|
||||||
last_scraped_message_id BIGINT,
|
last_scraped_message_id BIGINT,
|
||||||
last_scrape_time TIMESTAMP,
|
last_scrape_time TIMESTAMP,
|
||||||
CHECK (id = 1)
|
CHECK (id = 1)
|
||||||
)
|
)
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
def get_last_scraped_message_id(self):
|
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
|
int or None: Last scraped message ID or None if never scraped
|
||||||
"""
|
"""
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT last_scraped_message_id
|
SELECT last_scraped_message_id
|
||||||
FROM starboard_scraper_state
|
FROM starboard_scraper_state
|
||||||
WHERE id = 1
|
WHERE id = 1
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
result = self.cursor.fetchone()
|
result = self.cursor.fetchone()
|
||||||
return result[0] if result else None
|
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
|
Create the necessary tables for the streak cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS streak (
|
CREATE TABLE IF NOT EXISTS streak (
|
||||||
discord_id BIGINT PRIMARY KEY,
|
discord_id BIGINT PRIMARY KEY,
|
||||||
streak_start_id TEXT NOT NULL,
|
streak_start_id TEXT NOT NULL,
|
||||||
streak_start_time timestamp NOT NULL,
|
streak_start_time timestamp NOT NULL,
|
||||||
latest_post_time timestamp NOT NULL
|
latest_post_time timestamp NOT NULL
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
async def cog_unload(self):
|
async def cog_unload(self):
|
||||||
self.bot.logger.info("Unloading cog")
|
self.bot.logger.info("Unloading cog")
|
||||||
@@ -60,12 +58,10 @@ class Streak(commands.Cog):
|
|||||||
Populate the cache with the current streaks
|
Populate the cache with the current streaks
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM streak;
|
FROM streak;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
streaks = self.cursor.fetchall()
|
streaks = self.cursor.fetchall()
|
||||||
|
|
||||||
for streak in streaks:
|
for streak in streaks:
|
||||||
@@ -149,12 +145,10 @@ class Streak(commands.Cog):
|
|||||||
if self.streak_cache:
|
if self.streak_cache:
|
||||||
await self.insert_cache()
|
await self.insert_cache()
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT discord_id, latest_post_time
|
SELECT discord_id, latest_post_time
|
||||||
FROM streak;
|
FROM streak;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
streaks = self.cursor.fetchall()
|
streaks = self.cursor.fetchall()
|
||||||
|
|
||||||
for streak in streaks:
|
for streak in streaks:
|
||||||
@@ -250,13 +244,11 @@ class Streak(commands.Cog):
|
|||||||
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT discord_id, streak_start_time
|
SELECT discord_id, streak_start_time
|
||||||
FROM streak
|
FROM streak
|
||||||
ORDER BY streak_start_time;
|
ORDER BY streak_start_time;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
streaks = self.cursor.fetchall()
|
streaks = self.cursor.fetchall()
|
||||||
|
|
||||||
if not streaks:
|
if not streaks:
|
||||||
|
|||||||
@@ -41,15 +41,13 @@ class UserFacts(commands.Cog):
|
|||||||
Create the necessary tables for the birthday cog to work
|
Create the necessary tables for the birthday cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS user_facts (
|
CREATE TABLE IF NOT EXISTS user_facts (
|
||||||
discord_id BIGINT PRIMARY KEY,
|
discord_id BIGINT PRIMARY KEY,
|
||||||
mbti CHAR(4),
|
mbti CHAR(4),
|
||||||
height INT
|
height INT
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
height_group = app_commands.Group(name="høyde", description="Se, endre eller fjern høyde for brukere på serveren")
|
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
|
interaction (discord.Interaction): The interaction object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT discord_id, height FROM user_facts
|
SELECT discord_id, height FROM user_facts
|
||||||
WHERE height IS NOT NULL
|
WHERE height IS NOT NULL
|
||||||
ORDER BY height DESC;
|
ORDER BY height DESC;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
if not (result := self.cursor.fetchall()):
|
if not (result := self.cursor.fetchall()):
|
||||||
return await interaction.response.send_message(
|
return await interaction.response.send_message(
|
||||||
|
|||||||
@@ -305,7 +305,9 @@ class _KickSelectMenu(discord.ui.Select):
|
|||||||
def __init__(self, parent_view: LobbyView):
|
def __init__(self, parent_view: LobbyView):
|
||||||
self.parent_view = parent_view
|
self.parent_view = parent_view
|
||||||
options = [
|
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
|
for p in self.parent_view.lobby.players
|
||||||
]
|
]
|
||||||
super().__init__(placeholder="Kick en spiller", max_values=1, min_values=1, options=options)
|
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
|
Create the necessary tables for the Ordsky cog to work
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS wordcloud_metadata (
|
CREATE TABLE IF NOT EXISTS wordcloud_metadata (
|
||||||
discord_user_id BIGINT PRIMARY KEY,
|
discord_user_id BIGINT PRIMARY KEY,
|
||||||
tracked_since_message_channel_id BIGINT NOT NULL,
|
tracked_since_message_channel_id BIGINT NOT NULL,
|
||||||
tracked_since_message_id BIGINT NOT NULL UNIQUE
|
tracked_since_message_id BIGINT NOT NULL UNIQUE
|
||||||
)
|
)
|
||||||
"""
|
""")
|
||||||
)
|
self.cursor.execute("""
|
||||||
self.cursor.execute(
|
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS wordcloud_words (
|
CREATE TABLE IF NOT EXISTS wordcloud_words (
|
||||||
discord_user_id BIGINT NOT NULL,
|
discord_user_id BIGINT NOT NULL,
|
||||||
word TEXT NOT NULL,
|
word TEXT NOT NULL,
|
||||||
frequency INTEGER NOT NULL,
|
frequency INTEGER NOT NULL,
|
||||||
PRIMARY KEY (discord_user_id, word)
|
PRIMARY KEY (discord_user_id, word)
|
||||||
)
|
)
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
async def cog_unload(self):
|
async def cog_unload(self):
|
||||||
"""
|
"""
|
||||||
@@ -89,12 +85,10 @@ class WordCloud(commands.Cog):
|
|||||||
Populates the cached list of consenting users
|
Populates the cached list of consenting users
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.cursor.execute(
|
self.cursor.execute("""
|
||||||
"""
|
|
||||||
SELECT discord_user_id
|
SELECT discord_user_id
|
||||||
FROM wordcloud_metadata
|
FROM wordcloud_metadata
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
self.consenting_users = [row[0] for row in self.cursor.fetchall()]
|
self.consenting_users = [row[0] for row in self.cursor.fetchall()]
|
||||||
|
|
||||||
async def insert_cache(self):
|
async def insert_cache(self):
|
||||||
|
|||||||
Reference in new issue
Block a user