mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
Merge branch 'main' into dev
This commit is contained in:
48
.github/workflows/buildDockerImage.yml
vendored
48
.github/workflows/buildDockerImage.yml
vendored
@@ -5,17 +5,59 @@ name: Build Docker Image
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build Docker image
|
- name: Build Docker image with sha
|
||||||
run: |
|
run: |
|
||||||
docker build -t ${{ secrets.DOCKER_USERNAME }}/botator:${{ github.sha }} .
|
docker build -t ${{ secrets.DOCKER_USERNAME }}/botator:${{ github.sha }} .
|
||||||
|
|
||||||
|
- name: Build Docker image with latest
|
||||||
|
run: |
|
||||||
|
docker build -t ${{ secrets.DOCKER_USERNAME }}/botator:latest .
|
||||||
|
|
||||||
- name: Push Docker image to Docker Hub
|
- name: Push Docker image to Docker Hub
|
||||||
run: |
|
run: |
|
||||||
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||||
docker push ${{ secrets.DOCKER_USERNAME }}/botator:${{ github.sha }}
|
docker push ${{ secrets.DOCKER_USERNAME }}/botator:${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Push Docker image latest to Docker Hub
|
||||||
|
run: |
|
||||||
|
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||||
|
docker push ${{ secrets.DOCKER_USERNAME }}/botator:latest
|
||||||
|
|
||||||
|
build_arm64:
|
||||||
|
# This is the job for arm64 architecture
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
# We are using qemu to emulate arm64 architecture
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ secrets.DOCKER_USERNAME }}/botator_arm64:${{ github.sha }}
|
||||||
|
- name: Build and push latest
|
||||||
|
id: docker_build_latest
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ secrets.DOCKER_USERNAME }}/botator_arm64:latest
|
||||||
@@ -20,6 +20,8 @@ def debug(message):
|
|||||||
# if the os is windows, we logging.info(message), if
|
# if the os is windows, we logging.info(message), if
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
logging.info(message)
|
logging.info(message)
|
||||||
|
else:
|
||||||
|
printf(message)
|
||||||
|
|
||||||
|
|
||||||
# connect to the database
|
# connect to the database
|
||||||
|
|||||||
@@ -398,16 +398,16 @@ async def gpt_prompt(bot, messages, message, data_dict, prompt, guild_data):
|
|||||||
):
|
):
|
||||||
for attachment in msg.attachments:
|
for attachment in msg.attachments:
|
||||||
path = f"./../database/google-vision/results/{attachment.id}.txt"
|
path = f"./../database/google-vision/results/{attachment.id}.txt"
|
||||||
if images_usage >= 6 and guild_data["premium"] == 0:
|
if data_dict['images_usage'] >= 6 and guild_data["premium"] == 0:
|
||||||
guild_data["images_limit_reached"] = True
|
guild_data["images_limit_reached"] = True
|
||||||
elif images_usage >= 30 and guild_data["premium"] == 1:
|
elif data_dict['images_usage'] >= 30 and guild_data["premium"] == 1:
|
||||||
guild_data["images_limit_reached"] = True
|
guild_data["images_limit_reached"] = True
|
||||||
if (
|
if (
|
||||||
attachment.url.endswith((".png", ".jpg", ".jpeg", ".gif"))
|
attachment.url.endswith((".png", ".jpg", ".jpeg", ".gif"))
|
||||||
and not guild_data["images_limit_reached"]
|
and not guild_data["images_limit_reached"]
|
||||||
and not os.path.exists(path)
|
and not os.path.exists(path)
|
||||||
):
|
):
|
||||||
images_usage += 1
|
data_dict['images_usage'] += 1
|
||||||
analysis = await vision_processing.process(attachment)
|
analysis = await vision_processing.process(attachment)
|
||||||
if analysis != None:
|
if analysis != None:
|
||||||
content = f"{content} \n\n {analysis}"
|
content = f"{content} \n\n {analysis}"
|
||||||
@@ -446,7 +446,7 @@ async def gpt_prompt(bot, messages, message, data_dict, prompt, guild_data):
|
|||||||
)
|
)
|
||||||
curs_data.execute(
|
curs_data.execute(
|
||||||
"UPDATE images SET usage_count = ? WHERE guild_id = ?",
|
"UPDATE images SET usage_count = ? WHERE guild_id = ?",
|
||||||
(images_usage, message.guild.id),
|
(data_dict['images_usage'], message.guild.id),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
msgs.append({"role": role, "content": f"{content}", "name": name})
|
msgs.append({"role": role, "content": f"{content}", "name": name})
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from google.cloud import vision
|
|||||||
try:
|
try:
|
||||||
client = vision.ImageAnnotatorClient()
|
client = vision.ImageAnnotatorClient()
|
||||||
except:
|
except:
|
||||||
debug("Google Vision API is not setup, please run /setup")
|
print("Google Vision API is not setup, please run /setup")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -64,4 +64,4 @@ async def process(attachment):
|
|||||||
return final
|
return final
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug("Error while processing image: " + str(e))
|
print("Error while processing image: " + str(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user