mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
🐛 fix(ChatProcess.py): fix logic error in the return criteria for determining if the bot should respond to a message 🐛 fix(ChatProcess.py): fix typo in the 'functions' variable name 🐛 fix(ChatProcess.py): fix typo in the 'functions' parameter name in the request function call 🐛 fix(ChatProcess.py): fix typo in the 'functions' parameter name in the processFunctioncallResponse function call 🐛 fix(ChatProcess.py): remove unnecessary print statement in the processMessage function 🐛 fix(prompts.py): remove unnecessary print statement in the createPrompt function 🐛 fix(channelSetup.py): fix logic error in the is_owner function call 🐛 fix(moderation.py): remove unnecessary code for disabling moderation 🐛 fix(config.py): remove unnecessary code for creating tables in the database 🐛 fix(functionscalls.py): fix type hint for the return value of the call_function function 🐛 fix(guild.py): fix handling of serialized data in the load function 🐛 fix(SqlConnector.py): create setup_data table if it does not exist
71 lines
1.5 KiB
Python
71 lines
1.5 KiB
Python
import logging
|
|
import sqlite3
|
|
import json
|
|
from dotenv import load_dotenv
|
|
import os
|
|
|
|
# Loading environement variables
|
|
load_dotenv()
|
|
|
|
perspective_api_key = os.getenv("PERSPECTIVE_API_KEY")
|
|
discord_token = os.getenv("DISCORD_TOKEN")
|
|
webhook_url = os.getenv("WEBHOOK_URL")
|
|
max_uses: int = 400
|
|
tenor_api_key = os.getenv("TENOR_API_KEY")
|
|
|
|
# Logging
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
# Setting up the google vision api
|
|
os.environ[
|
|
"GOOGLE_APPLICATION_CREDENTIALS"
|
|
] = "./../database/google-vision/botator.json"
|
|
|
|
# Defining a debug function
|
|
|
|
|
|
def debug(message):
|
|
if os.name == "nt":
|
|
logging.info(message)
|
|
else:
|
|
print(message)
|
|
|
|
|
|
def ctx_to_guid(ctx):
|
|
if ctx.guild is None:
|
|
return ctx.author.id
|
|
else:
|
|
return ctx.guild.id
|
|
|
|
|
|
def mg_to_guid(mg):
|
|
if mg.guild is None:
|
|
return mg.author.id
|
|
else:
|
|
return mg.guild.id
|
|
|
|
|
|
con_premium = sqlite3.connect("./database/premium.db")
|
|
curs_premium = con_premium.cursor()
|
|
|
|
# This code creates the data table if it does not exist
|
|
curs_premium.execute(
|
|
"""CREATE TABLE IF NOT EXISTS data (user_id text, guild_id text, premium boolean)"""
|
|
)
|
|
|
|
# This code creates the channels table if it does not exist
|
|
curs_premium.execute(
|
|
"""CREATE TABLE IF NOT EXISTS channels (guild_id text, channel0 text, channel1 text, channel2 text, channel3 text, channel4 text)"""
|
|
)
|
|
"""
|
|
|
|
with open(
|
|
os.path.abspath(
|
|
os.path.join(os.path.dirname(__file__), "./prompts/gpt-3.5-turbo.txt")
|
|
),
|
|
"r",
|
|
encoding="utf-8",
|
|
) as file:
|
|
gpt_3_5_turbo_prompt = file.read()
|
|
"""
|