Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantouisyummy committed May 6, 2024
2 parents fa34826 + 5a072d3 commit 2cc5525
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 335 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOKEN=""
24 changes: 24 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
tags:
- 'v*'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build the Docker image
run: docker build . --file Dockerfile -t ghcr.io/mantou-9487/keyword:latest

- name: Login to GitHub Registry
run: echo "${{ secrets.DOCKER_GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push to GitHub Registry
run: docker push ghcr.io/mantou-9487/keyword:latest
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# 首先,使用 multi-stage build 來減少最終映像的大小
FROM python:3.11.5-slim as build

ENV PIP_DEFAULT_TIMEOUT=100 \
Expand All @@ -10,18 +9,18 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
RUN mkdir -p /keyword
WORKDIR /keyword

# 安裝 Poetry 並安裝依賴

COPY pyproject.toml poetry.lock ./
RUN pip install "poetry==$POETRY_VERSION" \
&& poetry install --no-root --no-ansi --no-interaction \
&& poetry export -f requirements.txt -o requirements.txt

# 最終階段

FROM python:3.11.5-slim as Final

WORKDIR /keyword

# 複製依賴並安裝

COPY --from=build /keyword/requirements.txt .
RUN set -ex \
&& addgroup --system --gid 1001 appgroup \
Expand All @@ -35,9 +34,9 @@ RUN set -ex \
&& rm requirements.txt \
&& rm -rf /root/.cache/pip/*

# 複製程式碼並設置運行命令

COPY .env .env
COPY /guild /guild
COPY . .

CMD [ "python3", "main.py" ]
CMD [ "python3", "main.py" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# KeyWord
A Discord Keyword Notification Bot.
30 changes: 15 additions & 15 deletions core/bot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from logging import Logger

from disnake.ext.commands import Bot as OriginalBot



class Bot(OriginalBot):
def __init__(self, logger: Logger, **kwargs):
super().__init__(**kwargs)

self.logger = logger

async def on_ready(self):
self.logger.info("The bot is ready! Logged in as %s" % self.user)

from logging import Logger

from disnake.ext.commands import Bot as OriginalBot



class Bot(OriginalBot):
def __init__(self, logger: Logger, **kwargs):
super().__init__(**kwargs)

self.logger = logger

async def on_ready(self):
self.logger.info("The bot is ready! Logged in as %s" % self.user)
66 changes: 33 additions & 33 deletions core/embeds.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
from disnake import Embed

# pylint: disable=C0116
# pylint: disable=C0115

class SuccessEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="✅ | " + title, description=description, color=0x0f9d58, **kwargs)
self._files = {}


class InfoEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="ℹ️ | " + title, description=description, color=0x4285f4, **kwargs)


class LoadingEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="⌛ | " + title, description=description, color=0x4285F4, **kwargs)


class WarningEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="⚠ | " + title, description=description, color=0xf4b400, **kwargs)


class ErrorEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="❌ | " + title, description=description, color=0xdb4437, **kwargs)

class HelpEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title=title, description=description, color=0xdb4437, **kwargs)
from disnake import Embed

# pylint: disable=C0116
# pylint: disable=C0115

class SuccessEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="✅ | " + title, description=description, color=0x0f9d58, **kwargs)
self._files = {}


class InfoEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="ℹ️ | " + title, description=description, color=0x4285f4, **kwargs)


class LoadingEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="⌛ | " + title, description=description, color=0x4285F4, **kwargs)


class WarningEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="⚠ | " + title, description=description, color=0xf4b400, **kwargs)


class ErrorEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title="❌ | " + title, description=description, color=0xdb4437, **kwargs)

class HelpEmbed(Embed):
def __init__(self, title: str, description: str = None, **kwargs):
super().__init__(title=title, description=description, color=0xdb4437, **kwargs)
Loading

0 comments on commit 2cc5525

Please sign in to comment.