Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
cb8584d
🚚 Create src folder and move all the code into it
dzhalaevd Mar 7, 2024
1275b12
🔥 remove app.py
dzhalaevd Mar 7, 2024
26758d9
🎨 move registration func of the middleware and filters to bot.py
dzhalaevd Mar 7, 2024
336eb08
♻️ fix imports
dzhalaevd Mar 7, 2024
aedc7c7
🔧 update paths
dzhalaevd Mar 7, 2024
9563811
🔥 remove utils folder
dzhalaevd Mar 7, 2024
c454359
🧪 add falling tests
dzhalaevd Mar 7, 2024
5f00a56
🔥 remove states folder
dzhalaevd Mar 7, 2024
8d4a4e9
🔥 remove folders
dzhalaevd Mar 7, 2024
256fefa
♻️ fix imports
dzhalaevd Mar 7, 2024
dde289e
🔥 drop django
dzhalaevd Mar 24, 2024
276994b
🗑️ Move legacy code to deprecated folder for future cleanup
dzhalaevd Mar 24, 2024
bbc2a02
🔥 remove loader.py
dzhalaevd Mar 24, 2024
178534d
📝 Update "About" section
dzhalaevd Mar 24, 2024
70e5a34
🚧⬆️ Working on dependencies in the process
dzhalaevd Mar 24, 2024
8cf837f
🔥 remove deprecated tests
dzhalaevd Mar 24, 2024
475610a
🔥 remove localization
dzhalaevd Mar 24, 2024
252696c
🔥 drop django
dzhalaevd Mar 24, 2024
57c93b5
🔥 drop brandbook
dzhalaevd Mar 24, 2024
7cb7394
⚰️ remove interaction with db
dzhalaevd Mar 24, 2024
bc1faf4
🤡 Quiet and sound of tumbleweed
dzhalaevd Mar 24, 2024
f0107c2
♻️ minor fixes
dzhalaevd Mar 24, 2024
7e0b1cf
🏷️ add types file
dzhalaevd Mar 24, 2024
ac7dc3c
⚰️ remove dead code
dzhalaevd Mar 24, 2024
6cd9c81
🚧 Update code to work with new library version
dzhalaevd Mar 24, 2024
9b3d1f2
🚚 rename default folder to reply
dzhalaevd Mar 24, 2024
1adc7f1
✨ Add funcs for sending and broadcasting messages with error handling
dzhalaevd Mar 24, 2024
ac5abbd
✨ Add start handler
dzhalaevd Mar 24, 2024
72f8167
♻️ minor fixes
dzhalaevd Mar 24, 2024
45b8ee2
🎉 frontend for tg mini apps
dzhalaevd Apr 23, 2024
27244d6
⬆️ Upgrade dependencies
dzhalaevd Apr 23, 2024
43b105d
⚰️ remove requirements.txt
dzhalaevd Apr 23, 2024
1cf9868
📝 update badges
dzhalaevd Apr 23, 2024
7598d9e
🔧 remove unused var and add new env var
dzhalaevd Apr 23, 2024
645fe52
🔧 add black alias
dzhalaevd Apr 23, 2024
c7869d4
🗑️ deprecate code that needs to be cleaned up
dzhalaevd Apr 23, 2024
4c09128
⚰️ remove yoomoney
dzhalaevd Apr 23, 2024
6a6421c
♻️ minor fixes
dzhalaevd Apr 23, 2024
f2968c2
🏷️ update Handler type
dzhalaevd Apr 23, 2024
2028195
🏷️ add types
dzhalaevd Apr 23, 2024
70c4a8e
♻️ minor fixes
dzhalaevd Apr 23, 2024
4373c9c
🔥 remove files
dzhalaevd Apr 23, 2024
9caaf6c
🚧 rewriting middlewares
dzhalaevd Apr 23, 2024
52eaaca
💄 update commands
dzhalaevd Apr 23, 2024
e044bfe
✨ add func for handle user req
dzhalaevd Apr 23, 2024
8c528d7
♻️ minor fixes
dzhalaevd Apr 23, 2024
f5154d0
🏗️ update keyboards
dzhalaevd Apr 23, 2024
e7af919
♻️ minor fixes
dzhalaevd Apr 23, 2024
9d6d8a6
♻️ minor fixes
dzhalaevd Apr 23, 2024
f4a6fa4
🛂 generation signature for auth
dzhalaevd Apr 23, 2024
94be363
✨ add handler for signin/signup
dzhalaevd Apr 23, 2024
2325b89
📝 update description
dzhalaevd Apr 26, 2024
e2217fc
💄 update frontend
dzhalaevd Apr 26, 2024
e3c5764
📝 remove unused env var from table
dzhalaevd Apr 26, 2024
0265eed
🏷️ add types
dzhalaevd Apr 26, 2024
deba550
💄 add web app
dzhalaevd Apr 26, 2024
d2d39b7
✨ add about project handler
dzhalaevd Apr 26, 2024
10b315b
🚧 user handler
dzhalaevd Apr 26, 2024
a7f52d1
🚨 fix whitespace
dzhalaevd Apr 29, 2024
7b2d25c
🚨 fix whitespace
dzhalaevd Apr 29, 2024
768cc23
⬆️ upgrade dependencies
dzhalaevd Apr 29, 2024
85df676
🔧 add pre-commit
dzhalaevd Apr 29, 2024
3aab80b
🚨 ignore f403
dzhalaevd Apr 29, 2024
af16616
🏷️ add typing
dzhalaevd Apr 29, 2024
bcd0b0a
✨ add middleware for handle deactivated user and not auth
dzhalaevd Apr 29, 2024
ec26a1b
♻️ minor fixes
dzhalaevd Apr 29, 2024
eafefc5
🚧 on handlers
dzhalaevd Apr 29, 2024
149d262
🚨 fix mypy warnings
dzhalaevd Apr 29, 2024
7111ae6
⚰️ remove unused services
dzhalaevd May 6, 2024
0276f8a
⬆️ upgrade dependencies
dzhalaevd May 6, 2024
5a0f49c
💄 update login form
dzhalaevd May 6, 2024
2943b31
♻️ minor fixes
dzhalaevd May 6, 2024
fb13c9a
✨ add handler for login form
dzhalaevd May 6, 2024
fd13de7
improve performance
dzhalaevd May 6, 2024
d41fd18
⬆️ upgrade dependencies
dzhalaevd May 9, 2024
b6eb93a
🌐 add localization
dzhalaevd May 9, 2024
10db2e8
📝 update DEVELOPMENT.md
dzhalaevd May 9, 2024
4036ce1
✨ add i18n
dzhalaevd May 9, 2024
e5c9be7
🚧 developing profile
dzhalaevd May 9, 2024
4dae2f6
♻️ minor fixes
dzhalaevd May 9, 2024
50dc944
💄 add profile menu
dzhalaevd May 9, 2024
c7d682b
✨ add rate limiter
dzhalaevd May 10, 2024
fb3e147
🔧 add env var for redis
dzhalaevd May 10, 2024
9ce87be
🔧 update RedisConfig
dzhalaevd May 10, 2024
fc3d952
📝 update badges
dzhalaevd May 10, 2024
0308bbc
⬆️ upgrade dependencies
dzhalaevd May 16, 2024
4f20526
✅ add e2e tests
dzhalaevd May 16, 2024
0a60f0d
🧑‍💻 add helpers func for testing
dzhalaevd May 16, 2024
566a840
♻️ minor fixes
dzhalaevd May 16, 2024
3474dad
🔐 add env vars for testing
dzhalaevd May 16, 2024
6c26256
⚰️ remove dead external api
dzhalaevd Jun 6, 2024
d85bd3b
➕ add yandex-geo
dzhalaevd Jun 6, 2024
14f1cb5
⬆️ upgrade dependencies
dzhalaevd Jun 6, 2024
28ae7e7
♻️ refactor code
dzhalaevd Jun 6, 2024
e2f96b3
💄 update user menu
dzhalaevd Jun 6, 2024
2c9bbcd
🚧 add base implementation for profile
dzhalaevd Jun 6, 2024
e98dbb0
🚸 diff buttons in dependence on profile
dzhalaevd Jun 6, 2024
512ae12
🚨 fix import with isort
dzhalaevd Jun 14, 2024
b0e2ac2
🚚 move states.py to deprecated
dzhalaevd Jun 14, 2024
1af0e87
🚨 fix import with isort
dzhalaevd Jun 14, 2024
b6c9ee3
🚨 fix import with isort
dzhalaevd Jun 14, 2024
5e314e4
💡 add todo
dzhalaevd Jun 14, 2024
0f80812
💄 add new keyboards
dzhalaevd Jun 14, 2024
055633f
💡 add todo
dzhalaevd Jun 14, 2024
b9bb49c
🚧 add base form for fill profile
dzhalaevd Jun 14, 2024
5c1b653
🧑‍💻 add middleware for working with media groups
dzhalaevd Jun 14, 2024
501b83d
🚨 fix linter warnings
dzhalaevd Jun 14, 2024
9f53697
⚰️ remove dead states and add new
dzhalaevd Jun 14, 2024
bf053b9
💡 comment the registration of ThrottlingMiddleware
dzhalaevd Jun 14, 2024
4f0e7e2
🗑️ deprecate class that needs to be cleaned up
dzhalaevd Jun 16, 2024
be547d9
🚚 move exceptions from middlewares to misc
dzhalaevd Jun 16, 2024
9ede94b
♻️ minor fixes
dzhalaevd Jun 16, 2024
0410354
♻️ minor fixes
dzhalaevd Jun 16, 2024
e80800d
💄 add new menus
dzhalaevd Jun 16, 2024
49143b0
🚸 handling back button
dzhalaevd Jun 16, 2024
f1bd8cf
💬 update text
dzhalaevd Jun 16, 2024
1dd60d5
⬆️ update que-sdk to 0.2.0
dzhalaevd Jun 27, 2024
937052f
➕ add aiogram-calendar
dzhalaevd Jun 27, 2024
f8054df
⬆️ upgrade dependencies
dzhalaevd Jun 27, 2024
f5e7a87
🔧 add folder for photos
dzhalaevd Jun 27, 2024
49612d1
🙈 exclude .gitkeep from photos
dzhalaevd Jun 27, 2024
475aba2
💬 a more intuitive label for user
dzhalaevd Jun 27, 2024
37849b9
✨ add client for working with geo
dzhalaevd Jun 27, 2024
ea9392e
✨ update misc middleware for working with geo
dzhalaevd Jun 27, 2024
77e10ea
♻️ minor fixes
dzhalaevd Jun 27, 2024
9bcb90d
🔧 add var for working with geo client
dzhalaevd Jun 27, 2024
f5d0c8e
✨ add new field state
dzhalaevd Jun 27, 2024
f7429eb
💄 add new keyboard
dzhalaevd Jun 27, 2024
c4bf8c4
🚧 draft work: profile, user
dzhalaevd Jun 27, 2024
b8ce2e9
⬆️ que-sdk to 0.2.3
dzhalaevd Jun 28, 2024
27d486b
➕ add numpy
dzhalaevd Jun 28, 2024
30cfe13
⬆️ upgrade dependencies
dzhalaevd Jun 28, 2024
94e7527
⚰️ remove infra
dzhalaevd Jun 28, 2024
e64b043
✨ add image classification
dzhalaevd Jun 28, 2024
23c9ebd
🧑‍💻 add consts
dzhalaevd Jun 28, 2024
1ae7894
⚡️ sped-up photo processing
dzhalaevd Jun 28, 2024
19fe9eb
🚨 fix imports
dzhalaevd Jun 28, 2024
e52e50a
🚚 give more suitable name for middleware
dzhalaevd Jul 1, 2024
ae3cb45
💄 update keyboards
dzhalaevd Jul 1, 2024
5709919
♻️ minor fixes
dzhalaevd Jul 1, 2024
5759a4e
🔥 remove codes
dzhalaevd Jul 1, 2024
0edb841
🎨 move to a higher level
dzhalaevd Jul 1, 2024
2939ba4
🎨 move funcs to one class
dzhalaevd Jul 1, 2024
b2490f0
♻️ minor fixes
dzhalaevd Jul 1, 2024
9cffc53
🚚 split single file into multiple
dzhalaevd Jul 3, 2024
192753a
♻️ minor fixes
dzhalaevd Jul 3, 2024
876f6ed
💄 update keyboards
dzhalaevd Jul 3, 2024
962516e
✨ add states for update profile
dzhalaevd Jul 3, 2024
5c9fcf6
🔧 add tests to exclude
dzhalaevd Oct 11, 2024
db44707
⬆️ upgrade dependencies
dzhalaevd Oct 11, 2024
c31b8e7
⬆️ que-sdk to 0.2.5
dzhalaevd Oct 11, 2024
8ce6f45
♻️ minor fixes
dzhalaevd Oct 11, 2024
3b6a520
🔥 remove test
dzhalaevd Oct 11, 2024
4b2bb96
✅ add e2e tests for creating profile
dzhalaevd Oct 11, 2024
0ca5f8b
💄 update keyboards
dzhalaevd Oct 11, 2024
f53aaa0
♻️ minor fixes
dzhalaevd Oct 11, 2024
def0061
✨ introduce new features
dzhalaevd Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ IP=
TIMEZONE=
MODERATE_CHAT=

POSTGRES_USER=
POSTGRES_PASSWORD=
DB_HOST=
DB_PORT=
POSTGRES_DB=
SIGNATURE_SECRET_KEY=
USE_REDIS=

SECRET_KEY=
API_KEY=
REDIS_PORT=
REDIS_HOST=

QIWI_KEY=
PHONE_NUMBER=
SECRET_P2=
API_ID=
API_HASH=
SESSION_STR=
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ dmypy.json

# Django Settings with Secret key
/django_project/django_project/settings.py
photos/
photos/
!photos/.gitkeep
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
exclude: 'docs|frontend|deprecated|README.md|CODE_OF_CONDUCT.md|LICENSE|.github|tests'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.8"
hooks:
- id: ruff
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gfm
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
args: [ --follow-imports=silent, --disable-error-code=no-untyped-call, --explicit-package-bases ]
exclude: tests/
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ WORKDIR /src
COPY requirements.txt /src
RUN pip install -r /src/requirements.txt
COPY . /src

13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@

### :monocle_face: About

| 🏗️ The project has moved elsewhere, and currently available at [que.group](https://github.com/QueGroup) |
|----------------------------------------------------------------------------------------------------------|

Open-source Dating Telegram bot built on aiogram 2.x to facilitate the search for new connections. The bot incorporates
Open-source Dating Telegram bot built on aiogram 3.x to facilitate the search for new connections. The bot incorporates
a classic profile browsing system, along with filtering options and event organization capabilities. Users can create
and join events, fostering community engagement. Additionally, the project is closely integrated with neural networks,
enhancing its capabilities.

### :alembic: Built With

![Python](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)\
![Django](https://img.shields.io/badge/Django-092E20?style=for-the-badge&logo=django&logoColor=green)\
![AIOHTTP](https://img.shields.io/badge/aiohttp-%232C5bb4.svg?style=for-the-badge&logo=aiohttp&logoColor=white)\
![Poetry](https://img.shields.io/badge/Poetry-%233B82F6.svg?style=for-the-badge&logo=poetry&logoColor=0B3D8D)\
![Babel](https://img.shields.io/badge/Babel-F9DC3e?style=for-the-badge&logo=babel&logoColor=black)\
![Postgresql](https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white)\
![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white)\
![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)
![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)\
![Aiogram](https://img.shields.io/badge/aiogram--V3-blue?style=for-the-badge&logo=telegram&logoColor=white)\
![Redis](https://img.shields.io/badge/redis-%23DD0031.svg?style=for-the-badge&logo=redis&logoColor=white)\
![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white)

### :hammer: Development

Expand Down
66 changes: 0 additions & 66 deletions app.py

This file was deleted.

17 changes: 7 additions & 10 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[python: data/**.py]
[python: django_project/**.py]
[python: filters/**.py]
[python: functions/**.py]
[python: handlers/**.py]
[python: keyboards/**.py]
[python: logs/**.py]
[python: middlewares/**.py]
[python: utils/**.py]
encoding = utf-8
[python: src/tgbot/filters/**.py]
[python: src/tgbot/services/**.py]
[python: src/tgbot/handlers/**.py]
[python: src/tgbot/keyboards/**.py]
[python: src/tgbot/middlewares/**.py]
[python: src/tgbot/utils/**.py]
encoding = utf-8
2 changes: 1 addition & 1 deletion bot.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ autorestart=true
autorestart=true
environment=HOME="/home/ubuntu",USER="ubuntu"
stderr_logfile=/home/ubuntu/DatingBot/logfile_err_django.log
stdout_logfile=/home/ubuntu/DatingBot/logfile_django.log
stdout_logfile=/home/ubuntu/DatingBot/logfile_django.log
156 changes: 156 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import asyncio
import logging
from typing import (
Sequence,
)

from aiogram import (
Bot,
Dispatcher,
)
from aiogram.client.default import (
DefaultBotProperties,
)
from aiogram.enums import (
ParseMode,
)
from aiogram.fsm.storage.memory import (
MemoryStorage,
)
from aiogram.fsm.storage.redis import (
DefaultKeyBuilder,
RedisStorage,
)
from aiogram.utils.i18n import (
ConstI18nMiddleware,
I18n,
)
import betterlogging as bl
from que_sdk import (
QueClient,
)
from redis.asyncio.client import Redis # type: ignore
from yandex_geocoder import (
Client,
)

from src.tgbot import (
services,
)
from src.tgbot.config import (
Config,
load_config,
)
from src.tgbot.handlers import (
routers_list,
)
from src.tgbot.middlewares import (
AccessControlMiddleware,
AlbumMiddleware,
DIMiddleware,
)


async def on_startup(bot: Bot, admin_ids: Sequence[int]) -> None:
await services.broadcast(bot, list(admin_ids), "Бот запущен")


def setup_logging() -> None:
"""
Set up logging configuration for the application.

This method initializes the logging configuration for the application.
It sets the log level to INFO and configures a basic colorized log for
output. The log format includes the filename, line number, log level,
timestamp, logger name, and log message.

Returns:
None

Example usage:
setup_logging()
"""
log_level = logging.INFO
bl.basic_colorized_config(level=log_level)

logging.basicConfig(
level=logging.INFO,
format="%(filename)s:%(lineno)d #%(levelname)-8s [%(asctime)s] - %(name)s - %(message)s",
)
logger = logging.getLogger(__name__)
logger.info("Starting bot")


def register_global_middlewares(
dp: Dispatcher,
config: Config,
client: QueClient,
redis: Redis,
i18n: I18n,
ya_client: Client
) -> None:
logging.info("Setup middlewares...")
middleware_types = [
DIMiddleware(config, client, ya_client),
AccessControlMiddleware(client=client),
ConstI18nMiddleware(locale="ru", i18n=i18n)
]
# dp.message.middleware(ThrottlingMiddleware(redis))
dp.message.middleware(AlbumMiddleware())
for middleware_type in middleware_types:
dp.message.outer_middleware(middleware_type)
dp.callback_query.outer_middleware(middleware_type)


def get_storage(config: Config) -> MemoryStorage | RedisStorage:
"""
Return storage based on the provided configuration.

Args:
config (Config): The configuration object.

Returns:
Storage: The storage object based on the configuration.
"""
if config.tg_bot.use_redis:
return RedisStorage.from_url(
config.redis.dsn(),
key_builder=DefaultKeyBuilder(with_bot_id=True, with_destiny=True),
)
else:
return MemoryStorage()


async def main() -> None:
setup_logging()

config = load_config()
i18n = I18n(path=config.tg_bot.LOCALES_DIR, default_locale="ru", domain="messages")
storage = get_storage(config)
client = QueClient()
ya_client = Client(api_key=config.misc.yandex_map_api_key)

redis = Redis(
host=config.redis.host,
port=config.redis.port,
decode_responses=True,
max_connections=10,
auto_close_connection_pool=True
)

bot = Bot(token=config.tg_bot.token, default=DefaultBotProperties(parse_mode=ParseMode.MARKDOWN))
dp = Dispatcher(storage=storage)

register_global_middlewares(dp, config, client, redis, i18n, ya_client)
dp.include_routers(*routers_list)
await services.set_default_commands(bot, config)
await on_startup(bot, config.tg_bot.admin_ids)
await dp.start_polling(bot)


if __name__ == "__main__":
try:
with asyncio.Runner() as runner:
runner.run(main())
except (KeyboardInterrupt, SystemExit):
logging.error("Бот был выключен!")
Binary file removed brandbook/1_page.png
Binary file not shown.
Binary file removed brandbook/2_page.png
Binary file not shown.
Binary file removed brandbook/3_page.png
Binary file not shown.
Binary file removed brandbook/4_page.png
Binary file not shown.
Loading