Skip to content

Commit 31f3f28

Browse files
Merge pull request #12 from 6RUN0/current
Подключил pre-commit и немного отрефакторил код
2 parents 4e89543 + 3c06444 commit 31f3f28

37 files changed

+1026
-464
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ assignees: ''
1111
Что пошло не так?
1212

1313
**Шаги для воспроизведения**
14-
1.
15-
2.
16-
3.
14+
1.
15+
2.
16+
3.
1717

1818
**Ожидаемый результат**
1919
Что должно было произойти

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ jobs:
5151
env:
5252
TOKEN: ${{ secrets.PYPI_API_TOKEN }}
5353
run: |
54-
uv publish -t $TOKEN
54+
uv publish -t $TOKEN

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ tests/
118118

119119

120120
# Bad dev's requirements
121-
requirements.txt
121+
requirements.txt

.pre-commit-config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-docstring-first
7+
- id: check-executables-have-shebangs
8+
- id: check-shebang-scripts-are-executable
9+
- id: check-yaml
10+
- id: end-of-file-fixer
11+
- id: fix-byte-order-marker
12+
- id: mixed-line-ending
13+
- id: name-tests-test
14+
- id: trailing-whitespace
15+
- repo: https://github.com/psf/black
16+
rev: 25.9.0
17+
hooks:
18+
- id: black
19+
- repo: https://github.com/csachs/pyproject-flake8
20+
rev: v7.0.0
21+
hooks:
22+
- id: pyproject-flake8
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v1.18.2
25+
hooks:
26+
- id: mypy
27+
additional_dependencies:
28+
- "aiohttp"
29+
- "sqlalchemy"
30+
- "sqlmodel"
31+
- "types-aiofiles"
32+
- "types-requests"
33+
exclude: "^examples/"
34+
- repo: https://github.com/pycqa/isort
35+
rev: 7.0.0
36+
hooks:
37+
- id: isort
38+
- repo: https://github.com/PyCQA/bandit
39+
rev: 1.8.6
40+
hooks:
41+
- id: bandit

assets/icon.svg

Lines changed: 0 additions & 1 deletion
Loading

assets/logo.svg

Lines changed: 0 additions & 1 deletion
Loading

docs/assets/icon.svg

Lines changed: 0 additions & 1 deletion
Loading

docs/client.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
client = MaxClient(
2020
phone: str,
2121
uri: str = Constants.WEBSOCKET_URI.value,
22-
headers: dict[str, Any] | None = Constants.DEFAULT_USER_AGENT.value,
22+
headers: dict[str, Any] | None = Constants.DEFAULT_USER_AGENT_PAYLOAD.value,
2323
token: str | None = None,
2424
send_fake_telemetry: bool = True,
2525
host: str = Constants.HOST.value,
@@ -35,7 +35,7 @@ client = MaxClient(
3535
|----------|-----|----------|---------------|
3636
| `phone` | `str` | Номер телефона для авторизации | - |
3737
| `uri` | `str` | URI WebSocket сервера | `Constants.WEBSOCKET_URI.value` |
38-
| `headers` | `dict[str, Any] \| None` | Заголовки для соединения | `Constants.DEFAULT_USER_AGENT.value` |
38+
| `headers` | `dict[str, Any] \| None` | Заголовки для соединения | `Constants.DEFAULT_USER_AGENT_PAYLOAD.value` |
3939
| `token` | `str \| None` | Токен авторизации | `None` |
4040
| `send_fake_telemetry` | `bool` | Отправка телеметрии | `True` |
4141
| `host` | `str` | Хост API сервера | `Constants.HOST.value` |

docs/examples.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ from pymax import MaxClient
88

99
async def main():
1010
client = MaxClient(phone="+79001234567")
11-
11+
1212
@client.on_message
1313
async def echo_handler(message):
1414
await client.send_message(
1515
chat_id=message.chat_id,
1616
text=f"Эхо: {message.text}"
1717
)
18-
18+
1919
await client.start()
2020

2121
asyncio.run(main())
@@ -29,27 +29,27 @@ from pymax import MaxClient
2929

3030
async def main():
3131
client = MaxClient(phone="+79001234567")
32-
32+
3333
# Словарь ключевых слов и ответов
3434
auto_replies = {
3535
'привет': 'Привет! Как дела?',
3636
'пока': 'До свидания!',
3737
'спасибо': 'Пожалуйста!',
3838
'время': 'Время ответить на ваш вопрос!',
3939
}
40-
40+
4141
@client.on_message
4242
async def auto_reply_handler(message):
4343
text = message.text.lower()
44-
44+
4545
for keyword, reply in auto_replies.items():
4646
if keyword in text:
4747
await client.send_message(
4848
chat_id=message.chat_id,
4949
text=reply
5050
)
5151
break
52-
52+
5353
await client.start()
5454

5555
asyncio.run(main())
@@ -63,29 +63,29 @@ from pymax import MaxClient
6363

6464
async def main():
6565
client = MaxClient(phone="+79001234567")
66-
66+
6767
# Запрещенные слова
6868
forbidden_words = ['спам', 'реклама', 'взлом']
69-
69+
7070
@client.on_message
7171
async def moderation_handler(message):
7272
text = message.text.lower()
73-
73+
7474
for word in forbidden_words:
7575
if word in text:
7676
# Удаляем сообщение
7777
await client.delete_message(
7878
chat_id=message.chat_id,
7979
message_id=message.id
8080
)
81-
81+
8282
# Предупреждаем пользователя
8383
await client.send_message(
8484
chat_id=message.chat_id,
8585
text=f"@{message.author.username}, использование запрещенных слов недопустимо!"
8686
)
8787
break
88-
88+
8989
await client.start()
9090

9191
asyncio.run(main())

examples/example.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import asyncio
2-
import logging
32

4-
from pymax import MaxClient, Message, SocketMaxClient
5-
from pymax.files import Photo
3+
from pymax import MaxClient, Message
64
from pymax.filters import Filter
7-
from pymax.static import AttachType
85

96
phone = "+1234567890"
107

118

129
client = MaxClient(phone=phone, work_dir="cache")
13-
# client = SocketMaxClient(phone=phone, work_dir="cache")
1410

1511

1612
@client.on_message(filter=Filter(chat_id=0))

0 commit comments

Comments
 (0)