diff --git a/app/bot.py b/app/bot.py index d02c65dc..a151485a 100755 --- a/app/bot.py +++ b/app/bot.py @@ -74,7 +74,7 @@ async def convert_heic_to_jpg(ctx): if attachment.filename.lower().endswith(("heic", "tiff")): source_file = "/tmp/source" source_file, file_path = tempfile.mkstemp() - jpg_file = "/tmp/%s.jpg" % time.time() + jpg_file = f"/tmp/{time.time()}.jpg" await attachment.save(fp=file_path) cmagick.convert(file_path, jpg_file) @@ -84,8 +84,7 @@ async def convert_heic_to_jpg(ctx): except Exception: pass await ctx.channel.send( - "%s uplodaed a file that discord cant natively embed, so I converted it to a jpg:\n%s" - % (ctx.author.mention, ctx.content), + f"{ctx.author.mention} uplodaed a file that discord cant natively embed, so I converted it to a jpg:\n{ctx.content}", file=discord.File(jpg_file), ) os.remove(file_path) @@ -111,15 +110,9 @@ async def fix_social_media_links(ctx): return for k in correct_domains.keys(): - if ctx.content.startswith(k) or ctx.content.startswith("www.{k}.com"): + if ctx.content.startswith(k) or ctx.content.startswith(f"www.{k}.com"): await ctx.channel.send( - "%s said:\n%s" - % ( - ctx.author.mention, - ctx.content.replace(k, "https://%s.com" % correct_domains[k]).split( - "?" - )[0], - ) + f"{ctx.author.mention} said:\n{ctx.content.replace(k, f'https://{correct_domains[k]}.com').split('?')[0]}", ) await ctx.delete() return diff --git a/app/cogs/actual_utils.py b/app/cogs/actual_utils.py index 203249b0..7d49a967 100755 --- a/app/cogs/actual_utils.py +++ b/app/cogs/actual_utils.py @@ -2,8 +2,9 @@ from discord import option from discord.ext import commands import discord import os -import tempfile import requests +import socket +import tempfile class ActualUtils(commands.Cog): @@ -122,7 +123,7 @@ class ActualUtils(commands.Cog): await ctx.send_followup( file=discord.File( file_path, - filename="A Message From {}.mp3".format(ctx.author.name), + filename=f"A Message From {ctx.author.name}.mp3", ) ) os.remove(file_path) @@ -340,6 +341,15 @@ class ActualUtils(commands.Cog): async def send_to_llm(self, ctx, question: str): import core_utils + # check if its running + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.settimeout(1) + try: + s.connect((core_utils.ein_ip, int(7869))) + except Exception: + await ctx.respond("The LLM is not running right now") + return + await ctx.defer() await ctx.send_followup(await core_utils.send_to_llm(ctx, question)) diff --git a/app/cogs/cheeky_functions.py b/app/cogs/cheeky_functions.py index 88a7a591..dd6355ad 100755 --- a/app/cogs/cheeky_functions.py +++ b/app/cogs/cheeky_functions.py @@ -122,7 +122,7 @@ class Cheeky(commands.Cog): requests.get(core_utils.json_endpoint + "dracula_flow").text.splitlines() ) embed = discord.Embed( - description="# %s" % verse.upper(), + description=f"# {verse.upper()}", color=discord.Color.red(), type="rich", ) @@ -413,7 +413,7 @@ class Cheeky(commands.Cog): result = eight_ball.check_8ball(question) - await ctx.respond(":8ball: %s :8ball:" % result) + await ctx.respond(f":8ball: {result} :8ball:") @commands.slash_command( name="flows", diff --git a/app/ffxiv.py b/app/ffxiv.py index 8153f43e..892eac11 100755 --- a/app/ffxiv.py +++ b/app/ffxiv.py @@ -3,16 +3,14 @@ import os import discord if os.getenv("ffxiv_token"): - token = "&private_key=%s" % os.getenv("ffxiv_token") + token = f"&private_key={os.getenv('ffxiv_token')}" else: token = "" def make_request(name, server): - player_search = "https://xivapi.com/character/search?name=%s&server=%s%s" % ( - name, - server, - token, + player_search = ( + f"https://xivapi.com/character/search?name={name}&server={server}{token}" ) player_id = list( filter( @@ -24,9 +22,8 @@ def make_request(name, server): # if adding extended=1 to the query, you'll see some image files, eg. /cj/1/blackmage.png # prepend these with https://xivapi.com/ to get a useable url # https://xivapi.com//cj/1/blackmage.png - request_url = "https://xivapi.com/character/%s?extended=1&data=CJ,FC%s" % ( - player_id, - token, + request_url = ( + f"https://xivapi.com/character/{player_id}?extended=1&data=CJ,FC{token}" ) player_blob = requests.get(request_url).json() character = player_blob["Character"] diff --git a/app/lewds.py b/app/lewds.py index 628e7115..ff1f69bc 100755 --- a/app/lewds.py +++ b/app/lewds.py @@ -29,7 +29,7 @@ def get_from_danbooru(boards, nsfw=True): if "file_url" in request.keys(): if request["file_url"].startswith("/data/"): - return "https://danbooru.donmai.us{}".format(request["file_url"]) + return f"https://danbooru.donmai.us{request['file_url']}" return request["file_url"] return get_from_danbooru(boards) diff --git a/app/tts.py b/app/tts.py index 4c376e23..27cda10f 100755 --- a/app/tts.py +++ b/app/tts.py @@ -26,6 +26,6 @@ def get_all_langs(): """ blob = "" for key, value in lang.tts_langs().items(): - blob += "{}: {}\n".format(key, value) + blob += f"{key}: {value}\n" - return "```css\n{}```".format(blob) + return f"```css\n{blob}```"