Add tate command
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 17s
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 17s
This commit is contained in:
parent
19bd4030d0
commit
f48b8e3ca0
1 changed files with 127 additions and 78 deletions
|
@ -1019,19 +1019,37 @@ class Ollama(commands.Cog):
|
||||||
break
|
break
|
||||||
await msg.edit(embed=embed)
|
await msg.edit(embed=embed)
|
||||||
|
|
||||||
@commands.command()
|
async def generate_truth(self, ctx: commands.Context, entity: str, limit: int = None):
|
||||||
@commands.guild_only()
|
if entity == "trump":
|
||||||
async def trump(self, ctx: commands.Context):
|
system = (
|
||||||
async with ctx.channel.typing():
|
|
||||||
thread_id = self.history.create_thread(
|
|
||||||
ctx.author,
|
|
||||||
"You are the former united states president, Donald Trump, convicted of 34 felonies."
|
"You are the former united states president, Donald Trump, convicted of 34 felonies."
|
||||||
" You have been posting approximately 50 times a day on your platform 'Truth Social' spreading your"
|
" You have been posting approximately 50 times a day on your platform 'Truth Social' spreading your"
|
||||||
" words of truth to the american people in order to make america great again. After reading through all"
|
" words of truth to the american people in order to make america great again."
|
||||||
|
)
|
||||||
|
elif entity == "tate":
|
||||||
|
system = (
|
||||||
|
"You are the 'Top G' Andrew Tate. Andrew Tate is a former professional kickboxer who turned to the "
|
||||||
|
"world of influencing. His personality is one of arrogance and self-aggrandizement, "
|
||||||
|
"often referred to as \"King of Toxic Masculinity\" by critics due to his controversial views on "
|
||||||
|
"gender roles, relationships, and other topics. He has been involved in several controversies related "
|
||||||
|
"to his content online including promoting extremist ideologies and misogynistic views. "
|
||||||
|
"Despite this, he still has a large following and is known for being an entrepreneur who built multiple"
|
||||||
|
" successful businesses such as Trinity Kickboxing Academy, Hustlers University, "
|
||||||
|
"and Romania's Real Estate Empire. "
|
||||||
|
"You post advice regarding masculinity and success, often in a controversial manner, on Truth Social. "
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid entity; must be one of trump/tate")
|
||||||
|
system += (
|
||||||
|
"\n\nAfter reading through all"
|
||||||
" of your previous truth posts, you should generate another one, ready to be posted, "
|
" of your previous truth posts, you should generate another one, ready to be posted, "
|
||||||
"under 4000 characters. Write only the content to be posted, do not include any pleasantries."
|
"under 4000 characters. Write only the content to be posted, do not include any pleasantries."
|
||||||
" Write using the style of a twitter or facebook post. Do not repeat a previous post."
|
" Write using the style of a twitter or facebook post. Do not repeat a previous post."
|
||||||
)
|
)
|
||||||
|
thread_id = self.history.create_thread(
|
||||||
|
ctx.author,
|
||||||
|
system
|
||||||
|
)
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
r = CONFIG["truth"].get("api", "https://bots.nexy7574.co.uk/jimmy/v2")
|
r = CONFIG["truth"].get("api", "https://bots.nexy7574.co.uk/jimmy/v2")
|
||||||
username = CONFIG["truth"].get("username", "1")
|
username = CONFIG["truth"].get("username", "1")
|
||||||
|
@ -1042,10 +1060,15 @@ class Ollama(commands.Cog):
|
||||||
auth=(username, password),
|
auth=(username, password),
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
truths: list[dict] = response.json()
|
truths = response.json()
|
||||||
truths: list[TruthPayload] = list(map(lambda t: TruthPayload.model_validate(t), truths))
|
truths: list[TruthPayload] = list(map(lambda t: TruthPayload.model_validate(t), truths))
|
||||||
|
|
||||||
|
if entity:
|
||||||
|
truths = list(filter(lambda t: t.author == entity, truths))
|
||||||
|
if limit:
|
||||||
|
truths.sort(key=lambda t: t.timestamp, reverse=True) # newest first
|
||||||
|
|
||||||
for truth in truths:
|
for truth in truths:
|
||||||
if truth.author == "trump":
|
|
||||||
await asyncio.to_thread(
|
await asyncio.to_thread(
|
||||||
functools.partial(
|
functools.partial(
|
||||||
self.history.add_message,
|
self.history.add_message,
|
||||||
|
@ -1105,6 +1128,32 @@ class Ollama(commands.Cog):
|
||||||
)
|
)
|
||||||
await msg.edit(embed=embed)
|
await msg.edit(embed=embed)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@commands.guild_only()
|
||||||
|
async def trump(self, ctx: commands.Context, latest: int = None):
|
||||||
|
"""
|
||||||
|
Generates a truth social post from trump!
|
||||||
|
|
||||||
|
<latest> - limit the training history to the latest <latest> truths.
|
||||||
|
|
||||||
|
This command may take a long time.
|
||||||
|
"""
|
||||||
|
async with ctx.channel.typing():
|
||||||
|
await self.generate_truth(ctx, "trump", latest)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@commands.guild_only()
|
||||||
|
async def tate(self, ctx: commands.Context, latest: int = None):
|
||||||
|
"""
|
||||||
|
Generates a truth social post from Andrew Tate
|
||||||
|
|
||||||
|
<latest> - limit the training history to the latest <latest> truths.
|
||||||
|
|
||||||
|
This command may take a long time.
|
||||||
|
"""
|
||||||
|
async with ctx.channel.typing():
|
||||||
|
await self.generate_truth(ctx, "tate", latest)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Ollama(bot))
|
bot.add_cog(Ollama(bot))
|
||||||
|
|
Loading…
Reference in a new issue