Adding fstrings and also a message if ollama is off
All checks were successful
Build and push / changes (push) Successful in 4s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 3m12s
Build and push / sync-argocd-app (push) Successful in 2s
Build and push / post-failure-to-discord (push) Has been skipped
Build and push / post-success-to-discord (push) Successful in 2s

This commit is contained in:
Luke R 2025-04-22 12:38:32 -07:00
parent 3a697f21ca
commit 8b44daa832
6 changed files with 26 additions and 26 deletions

View File

@ -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

View File

@ -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))

View File

@ -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",

View File

@ -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"]

View File

@ -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)

View File

@ -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}```"