Added resetter

This commit is contained in:
Paillat
2022-12-10 23:40:35 +01:00
parent 32dbed4658
commit 222e3c5c80
2 changed files with 28 additions and 0 deletions

11
code/resetter.py Normal file
View File

@@ -0,0 +1,11 @@
import sqlite3
conn = sqlite3.connect('../database/data.db')
c = conn.cursor()
import time
#the database is: c.execute('''CREATE TABLE IF NOT EXISTS data (guild_id text, channel_id text, api_key text, is_active boolean, max_tokens integer, temperature real, frequency_penalty real, presence_penalty real, uses_count_today integer, prompt_size integer, prompt_prefix text, tts boolean, pretend_to_be text, pretend_enabled boolean)''')
#set the uses_count_today to 0 for all guilds every 24 hours
while True:
for row in c.execute('''SELECT * FROM data'''):
c.execute('''UPDATE data SET uses_count_today = 0 WHERE guild_id = ?''', (row[0],))
conn.commit()
time.sleep(86400)

View File

@@ -0,0 +1,17 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.10.0
# Keeps Python from generating .pyc files in the container
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
RUN git clone https://github.com/Paillat-dev/Botator.git
WORKDIR /Botator/code/
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /Botator/code
USER appuser
CMD ["python", "resetter.py"]