File tree 7 files changed +96
-31
lines changed
7 files changed +96
-31
lines changed Original file line number Diff line number Diff line change 1
1
# Separate "build" image
2
- FROM python:3.11-slim-bullseye as compile-image
2
+ FROM python:3.11-slim-bookworm as compile-image
3
3
RUN python -m venv /opt/venv
4
4
ENV PATH="/opt/venv/bin:$PATH"
5
5
COPY requirements.txt .
6
6
RUN pip install --no-cache-dir --upgrade pip \
7
7
&& pip install --no-cache-dir -r requirements.txt
8
8
9
9
# "Run" image
10
- FROM python:3.11-slim-bullseye
11
- COPY --from=compile-image /opt/venv /opt/venv
12
- ENV PATH="/opt/venv/bin:$PATH"
10
+ FROM gcr.io/distroless/python3
13
11
WORKDIR /app
12
+ COPY --from=compile-image /opt/venv /app/venv
13
+ ENV PYTHONPATH="/app/venv/lib/python3.11/site-packages"
14
14
COPY bot /app/bot
15
- CMD ["python" , " -m" , "bot" ]
15
+ CMD ["-m" , "bot" ]
Original file line number Diff line number Diff line change 1
1
MIT License
2
2
3
- Copyright (c) 2019-2023 Groosha (also known as MasterGroosha on GitHub)
3
+ Copyright (c) 2019-2024 Groosha (also known as MasterGroosha on GitHub)
4
4
5
5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ This is a simple bot written with [aiogram 3.x](https://github.com/aiogram/aiogr
15
15
* Group to supergroup migrate information (both old and new ID).
16
16
17
17
## Requirements:
18
- * Python 3.9 and newer;
18
+ * Python 3.11 and newer;
19
19
* Linux (should work on Windows, but not tested);
20
20
* Systemd init system (optional).
21
21
* Docker (optional).
Original file line number Diff line number Diff line change 3
3
4
4
import structlog
5
5
from aiogram import Bot , Dispatcher
6
+ from aiogram .client .default import DefaultBotProperties
7
+ from aiogram .enums import ParseMode
6
8
from structlog .typing import FilteringBoundLogger
7
9
8
10
from bot .config_reader import bot_config , log_config
18
20
async def main ():
19
21
structlog .configure (** get_structlog_config (log_config ))
20
22
21
- bot = Bot (bot_config .bot_token .get_secret_value (), parse_mode = "HTML" )
23
+ bot = Bot (
24
+ bot_config .bot_token .get_secret_value (),
25
+ default = DefaultBotProperties (
26
+ parse_mode = ParseMode .HTML ,
27
+ )
28
+ )
22
29
23
30
# Setup dispatcher and bind routers to it
24
31
dp = Dispatcher ()
Original file line number Diff line number Diff line change 1
- from enum import Enum
1
+ from enum import StrEnum , auto
2
2
3
- from pydantic import BaseSettings , SecretStr
3
+ from pydantic import SecretStr
4
+ from pydantic_settings import BaseSettings , SettingsConfigDict
4
5
5
6
6
- class ModeEnum (str , Enum ):
7
- DEVELOPMENT = "dev"
8
- PRODUCTION = "prod"
9
-
10
-
11
- class LoggingRenderer (str , Enum ):
12
- JSON = "json"
13
- CONSOLE = "console"
7
+ class LoggingRenderer (StrEnum ):
8
+ JSON = auto ()
9
+ CONSOLE = auto ()
14
10
15
11
16
12
class LoggingSettings (BaseSettings ):
@@ -20,18 +16,22 @@ class LoggingSettings(BaseSettings):
20
16
renderer : LoggingRenderer = LoggingRenderer .JSON
21
17
log_unhandled : bool = False
22
18
23
- class Config :
24
- env_file = '.env'
25
- env_file_encoding = 'utf-8'
26
- env_prefix = "LOGGING_"
19
+ model_config = SettingsConfigDict (
20
+ env_file = ".env" ,
21
+ env_file_encoding = "UTF-8" ,
22
+ env_prefix = "LOGGING_" ,
23
+ extra = "allow" ,
24
+ )
27
25
28
26
29
27
class BotSettings (BaseSettings ):
30
28
bot_token : SecretStr
31
29
32
- class Config :
33
- env_file = '.env'
34
- env_file_encoding = 'utf-8'
30
+ model_config = SettingsConfigDict (
31
+ env_file = ".env" ,
32
+ env_file_encoding = "UTF-8" ,
33
+ extra = "allow" ,
34
+ )
35
35
36
36
37
37
bot_config = BotSettings ()
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ After=network.target
5
5
[Service]
6
6
Type =simple
7
7
WorkingDirectory =/home/user/my-id-bot
8
+ EnvironmentFile =/home/user/my-id-bot/.env
8
9
ExecStart =/home/user/my-id-bot/venv/bin/python -m bot
9
10
KillMode =process
10
11
Restart =always
Original file line number Diff line number Diff line change 1
- aiogram == 3.0.0b7
2
- cachetools == 5.3.0
3
- python-dotenv == 1.0.0
4
- pydantic == 1.10.6
5
- fluent.runtime == 0.4.0
6
- structlog == 22.3.0
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile requirements.in -o requirements.txt
3
+ aiofiles == 23.2.1
4
+ # via aiogram
5
+ aiogram == 3.12.0
6
+ # via -r requirements.in
7
+ aiohappyeyeballs == 2.3.5
8
+ # via aiohttp
9
+ aiohttp == 3.10.3
10
+ # via aiogram
11
+ aiosignal == 1.3.1
12
+ # via aiohttp
13
+ annotated-types == 0.7.0
14
+ # via pydantic
15
+ attrs == 24.2.0
16
+ # via
17
+ # aiohttp
18
+ # fluent-runtime
19
+ babel == 2.16.0
20
+ # via fluent-runtime
21
+ cachetools == 5.4.0
22
+ # via -r requirements.in
23
+ certifi == 2024.7.4
24
+ # via aiogram
25
+ fluent-runtime == 0.4.0
26
+ # via -r requirements.in
27
+ fluent-syntax == 0.19.0
28
+ # via fluent-runtime
29
+ frozenlist == 1.4.1
30
+ # via
31
+ # aiohttp
32
+ # aiosignal
33
+ idna == 3.7
34
+ # via yarl
35
+ magic-filter == 1.0.12
36
+ # via aiogram
37
+ multidict == 6.0.5
38
+ # via
39
+ # aiohttp
40
+ # yarl
41
+ pydantic == 2.8.2
42
+ # via
43
+ # aiogram
44
+ # pydantic-settings
45
+ pydantic-core == 2.20.1
46
+ # via pydantic
47
+ pydantic-settings == 2.4.0
48
+ # via -r requirements.in
49
+ python-dotenv == 1.0.1
50
+ # via pydantic-settings
51
+ pytz == 2024.1
52
+ # via fluent-runtime
53
+ structlog == 24.4.0
54
+ # via -r requirements.in
55
+ typing-extensions == 4.12.2
56
+ # via
57
+ # aiogram
58
+ # fluent-runtime
59
+ # fluent-syntax
60
+ # pydantic
61
+ # pydantic-core
62
+ yarl == 1.9.4
63
+ # via aiohttp
You can’t perform that action at this time.
0 commit comments