parent
a8ec570594
commit
6b8ef81cdc
1 changed files with 9 additions and 9 deletions
18
sweebot.py
18
sweebot.py
|
@ -58,7 +58,7 @@ def config_docs():
|
|||
def ai_response_truncate(uuidd):
|
||||
if uuidd in responses_ai:
|
||||
res = responses_ai[uuidd]
|
||||
return f'<title>AI response {uuidd}</title>\n<meta name="viewport" content="width=device-width, initial-scale=1.0">\n<link rel="stylesheet" href="https://swee.codes/style.css" type="text/css">\n<body><center><h1>AI response {uuidd}</h1><br><br><div class=code width="100%" style="word-wrap: break-word;white-space: pre;text-align: left;">' + res
|
||||
return f'<title>AI response {uuidd}</title>\n<meta name="viewport" content="width=device-width, initial-scale=1.0">\n<link rel="stylesheet" href="https://swee.codes/style.css" type="text/css">\n<body><center><h1>AI response {uuidd}</h1><br><br><pre class=code width="100%" style="word-wrap: break-word;white-space: pre-wrap;text-align: left;">' + res
|
||||
else:
|
||||
abrt(404)
|
||||
threading.Thread(target=app.run, daemon=True, kwargs={"port": 2005}).start()
|
||||
|
@ -553,7 +553,7 @@ while True:
|
|||
for i in logs[channel][-15:]:
|
||||
prettylogs += i["nick"] + ": " + i["content"] + "\n"
|
||||
prettylogs = prettylogs.strip()
|
||||
chatquery = f"--Details--\nYour happiness level is {happiness}/10, your emotion level will impact the conversation's tone.\nYour name is MeowNexUS, you're a bot who acts like an anthropomorphic cat/furry\nYour beloved creator is named Swee.\nDo not start your reply with your name, people already know who you are.\nYou should not use ANY emojis at all, instead, use the much cuter ASCII emoticons and kaomojis such as :3\nIf the user's message contains ^ that means the person wants more details from the last message in the provided history.\nYou will be provided with the last 15 lines of this channel's chat logs to improve the conversation's context, Don't mind if your own messages have mutliple lines, and do not repeat any of the messages listed, it will be considered annoying.\nThe bottom of the chat history in the prompt will be the main question\n--Chat on {channel}--\n{prettylogs}\n--main question--\n{nick}: " + " ".join(command)
|
||||
chatquery = f"--Details--\nYour happiness level is {happiness}/10, your emotion level will impact the conversation's tone.\nYour name is MeowNexUS, you're a bot who acts like an anthropomorphic cat/furry\nYour beloved creator is named Swee.\nDo not start your reply with your name, people already know who you are.\nYou should not use ANY emojis at all, instead, use the much cuter ASCII emoticons and kaomojis such as :3\nIf the user's message contains ^ that means the person wants more details from the last message in the provided history.\nYou will be provided with the last 15 lines of this channel's chat logs to improve the conversation's context, Don't mind if your own messages have mutliple lines, and do not repeat any of the messages listed, it will be considered annoying.\nThe bottom of the chat history in the prompt will be the main question\nThis chat is on IRC, you should answer the question in the simplest way possible\n--Chat on {channel}--\n{prettylogs}\n--main question--\n{nick}: " + " ".join(command)
|
||||
postAttempt = AIsession.post(AIurl, json={"model": AImodel, "prompt": chatquery, "stream": False})
|
||||
print(postAttempt.content)
|
||||
if not postAttempt.ok:
|
||||
|
@ -562,7 +562,7 @@ while True:
|
|||
randomname = str(uuid.uuid4())
|
||||
responses_ai[randomname] = aimsg
|
||||
mtline = ""
|
||||
lastquery = f"<p>Channel: {channel}</p><p>Request:</p><br><br><textarea class=code width=100% spellcheck=\"false\" autocapitalize=\"off\" autocomplete=\"off\" autocorrect=\"off\" readonly=\"true\">{chatquery}</textarea><hr><p>Response</p><br><br><textarea class=code width=100% spellcheck=\"false\" autocapitalize=\"off\" autocomplete=\"off\" autocorrect=\"off\" readonly=\"true\">{aimsg}</textarea>"
|
||||
lastquery = f'<p>Channel: {channel}</p><p>Request:</p><br><br><pre class=code width="100%" style="word-wrap: break-word;white-space: pre-wrap;text-align: left;">{chatquery}</pre><hr><p>Response</p><br><br><pre class=code width="100%" style="word-wrap: break-word;white-space: pre-wrap;text-align: left;">{aimsg}</pre>'
|
||||
broke = False
|
||||
logs[channel].append({"nick": nick, "content": " ".join(command)})
|
||||
logs[channel].append({"nick": "MeowNexUS", "content": aimsg, "ignore": True})
|
||||
|
@ -670,9 +670,9 @@ while True:
|
|||
run-=1
|
||||
|
||||
elif command[0] == "$dopull":
|
||||
irc.send_irc(channel, nick + ":[...] Please wait, pulling docker image...")
|
||||
irc.send_irc(channel, nick + ": [...] Please wait, pulling docker image...")
|
||||
image = dock.images.pull('alpine', tag="edge")
|
||||
irc.send_irc(channel, nick + ":[OK] Pulled docker image, running command now.")
|
||||
irc.send_irc(channel, nick + ": [OK] Pulled docker image, running command now.")
|
||||
elif command[0] == "$doshell":
|
||||
if len(command) > 1:
|
||||
try:
|
||||
|
@ -683,18 +683,18 @@ while True:
|
|||
_, stream = cntr.exec_run(cmd=["timeout", "10", "ash", "-c", " ".join(command[1:])], tty=False)
|
||||
multiline(replace_color_codes(stream.decode()), channel)
|
||||
except Exception as ex:
|
||||
irc.send_irc(channel, nick + ":[ERR] Traceback:")
|
||||
irc.send_irc(channel, nick + ": [ERR] Traceback:")
|
||||
multiline(traceback.format_exc(), channel)
|
||||
else:
|
||||
irc.send_irc(channel, nick + ":[ERR] ")
|
||||
irc.send_irc(channel, nick + ": [ERR] No command specified, aborting")
|
||||
elif command[0] == "$doreset":
|
||||
if cntr == None:
|
||||
irc.send_irc(channel, nick + ":[OK] No container is loaded yet.")
|
||||
irc.send_irc(channel, nick + ": [OK] No container is loaded yet.")
|
||||
else:
|
||||
cntr.kill()
|
||||
cntr.remove()
|
||||
cntr = None
|
||||
irc.send_irc(channel, nick + ":[OK] Done.")
|
||||
irc.send_irc(channel, nick + ": [OK] Done.")
|
||||
|
||||
|
||||
elif command[0] == "$version":
|
||||
|
|
Loading…
Add table
Reference in a new issue