mirror of
https://github.com/Redume/Shirino.git
synced 2024-11-23 16:56:23 +03:00
Compare commits
4 commits
c07fba01ad
...
0c1a42791a
Author | SHA1 | Date | |
---|---|---|---|
0c1a42791a | |||
416be2c451 | |||
ab18d1c265 | |||
c0e1698581 |
5 changed files with 90 additions and 9 deletions
6
.dockerignore
Normal file
6
.dockerignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.git/
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
__pycache__
|
49
.github/workflows/docker.yaml
vendored
Normal file
49
.github/workflows/docker.yaml
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
name: Create and publish a Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FROM python:3.12
|
||||||
|
|
||||||
|
WORKDIR /shirino
|
||||||
|
|
||||||
|
COPY ./requirements.txt .
|
||||||
|
|
||||||
|
RUN pip3 install --no-cache-dir --upgrade -r ./requirements.txt
|
||||||
|
|
||||||
|
COPY ./ /shirino/
|
||||||
|
|
||||||
|
CMD ["python", "main.py"]
|
5
docker-compose.yaml
Normal file
5
docker-compose.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
services:
|
||||||
|
shirino:
|
||||||
|
build: .
|
||||||
|
image: ghcr.io/shirino/shirino:latest
|
||||||
|
restart: unless-stopped
|
28
main.py
28
main.py
|
@ -26,12 +26,17 @@ async def currency(query: types.Message | types.InlineQuery) -> None:
|
||||||
conv = Converter()
|
conv = Converter()
|
||||||
|
|
||||||
if len(args) <= 1:
|
if len(args) <= 1:
|
||||||
if query.chat.type not in ['supergroup', 'group']:
|
try:
|
||||||
return await reply(result_id,
|
if query.chat.type in ['supergroup', 'group']:
|
||||||
"2 or 3 arguments are required.",
|
return
|
||||||
"@shirino_bot USD RUB "
|
except:
|
||||||
"\n@shirino_bot 12 USD RUB",
|
pass
|
||||||
query)
|
|
||||||
|
return await reply(result_id,
|
||||||
|
"2 or 3 arguments are required.",
|
||||||
|
"@shirino_bot USD RUB "
|
||||||
|
"\n@shirino_bot 12 USD RUB",
|
||||||
|
query)
|
||||||
if len(args) == 4:
|
if len(args) == 4:
|
||||||
conv.amount = float(args[0])
|
conv.amount = float(args[0])
|
||||||
from_currency_alias = args[1].lower()
|
from_currency_alias = args[1].lower()
|
||||||
|
@ -44,8 +49,13 @@ async def currency(query: types.Message | types.InlineQuery) -> None:
|
||||||
from_currency_alias = args[0].lower()
|
from_currency_alias = args[0].lower()
|
||||||
conv_currency_alias = args[1].lower()
|
conv_currency_alias = args[1].lower()
|
||||||
else:
|
else:
|
||||||
if query.chat.type not in ['supergroup', 'group']:
|
try:
|
||||||
return await reply(result_id, 'The source and target currency could not be determined.', None, query)
|
if query.chat.type in ['supergroup', 'group']:
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return await reply(result_id, 'The source and target currency could not be determined.', None, query)
|
||||||
|
|
||||||
from_currency, conv_currency = None, None
|
from_currency, conv_currency = None, None
|
||||||
|
|
||||||
|
@ -93,7 +103,7 @@ async def reply(result_id: str | None, title: str | None, desc, query: types.Inl
|
||||||
is_personal=True,
|
is_personal=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await query.answer(title)
|
await query.answer(f'{title} \n{desc}')
|
||||||
|
|
||||||
|
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue