Skip to content

Commit 1855f90

Browse files
authored
Merge pull request #14 from Amaimersion/v1.3.0
v1.3.0
2 parents a7e607d + b83a703 commit 1855f90

File tree

103 files changed

+6186
-914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+6186
-914
lines changed

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# You don't need to include every item in this file.
2+
# You need to includes items that 100% shouldn't
3+
# be in build context. You should avoid using `COPY . .`
4+
# in order to not leak sensitive information. Instead,
5+
# always specify items explicitly.
6+
7+
# Files
8+
.env*
9+
**/*.md
10+
**/*.egg-info
11+
**/*.pyc
12+
**/*.log
13+
**/temp.*
14+
**/*.sqlite
15+
**/*.sqlite-journal
16+
**/*.mo
17+
18+
# Folders
19+
**/__pycache__
20+
**/temp
21+
venv
22+
instance
23+
var
24+
.git

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
1010

11-
[*.{html,css,md,sh,conf,ini}]
11+
[*.{html,css,md,sh,conf,ini,yml,yaml}]
1212
indent_size = 2

.env.example

Lines changed: 95 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,111 @@
1-
# Single secret key
2-
# You must generate it like this as follows
3-
# in order to use `cryptography` package:
1+
# Based on this file you can create your own
2+
# `.env.development` or `.env.production`.
3+
# Next will be described expected environment variables.
4+
# In final file you also can put any arbitrary environment variables
5+
# (for example, specific for Docker containers, app configuration,
6+
# external software configuration, etc.).
7+
# If some env variable shouldn't be presented, then just delete it.
8+
# "If you use docker image" means that you are using Docker locally,
9+
# through "docker" or "docker-compose".
10+
11+
12+
### Required
13+
14+
# Single secret key.
15+
# Don't lose it, otherwise you will be not able to
16+
# interact with existing database.
17+
# You must generate it as follows in order
18+
# to use `cryptography` package:
419
# ```
5-
# from cryptography.fernet import Fernet
6-
# key = Fernet.generate_key().decode()
7-
# print(key)
20+
# python manage.py generate-secret-key
821
# ```
922
FLASK_SECRET_KEY=
1023

1124
# Address of database.
12-
# PostgreSQL is expected in production, but not required
25+
# PostgreSQL is expected in production, but not required.
26+
# For local SQLite you can specify a path. For example,
27+
# `sqlite:///development.sqlite` will put `development.sqlite`
28+
# in `src` folder (because relative to the app).
1329
DATABASE_URL=postgresql+psycopg2://<user>:<password>@<host>:<port>/<db_name>
1430

15-
# Address of Redis server. Optional.
31+
# API token received from @BotFather for Telegram bot.
32+
TELEGRAM_API_BOT_TOKEN=
33+
34+
# ID of app registerd in Yandex to access Yandex OAuth API.
35+
YANDEX_OAUTH_API_APP_ID=
36+
37+
# Password of app registerd in Yandex to access Yandex OAuth API.
38+
YANDEX_OAUTH_API_APP_PASSWORD=
39+
40+
###
41+
42+
43+
### Required if you use Postgres docker image
44+
45+
# Name of user that will own DB.
46+
# Use this value in `DATABASE_URL`.
47+
POSTGRES_USER=
48+
49+
# Password of user that will own DB.
50+
# Use this value in `DATABASE_URL`.
51+
POSTGRES_PASSWORD=
52+
53+
# Name of DB that will store data.
54+
# Use this value in `DATABASE_URL`.
55+
POSTGRES_DB=
56+
57+
###
58+
59+
60+
### Required if you use amaimersion/yd-tg-bot-rq docker image
61+
62+
# Number of RQ workers that will handle background tasks.
63+
# Each worker can perform one task at a time.
64+
# Read RQ documentation to set appropriate value.
65+
# Keep in mind that each worker instance creates its own fork,
66+
# which means significant usage of your computer resources.
67+
# So, monitor usage of your computer resources.
68+
# Start with 2 or 3 if you don't sure what you need.
69+
RQ_WORKERS=
70+
71+
###
72+
73+
74+
### Optional
75+
76+
# Add postfix to final URL of Telegram webhook route.
77+
# For example, initially app uses `/webhook` URL.
78+
# You can set this variable to `_aslv123`.
79+
# And the app will use this URL `/webhook_aslv123`.
80+
TELEGRAM_API_WEBHOOK_URL_POSTFIX=
81+
82+
# Address of Redis server.
1683
# If address will be specified, then the app will assume
1784
# that valid instance of Redis server is running, and the app
1885
# will not make any checks (like `PING`). So, make sure you
1986
# pointing to valid Redis instance.
87+
# If you want to point to Docker container that is placed
88+
# in the same network as the app container, then you should
89+
# use container DNS name. For example, `redis://redis-container:6379`.
2090
REDIS_URL=
2191

22-
# API token received from @BotFather for Telegram bot
23-
TELEGRAM_API_BOT_TOKEN=
92+
# Number of gunicorn workers.
93+
# Read gunicorn documentation to set appropriate value.
94+
# Use "-1" for "auto".
95+
# Keep in mind that each worker instance creates its own fork,
96+
# which means significant usage of your computer resources.
97+
# So, monitor usage of your computer resources.
98+
# Most likely you don't need high values.
99+
# Start with 1 or 2.
100+
GUNICORN_WORKERS=
24101

25-
# ID of app registerd in Yandex to access Yandex OAuth API
26-
YANDEX_OAUTH_API_APP_ID=
102+
# Number of connections for each gunicorn worker.
103+
# Read gunicorn documentation to set appropriate value.
104+
GUNICORN_WORKER_CONNECTIONS=
27105

28-
# Password of app registerd in Yandex to access Yandex OAuth API
29-
YANDEX_OAUTH_API_APP_PASSWORD=
30-
31-
# Your UA for Google Analytics. Optional
106+
# Your UA for Google Analytics.
107+
# Google Analytics is used in some app components to collect
108+
# and analyze usage info.
32109
GOOGLE_ANALYTICS_UA=UA-XXXX-X
110+
111+
###

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
**/temp.*
55
*.sqlite
66
*.sqlite-journal
7+
**/*.mo
78

89
# Folders
910
__pycache__
@@ -13,5 +14,6 @@ venv
1314

1415
# Secrets
1516
instance
17+
var
1618
.env*
1719
!.env.example

.slugignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
.editorconfig
33
.env.example
44
.flake8
5+
.dockerignore
6+
Dockerfile
7+
docker-compose.yml
58
CHANGELOG.md
9+
CHANGELOG.APP.md
610
LICENSE
711
README.md
812

913
# Folders
1014
.vscode
1115
info
1216
.github
17+
docker
18+
var

CHANGELOG.APP.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
This changelog includes records about notable changes that are only visible from developer side. Such records require some technical expertise to properly understand them. To see changelog from end user side, see [changelog for end users](CHANGELOG.md).
2+
___
3+
4+
5+
# 1.3.0 (August 27, 2021)
6+
7+
## Added
8+
9+
- Support for `callback_query` Telegram update.
10+
- Support for user settings.
11+
- Support for translations.
12+
- `gunicorn` will support IP socket configuration through `GUNICORN_USE_IP_SOCKET` and `GUNICORN_PORT` env variables.
13+
- path of unix socket for `gunicorn` server can be changed through `GUNICORN_UNIX_SOCKET_PATH` env variable.
14+
- Docker images.
15+
- Support for docker-compose.
16+
- Information about project version naming.
17+
- Short name in information about the app.
18+
- Logger settings for `Flask` and `gunicorn`. Set it through env variables.
19+
- Debug logs.
20+
21+
## Changed
22+
23+
- Big refactoring.
24+
- Changelog splitted into two files: one for end users and one for developers.
25+
- Changelog will no longer contain `Improved` section. It will be merged with `Changed` section.
26+
- DB data about incoming Telegram user will be fetched on every request, before dispatching of request to appropriate handler.
27+
- `language` column moved from `User` model to `UserSettings`.
28+
- Background tasks will have copy of request `g` data.
29+
- Worker for background tasks should be started with `python manage.py run-worker` instead of `python worker.py`.
30+
- To add webhook URL postfix use `TELEGRAM_API_WEBHOOK_URL_POSTFIX` env variable, from now don't edit `views.py` file and revert it back.
31+
- SQLAlchemy debug echo will be disabled by default. Use `SQLALCHEMY_ECHO` env variable to control it.
32+
- Python runtime version to 3.8.11.
33+
- `src.api` module renamed to `src.http`.
34+
35+
## Fixed
36+
37+
- `/telegram_bot/yandex_disk_authorization` with trailing slash at the end (i.e., `/telegram_bot/yandex_disk_authorization/`) will be handled correctly.
38+
- Invalid DB migrations for PostgreSQL. More specifically, these migrations didn't really change enum values. That bug was not noticeable, because new enum values wasn't actually used at all. For SQLite everything was ok. To fix invalid PostgreSQL schema, run `flask db downgrade 358b1cefda13 && flask db upgrade`. You will not lose your current data (at the moment of `20dfdf679e84` migration).
39+
40+
41+
# 1.2.0 (December 14, 2020)
42+
43+
## Improved
44+
45+
- Upgrade `python` to 3.8.5.
46+
- All requirements upgraded to latest version.
47+
- Big refactoring.
48+
49+
## Added
50+
51+
- Stateful chat support. Now bot can store custom user data (in different namespaces: user, chat, user in chat); determine Telegram message types; register single use handler (call once for message) with optional timeout for types of message; subscribe handlers with optional timeout for types of messages.
52+
- [Console Client](https://yandex.ru/dev/oauth/doc/dg/reference/console-client.html) Yandex.OAuth method. By default it is disabled, and default one is [Auto Code Client](https://yandex.ru/dev/oauth/doc/dg/reference/auto-code-client.html/).
53+
- RQ (job queue). It requires Redis to be enabled, and as Redis it is also optional. However, it is highly recommended to use it.
54+
- Support for different env-type files (based on current environment). Initially it was only for production.
55+
- Web Site: 302 (redirect to Telegram) will be returned instead of 404 (not found page), but only in production mode.
56+
- Debug configuration for VSCode.
57+
- DB: add indexes for frequent using columns.
58+
59+
## Changed
60+
61+
- Redirect to favicon will be handled by nginx.
62+
- Biggest photo (from single photo file) will be selected based on total pixels count, not based on height.
63+
64+
## Fixed
65+
66+
- A bug when new user (didn't use any command before) used `/revoke_access` command and it led to request crash (500).
67+
- Situation: Telegram send an update, the server sent back a 500; Telegram will send same update again and again until it get 200 from a server, but server always returns 500. Such sitations can occur, for example, when user initiated a command and blocked the bot - bot can't send message to user in this case (it gets 403 from Telegram API, so, server raises error because it is an unexpected error and should be logged). Now it is fixed and the bot always send back 200, even for such error situations.
68+
69+
70+
# 1.1.0 (May 9, 2020)
71+
72+
## Improved
73+
74+
- Big refactoring of everything.
75+
- File structure.
76+
- Upgrade `gevent` to 1.5.0.
77+
78+
## Added
79+
80+
- `SERVER_NAME` environment variable.
81+
- Google Analytics in authorization pages.
82+
- Templates for issues and pull requests.
83+
- `robots.txt`.
84+
85+
## Changed
86+
87+
- Decreased size of slug on Heroku by removing unused files and folders.
88+
- Decreased number of seconds for Yandex.OAuth request timeout.
89+
- Redirects and generated URL's always will be absolute URL's with `PREFERRED_URL_SCHEME + SERVER_NAME`.
90+
- If user refused to grant the access to Yandex.Disk, then user `insert_token` will be cleared after redirect.
91+
92+
93+
# 1.0.0 (April 15, 2020)
94+
95+
Initial release!

0 commit comments

Comments
 (0)