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.
|
# 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
|
base_url = "http://ollama:11434/api" # this is the default if you're running via docker compose
|
||||||
|
is_gpu = false
|
||||||
|
|
||||||
[ollama.external]
|
[ollama.external]
|
||||||
owner = 421698654189912064
|
owner = 421698654189912064
|
||||||
|
|
|
@ -287,7 +287,7 @@ class FFMeta(commands.Cog):
|
||||||
"-y",
|
"-y",
|
||||||
"-f",
|
"-f",
|
||||||
"mp4",
|
"mp4",
|
||||||
f"-r",
|
"-r",
|
||||||
"5",
|
"5",
|
||||||
"pipe:1",
|
"pipe:1",
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
|
|
@ -13,6 +13,7 @@ class MeterCog(commands.Cog):
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
|
|
||||||
@commands.slash_command(name="gay-meter")
|
@commands.slash_command(name="gay-meter")
|
||||||
|
@discord.guild_only()
|
||||||
async def gay_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
async def gay_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
||||||
"""Checks how gay someone is"""
|
"""Checks how gay someone is"""
|
||||||
user = user or ctx.user
|
user = user or ctx.user
|
||||||
|
@ -21,23 +22,34 @@ class MeterCog(commands.Cog):
|
||||||
for i in range(0, 125, 25):
|
for i in range(0, 125, 25):
|
||||||
await ctx.edit(content="Calculating... %d%%" % i)
|
await ctx.edit(content="Calculating... %d%%" % i)
|
||||||
await asyncio.sleep(random.randint(1, 30) / 10)
|
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.")
|
await ctx.edit(content=f"{user.mention} is {pct}% gay.")
|
||||||
|
|
||||||
@commands.slash_command(name="penis-length")
|
@commands.slash_command(name="penis-length")
|
||||||
async def penis_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
async def penis_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
||||||
"""Checks the length of someone's penis."""
|
"""Checks the length of someone's penis."""
|
||||||
user = user or ctx.user
|
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 = ["8"]
|
||||||
chunks += ["="] * n
|
chunks += ["="] * pct
|
||||||
chunks.append("B")
|
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(
|
return await ctx.respond(
|
||||||
embed=discord.Embed(
|
embed=discord.Embed(
|
||||||
title=f"{user.display_name}'s penis length:",
|
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")
|
@discord.ui.button(label="Done", style=discord.ButtonStyle.success, custom_id="done")
|
||||||
async def done(self, btn: discord.ui.Button, interaction: Interaction):
|
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()
|
self.stop()
|
||||||
|
|
||||||
|
|
||||||
|
@ -637,6 +659,24 @@ class Ollama(commands.Cog):
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
try:
|
try:
|
||||||
server = self.next_server(tried)
|
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:
|
except RuntimeError:
|
||||||
tried.add(server)
|
tried.add(server)
|
||||||
continue
|
continue
|
||||||
|
@ -752,6 +792,27 @@ class Ollama(commands.Cog):
|
||||||
|
|
||||||
key = os.urandom(6).hex()
|
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(
|
embed = discord.Embed(
|
||||||
title="Generating response...",
|
title="Generating response...",
|
||||||
description=">>> ",
|
description=">>> ",
|
||||||
|
|
|
@ -221,14 +221,14 @@ class YTDLCog(commands.Cog):
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
"https://0x0.st",
|
"https://0x0.st",
|
||||||
files={"file": (name, data, mime_type)},
|
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:
|
if response.status_code == 200:
|
||||||
return urlparse(response.text).path[1:]
|
return urlparse(response.text).path[1:]
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
@commands.slash_command(name="yt-dl")
|
@commands.slash_command(name="yt-dl")
|
||||||
# @commands.bot_has_permissions(send_messages=True, embed_links=True, attach_files=True)
|
|
||||||
async def yt_dl_command(
|
async def yt_dl_command(
|
||||||
self,
|
self,
|
||||||
ctx: discord.ApplicationContext,
|
ctx: discord.ApplicationContext,
|
||||||
|
@ -485,7 +485,7 @@ class YTDLCog(commands.Cog):
|
||||||
await ctx.edit(view=None)
|
await ctx.edit(view=None)
|
||||||
try:
|
try:
|
||||||
if audio_only is False:
|
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:
|
else:
|
||||||
# can be .opus, .m4a, .mp3, .ogg, .oga
|
# can be .opus, .m4a, .mp3, .ogg, .oga
|
||||||
for _file in temp_dir.iterdir():
|
for _file in temp_dir.iterdir():
|
||||||
|
@ -495,7 +495,7 @@ class YTDLCog(commands.Cog):
|
||||||
else:
|
else:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
ext = extracted_info["ext"]
|
ext = extracted_info.get("ext", "*")
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"Failed to locate downloaded file. Was supposed to be looking for a file extension of "
|
"Failed to locate downloaded file. Was supposed to be looking for a file extension of "
|
||||||
"%r amongst files %r, however none were found.",
|
"%r amongst files %r, however none were found.",
|
||||||
|
|
Loading…
Reference in a new issue