Rollback to 0.0.1
This commit is contained in:
parent
3c66fe13f7
commit
401b9487b0
1 changed files with 1 additions and 63 deletions
64
guild2.py
64
guild2.py
|
@ -31,18 +31,7 @@ import distro
|
||||||
print("[" + BLUE + "..." + RESET + "] Importing DuckDuckGo search...")
|
print("[" + BLUE + "..." + RESET + "] Importing DuckDuckGo search...")
|
||||||
from duckduckgo_search import DDGS
|
from duckduckgo_search import DDGS
|
||||||
import subprocess
|
import subprocess
|
||||||
from characterai import pycai
|
|
||||||
client = guilded.Client()
|
client = guilded.Client()
|
||||||
#C.AI
|
|
||||||
caitoken = os.environ["CAItoken"]
|
|
||||||
caibot= os.environ["CAImodel"]
|
|
||||||
try:
|
|
||||||
cai = pycai.Client(caitoken)
|
|
||||||
me = cai.get_me()
|
|
||||||
chat = cai.connect()
|
|
||||||
chats = []
|
|
||||||
except:
|
|
||||||
print(traceback.format_exc())
|
|
||||||
# Help document
|
# Help document
|
||||||
documentation = """$help - Shows this message.
|
documentation = """$help - Shows this message.
|
||||||
$ping - Test if bot is online.
|
$ping - Test if bot is online.
|
||||||
|
@ -50,10 +39,9 @@ $version - Get version of SweeBot and the system it's running on
|
||||||
$whoami - Gets your user ID
|
$whoami - Gets your user ID
|
||||||
$perms - Gets your permissions
|
$perms - Gets your permissions
|
||||||
$search - Preform a websearch via DuckDuckGo
|
$search - Preform a websearch via DuckDuckGo
|
||||||
$ai-chat - Preform an AI chat powered by Character.AI
|
|
||||||
"""
|
"""
|
||||||
meows = ['Meow!', 'Nyaa~', 'Mrow.', 'Prr! :3', 'Hiss!', "Mrrp?", "Mreow.", "!woeM", "3: !rrP", "!ssiH", "~aayN", "Mew!", "Moew!"]
|
meows = ['Meow!', 'Nyaa~', 'Mrow.', 'Prr! :3', 'Hiss!', "Mrrp?", "Mreow.", "!woeM", "3: !rrP", "!ssiH", "~aayN", "Mew!", "Moew!"]
|
||||||
version = "0.0.2 patch 2 (AI update) (Open-source patch)"
|
version = "0.0.1 (rollback)"
|
||||||
# user permissions
|
# user permissions
|
||||||
def getperms(userID):
|
def getperms(userID):
|
||||||
if not os.path.isfile(str(userID)):
|
if not os.path.isfile(str(userID)):
|
||||||
|
@ -67,8 +55,6 @@ class SweeBotTestException(Exception):
|
||||||
pass
|
pass
|
||||||
class SweeBotSystemException(Exception):
|
class SweeBotSystemException(Exception):
|
||||||
pass
|
pass
|
||||||
class SweeBotAIException(Exception):
|
|
||||||
pass
|
|
||||||
# Client itself
|
# Client itself
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
@ -76,20 +62,6 @@ async def on_ready():
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
ai = False
|
|
||||||
ai_ = None
|
|
||||||
ai__ = 0
|
|
||||||
for i in message.replied_to:
|
|
||||||
h = 0
|
|
||||||
for j in chats:
|
|
||||||
print(i.id)
|
|
||||||
print(j['messages'])
|
|
||||||
if i.id in j['messages']:
|
|
||||||
ai = True
|
|
||||||
ai_ = j['cai']
|
|
||||||
ai__ = h
|
|
||||||
break
|
|
||||||
h+=1
|
|
||||||
if message.author.name != client.user.name:
|
if message.author.name != client.user.name:
|
||||||
if message.content == "":
|
if message.content == "":
|
||||||
return
|
return
|
||||||
|
@ -99,26 +71,6 @@ async def on_message(message):
|
||||||
print(YELLOW + "<"+message.author.name+" ("+message.channel.name+"@"+message.server.name+ " {" + message.server.id +"})> "+RESET+message.content)
|
print(YELLOW + "<"+message.author.name+" ("+message.channel.name+"@"+message.server.name+ " {" + message.server.id +"})> "+RESET+message.content)
|
||||||
if message.author.name == client.user.name or message.author.bot:
|
if message.author.name == client.user.name or message.author.bot:
|
||||||
return
|
return
|
||||||
if ai:
|
|
||||||
try:
|
|
||||||
chat = cai.connect()
|
|
||||||
if message.content == "$more":
|
|
||||||
mess = await message.reply(embed=guilded.Embed(title=":sweebot-loading: Requesting more..."))
|
|
||||||
message2 = chat.send_message(
|
|
||||||
caibot, ai_.chat_id, ""
|
|
||||||
)
|
|
||||||
await mess.edit(embed=guilded.Embed(title=":sweebot-success: Requested more.", description=message2.text))
|
|
||||||
chats[ai__]['messages'].append(mess.id)
|
|
||||||
else:
|
|
||||||
mess = await message.reply(embed=guilded.Embed(title=":sweebot-loading: Replying..."))
|
|
||||||
message2 = chat.send_message(
|
|
||||||
caibot, ai_.chat_id, "--Guilded receive--\n" + "<" + message.author.name + "> " + message.content
|
|
||||||
)
|
|
||||||
await mess.edit(embed=guilded.Embed(title=":sweebot-success: Successfully replied.", description=message2.text))
|
|
||||||
chats[ai__]['messages'].append(mess.id)
|
|
||||||
except:
|
|
||||||
mess = await message.reply(embed=guilded.Embed(title=":sweebot-fail: Command failed!",description=traceback.format_exc()))
|
|
||||||
print("[" + RED + "FAIL" + RESET + "] Command failed, check chat for traceback.")
|
|
||||||
elif message.content[0] == "$":
|
elif message.content[0] == "$":
|
||||||
try:
|
try:
|
||||||
command=message.content[1:].split(" ")
|
command=message.content[1:].split(" ")
|
||||||
|
@ -239,20 +191,6 @@ async def on_message(message):
|
||||||
embeds.append(guilded.Embed(description=i))
|
embeds.append(guilded.Embed(description=i))
|
||||||
await message.reply("Search results:" ,embed=guilded.Embed(description="\n".join(result)))
|
await message.reply("Search results:" ,embed=guilded.Embed(description="\n".join(result)))
|
||||||
print("[" + GREEN + "OK" + RESET + "] '$search' executed successfully.")
|
print("[" + GREEN + "OK" + RESET + "] '$search' executed successfully.")
|
||||||
elif command[0] == "ai-chat":
|
|
||||||
chat = cai.connect()
|
|
||||||
mess = await message.reply(embed=guilded.Embed(title=":sweebot-loading: Creating new AI chat."))
|
|
||||||
new, answer = chat.new_chat(
|
|
||||||
caibot, me.id
|
|
||||||
)
|
|
||||||
text = " ".join(command[1:])
|
|
||||||
message2 = chat.send_message(
|
|
||||||
caibot, new.chat_id, "--Guilded receive--\n" + "<" + message.author.name + ">" + text
|
|
||||||
)
|
|
||||||
await mess.edit(embed=guilded.Embed(title=":sweebot-success: New AI chat created.", description=message2.text))
|
|
||||||
chats.append({"messages": [mess.id], "cai": new})
|
|
||||||
elif command[0] == "more":
|
|
||||||
raise SweeBotAIException("Please reply to an AI message with `$more` instead of calling it without a reply.")
|
|
||||||
else:
|
else:
|
||||||
mess = await message.reply(embed=guilded.Embed(title=":sweebot-unknown: Command not found."))
|
mess = await message.reply(embed=guilded.Embed(title=":sweebot-unknown: Command not found."))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue