Merge remote-tracking branch 'origin/master'
All checks were successful
Build and Publish / build_and_publish (push) Successful in 4m45s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 4m45s
This commit is contained in:
commit
01e3e85f19
5 changed files with 85 additions and 11 deletions
|
@ -34,6 +34,7 @@ allowed_models = [
|
|||
# Note that every model has a tag called "latest" which is the most recent version.
|
||||
]
|
||||
base_url = "http://ollama:11434/api" # this is the default if you're running via docker compose
|
||||
is_gpu = false
|
||||
|
||||
[ollama.external]
|
||||
owner = 421698654189912064
|
||||
|
|
|
@ -287,7 +287,7 @@ class FFMeta(commands.Cog):
|
|||
"-y",
|
||||
"-f",
|
||||
"mp4",
|
||||
f"-r",
|
||||
"-r",
|
||||
"5",
|
||||
"pipe:1",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
|
|
|
@ -13,6 +13,7 @@ class MeterCog(commands.Cog):
|
|||
self.cache = {}
|
||||
|
||||
@commands.slash_command(name="gay-meter")
|
||||
@discord.guild_only()
|
||||
async def gay_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
||||
"""Checks how gay someone is"""
|
||||
user = user or ctx.user
|
||||
|
@ -21,23 +22,34 @@ class MeterCog(commands.Cog):
|
|||
for i in range(0, 125, 25):
|
||||
await ctx.edit(content="Calculating... %d%%" % i)
|
||||
await asyncio.sleep(random.randint(1, 30) / 10)
|
||||
|
||||
pct = user.id % 100
|
||||
|
||||
if random.randint(0, 1):
|
||||
pct = sum((user.id, ctx.user.id, ctx.channel.id, ctx.guild.id)) % 400
|
||||
else:
|
||||
pct = user.id % 100
|
||||
await ctx.edit(content=f"{user.mention} is {pct}% gay.")
|
||||
|
||||
@commands.slash_command(name="penis-length")
|
||||
async def penis_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
||||
"""Checks the length of someone's penis."""
|
||||
user = user or ctx.user
|
||||
n = self.cache.get(user) or random.randint(0, 100)
|
||||
if random.randint(0, 1):
|
||||
pct = sum((user.id, ctx.user.id)) % 200
|
||||
else:
|
||||
pct = user.id % 125
|
||||
pct = pct
|
||||
chunks = ["8"]
|
||||
chunks += ["="] * n
|
||||
chunks += ["="] * pct
|
||||
chunks.append("B")
|
||||
self.cache[user] = n
|
||||
inch = pct * 0.3937008
|
||||
im = "inch"
|
||||
if pct > 30.48:
|
||||
im = "ft"
|
||||
inch = pct * 0.0328084
|
||||
return await ctx.respond(
|
||||
embed=discord.Embed(
|
||||
title=f"{user.display_name}'s penis length:",
|
||||
description="%d cm\n%s" % (n, "".join(chunks))
|
||||
description="%d cm (%.2f%s)\n%s" % (pct, inch, im, "".join(chunks))
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -461,6 +461,28 @@ class PromptSelector(discord.ui.View):
|
|||
|
||||
@discord.ui.button(label="Done", style=discord.ButtonStyle.success, custom_id="done")
|
||||
async def done(self, btn: discord.ui.Button, interaction: Interaction):
|
||||
self.ctx.interaction = interaction
|
||||
self.stop()
|
||||
|
||||
|
||||
class ConfirmCPURun(discord.ui.View):
|
||||
def __init__(self, ctx: discord.ApplicationContext):
|
||||
super().__init__(timeout=600, disable_on_timeout=True)
|
||||
self.ctx = ctx
|
||||
self.proceed = False
|
||||
|
||||
async def interaction_check(self, interaction: Interaction) -> bool:
|
||||
return interaction.user == self.ctx.user
|
||||
|
||||
@discord.ui.button(label="Run on CPU", style=discord.ButtonStyle.primary, custom_id="cpu")
|
||||
async def run_on_cpu(self, btn: discord.ui.Button, interaction: Interaction):
|
||||
await interaction.response.defer(invisible=True)
|
||||
self.proceed = True
|
||||
self.stop()
|
||||
|
||||
@discord.ui.button(label="Abort", style=discord.ButtonStyle.primary, custom_id="gpu")
|
||||
async def run_on_gpu(self, btn: discord.ui.Button, interaction: Interaction):
|
||||
await interaction.response.defer(invisible=True)
|
||||
self.stop()
|
||||
|
||||
|
||||
|
@ -637,6 +659,24 @@ class Ollama(commands.Cog):
|
|||
for i in range(10):
|
||||
try:
|
||||
server = self.next_server(tried)
|
||||
if server and CONFIG["ollama"]["server"].get("is_gpu", False) is not True:
|
||||
cf = ConfirmCPURun(ctx)
|
||||
await ctx.edit(
|
||||
embed=discord.Embed(
|
||||
title=f"Server {server} is available, but...",
|
||||
description="It is CPU only, which means it is very slow and will likely crash.\n"
|
||||
"If you really want, you can continue your generation, using this "
|
||||
"server. Be aware though, once in motion, it cannot be stopped.\n\n"
|
||||
""
|
||||
"Continue?",
|
||||
color=discord.Color.red(),
|
||||
),
|
||||
view=cf
|
||||
)
|
||||
await cf.wait()
|
||||
await ctx.edit(view=None)
|
||||
if cf.proceed:
|
||||
break
|
||||
except RuntimeError:
|
||||
tried.add(server)
|
||||
continue
|
||||
|
@ -752,6 +792,27 @@ class Ollama(commands.Cog):
|
|||
|
||||
key = os.urandom(6).hex()
|
||||
|
||||
if server_config.get("is_gpu", False) is False:
|
||||
cf2 = ConfirmCPURun(ctx)
|
||||
await ctx.edit(
|
||||
content=None,
|
||||
embed=discord.Embed(
|
||||
title="Before you continue",
|
||||
description="You've selected a CPU-only server. This will be really slow. This will also likely"
|
||||
" bring the host to a halt. Consider the pain the CPU is about to endure. "
|
||||
"Are you super"
|
||||
" sure you want to continue? You can run `h!ollama-status` to see what servers are"
|
||||
" available.",
|
||||
color=discord.Color.red(),
|
||||
),
|
||||
view=cf2
|
||||
)
|
||||
await cf2.wait()
|
||||
if cf2.proceed is False:
|
||||
return await ctx.edit("Cancelled.", embed=None, view=None)
|
||||
else:
|
||||
await ctx.edit(view=None)
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Generating response...",
|
||||
description=">>> ",
|
||||
|
|
|
@ -221,14 +221,14 @@ class YTDLCog(commands.Cog):
|
|||
response = await client.post(
|
||||
"https://0x0.st",
|
||||
files={"file": (name, data, mime_type)},
|
||||
headers={"User-Agent": "CollegeBot (matrix: @nex:nexy7574.co.uk)"},
|
||||
data={"expires": 12},
|
||||
headers={"User-Agent": "CollegeBot (see: https://gist.i-am.nexus/nex/f63fcb9eb389401caf66d1dfc3c7570c)"},
|
||||
)
|
||||
if response.status_code == 200:
|
||||
return urlparse(response.text).path[1:]
|
||||
response.raise_for_status()
|
||||
|
||||
@commands.slash_command(name="yt-dl")
|
||||
# @commands.bot_has_permissions(send_messages=True, embed_links=True, attach_files=True)
|
||||
async def yt_dl_command(
|
||||
self,
|
||||
ctx: discord.ApplicationContext,
|
||||
|
@ -485,7 +485,7 @@ class YTDLCog(commands.Cog):
|
|||
await ctx.edit(view=None)
|
||||
try:
|
||||
if audio_only is False:
|
||||
file: Path = next(temp_dir.glob("*." + extracted_info["ext"]))
|
||||
file: Path = next(temp_dir.glob("*." + extracted_info.get("ext", "*")))
|
||||
else:
|
||||
# can be .opus, .m4a, .mp3, .ogg, .oga
|
||||
for _file in temp_dir.iterdir():
|
||||
|
@ -495,7 +495,7 @@ class YTDLCog(commands.Cog):
|
|||
else:
|
||||
raise StopIteration
|
||||
except StopIteration:
|
||||
ext = extracted_info["ext"]
|
||||
ext = extracted_info.get("ext", "*")
|
||||
self.log.warning(
|
||||
"Failed to locate downloaded file. Was supposed to be looking for a file extension of "
|
||||
"%r amongst files %r, however none were found.",
|
||||
|
|
Loading…
Reference in a new issue