aioscam 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aioscam-0.1.1/LICENSE +21 -0
- aioscam-0.1.1/PKG-INFO +249 -0
- aioscam-0.1.1/README.md +201 -0
- aioscam-0.1.1/aioscam/__init__.py +23 -0
- aioscam-0.1.1/aioscam/bot/__init__.py +9 -0
- aioscam-0.1.1/aioscam/bot/bot.py +1081 -0
- aioscam-0.1.1/aioscam/client/__init__.py +13 -0
- aioscam-0.1.1/aioscam/client/client.py +160 -0
- aioscam-0.1.1/aioscam/client/request.py +84 -0
- aioscam-0.1.1/aioscam/client/response.py +39 -0
- aioscam-0.1.1/aioscam/config.py +155 -0
- aioscam-0.1.1/aioscam/dispatcher/__init__.py +13 -0
- aioscam-0.1.1/aioscam/dispatcher/dispatcher.py +427 -0
- aioscam-0.1.1/aioscam/dispatcher/event.py +192 -0
- aioscam-0.1.1/aioscam/dispatcher/router.py +275 -0
- aioscam-0.1.1/aioscam/dispatcher/state.py +63 -0
- aioscam-0.1.1/aioscam/enums/__init__.py +33 -0
- aioscam-0.1.1/aioscam/enums/api_path.py +58 -0
- aioscam-0.1.1/aioscam/enums/attachment.py +18 -0
- aioscam-0.1.1/aioscam/enums/button.py +19 -0
- aioscam-0.1.1/aioscam/enums/chat.py +31 -0
- aioscam-0.1.1/aioscam/enums/http_method.py +15 -0
- aioscam-0.1.1/aioscam/enums/intent.py +14 -0
- aioscam-0.1.1/aioscam/enums/message_link.py +13 -0
- aioscam-0.1.1/aioscam/enums/parse_mode.py +13 -0
- aioscam-0.1.1/aioscam/enums/sender_action.py +19 -0
- aioscam-0.1.1/aioscam/enums/text_style.py +18 -0
- aioscam-0.1.1/aioscam/enums/update.py +33 -0
- aioscam-0.1.1/aioscam/enums/upload.py +15 -0
- aioscam-0.1.1/aioscam/exceptions/__init__.py +33 -0
- aioscam-0.1.1/aioscam/exceptions/exceptions.py +93 -0
- aioscam-0.1.1/aioscam/filters/__init__.py +28 -0
- aioscam-0.1.1/aioscam/filters/base.py +90 -0
- aioscam-0.1.1/aioscam/filters/builtin.py +281 -0
- aioscam-0.1.1/aioscam/fsm/__init__.py +16 -0
- aioscam-0.1.1/aioscam/fsm/memory.py +63 -0
- aioscam-0.1.1/aioscam/fsm/scene.py +66 -0
- aioscam-0.1.1/aioscam/fsm/state.py +77 -0
- aioscam-0.1.1/aioscam/fsm/storage.py +91 -0
- aioscam-0.1.1/aioscam/handler/__init__.py +15 -0
- aioscam-0.1.1/aioscam/handler/base.py +69 -0
- aioscam-0.1.1/aioscam/handler/callback.py +52 -0
- aioscam-0.1.1/aioscam/handler/event.py +61 -0
- aioscam-0.1.1/aioscam/handler/message.py +57 -0
- aioscam-0.1.1/aioscam/methods/__init__.py +15 -0
- aioscam-0.1.1/aioscam/methods/base.py +47 -0
- aioscam-0.1.1/aioscam/methods/get_me.py +24 -0
- aioscam-0.1.1/aioscam/methods/get_updates.py +40 -0
- aioscam-0.1.1/aioscam/methods/send_message.py +50 -0
- aioscam-0.1.1/aioscam/middleware/__init__.py +11 -0
- aioscam-0.1.1/aioscam/middleware/base.py +36 -0
- aioscam-0.1.1/aioscam/middleware/manager.py +98 -0
- aioscam-0.1.1/aioscam/py.typed +0 -0
- aioscam-0.1.1/aioscam/types/__init__.py +73 -0
- aioscam-0.1.1/aioscam/types/attachment.py +172 -0
- aioscam-0.1.1/aioscam/types/base.py +31 -0
- aioscam-0.1.1/aioscam/types/callback.py +25 -0
- aioscam-0.1.1/aioscam/types/chat.py +44 -0
- aioscam-0.1.1/aioscam/types/chats.py +20 -0
- aioscam-0.1.1/aioscam/types/command.py +30 -0
- aioscam-0.1.1/aioscam/types/keyboard.py +253 -0
- aioscam-0.1.1/aioscam/types/message.py +123 -0
- aioscam-0.1.1/aioscam/types/subscription.py +24 -0
- aioscam-0.1.1/aioscam/types/update.py +116 -0
- aioscam-0.1.1/aioscam/types/user.py +47 -0
- aioscam-0.1.1/aioscam/utils/__init__.py +19 -0
- aioscam-0.1.1/aioscam/utils/deep_linking.py +76 -0
- aioscam-0.1.1/aioscam/utils/formatting.py +62 -0
- aioscam-0.1.1/aioscam/utils/keyboard.py +192 -0
- aioscam-0.1.1/aioscam/webhook/__init__.py +11 -0
- aioscam-0.1.1/aioscam/webhook/aiohttp.py +49 -0
- aioscam-0.1.1/aioscam/webhook/base.py +35 -0
- aioscam-0.1.1/aioscam.egg-info/PKG-INFO +249 -0
- aioscam-0.1.1/aioscam.egg-info/SOURCES.txt +81 -0
- aioscam-0.1.1/aioscam.egg-info/dependency_links.txt +1 -0
- aioscam-0.1.1/aioscam.egg-info/requires.txt +26 -0
- aioscam-0.1.1/aioscam.egg-info/top_level.txt +1 -0
- aioscam-0.1.1/pyproject.toml +91 -0
- aioscam-0.1.1/setup.cfg +4 -0
- aioscam-0.1.1/tests/test_basic.py +105 -0
- aioscam-0.1.1/tests/test_comprehensive.py +656 -0
- aioscam-0.1.1/tests/test_integration.py +454 -0
- aioscam-0.1.1/tests/test_security.py +412 -0
aioscam-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AioScam Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aioscam-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aioscam
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Async framework for Max messenger bots (aiogram-style)
|
|
5
|
+
Author: AioScam Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/aioscam/aioscam
|
|
8
|
+
Project-URL: Documentation, https://aioscam.readthedocs.io/
|
|
9
|
+
Project-URL: Repository, https://github.com/aioscam/aioscam
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/aioscam/aioscam/issues
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Communications :: Chat
|
|
22
|
+
Classifier: Framework :: AsyncIO
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
27
|
+
Requires-Dist: magic-filter>=1.0.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
30
|
+
Provides-Extra: fastapi
|
|
31
|
+
Requires-Dist: fastapi>=0.100.0; extra == "fastapi"
|
|
32
|
+
Requires-Dist: uvicorn>=0.23.0; extra == "fastapi"
|
|
33
|
+
Provides-Extra: litestar
|
|
34
|
+
Requires-Dist: litestar>=2.0.0; extra == "litestar"
|
|
35
|
+
Requires-Dist: uvicorn>=0.23.0; extra == "litestar"
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
41
|
+
Requires-Dist: coverage>=7.0.0; extra == "dev"
|
|
42
|
+
Provides-Extra: docs
|
|
43
|
+
Requires-Dist: sphinx>=7.0.0; extra == "docs"
|
|
44
|
+
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
45
|
+
Provides-Extra: all
|
|
46
|
+
Requires-Dist: aioscam[dev,docs,fastapi,litestar]; extra == "all"
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
|
|
49
|
+
# AioScam
|
|
50
|
+
|
|
51
|
+
Async Python framework for building Max messenger bots, inspired by aiogram architecture.
|
|
52
|
+
|
|
53
|
+
## Version
|
|
54
|
+
|
|
55
|
+
**v0.1.1** — Production Ready
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
- 🚀 **Fully async** - Built on `asyncio` and `aiohttp`
|
|
60
|
+
- 🎯 **aiogram-style API** - Familiar decorators and patterns
|
|
61
|
+
- 🔄 **Router system** - Modular bot architecture with nesting support
|
|
62
|
+
- 🎭 **Magic Filters** - Declarative event filtering (`F.text`, `F.callback.payload`)
|
|
63
|
+
- 🔧 **Middleware** - Request/response processing pipeline
|
|
64
|
+
- 📦 **FSM** - Built-in finite state machine with MemoryStorage
|
|
65
|
+
- 🛡️ **StateGuard** - Blocks unauthorized commands/callbacks during active FSM states
|
|
66
|
+
- 📱 **Contact & Location** - Inline buttons for requesting phone number and geolocation
|
|
67
|
+
- 🗑️ **Message Management** - Delete sent messages
|
|
68
|
+
- 🌐 **Webhook support** - aiohttp, FastAPI, Litestar
|
|
69
|
+
- 📡 **Polling mode** - Long-polling with exponential backoff
|
|
70
|
+
- 🔒 **Security** - Webhook secret token, circular router detection, race condition prevention
|
|
71
|
+
- 📦 **Python 3.9-3.12** - Wide version support
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
### TestPyPI (Testing)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install --index-url https://test.pypi.org/simple/ \
|
|
79
|
+
--extra-index-url https://pypi.org/simple/ aioscam
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
> ⚠️ Test version on TestPyPI. For production, install from source.
|
|
83
|
+
|
|
84
|
+
### Basic installation
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install aioscam
|
|
88
|
+
|
|
89
|
+
# With FastAPI webhook support
|
|
90
|
+
pip install aioscam[fastapi]
|
|
91
|
+
|
|
92
|
+
# With Litestar webhook support
|
|
93
|
+
pip install aioscam[litestar]
|
|
94
|
+
|
|
95
|
+
# Development mode
|
|
96
|
+
pip install aioscam[dev]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### PyPI Status
|
|
100
|
+
|
|
101
|
+
- **TestPyPI**: ✅ Published ([test.pypi.org/project/aioscam/](https://test.pypi.org/project/aioscam/))
|
|
102
|
+
- **PyPI**: 🟡 Planned
|
|
103
|
+
|
|
104
|
+
### From source
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
git clone https://github.com/aioscam/aioscam.git
|
|
108
|
+
cd aioscam
|
|
109
|
+
pip install -e .
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Quick Start
|
|
113
|
+
|
|
114
|
+
### Echo Bot (Polling mode)
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
import asyncio
|
|
118
|
+
from aioscam import Bot, Dispatcher, Router
|
|
119
|
+
from aioscam.filters import Command, F
|
|
120
|
+
|
|
121
|
+
dp = Dispatcher()
|
|
122
|
+
router = Router()
|
|
123
|
+
|
|
124
|
+
@router.message_created(Command("start"))
|
|
125
|
+
async def cmd_start(event):
|
|
126
|
+
await event.message.answer("Привет! Я эхо-бот. Напиши мне что-нибудь!")
|
|
127
|
+
|
|
128
|
+
@router.message_created()
|
|
129
|
+
async def echo_message(event):
|
|
130
|
+
await event.message.answer(event.message.body.text)
|
|
131
|
+
|
|
132
|
+
dp.include_router(router)
|
|
133
|
+
|
|
134
|
+
async def main():
|
|
135
|
+
bot = Bot() # Token from MAX_BOT_TOKEN env
|
|
136
|
+
await dp.start_polling(bot)
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
asyncio.run(main())
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### With Magic Filters
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
@router.message_created(F.message.body.text.func(lambda t: "привет" in t.lower()))
|
|
146
|
+
async def handle_hello(event):
|
|
147
|
+
await event.message.answer("Привет! Как дела?")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### FSM Example
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from aioscam.fsm import State, StatesGroup
|
|
154
|
+
|
|
155
|
+
class MyState(StatesGroup):
|
|
156
|
+
waiting_name = State()
|
|
157
|
+
waiting_age = State()
|
|
158
|
+
|
|
159
|
+
@router.message_created(Command("register"))
|
|
160
|
+
async def cmd_register(event, state):
|
|
161
|
+
await state.set_state(MyState.waiting_name)
|
|
162
|
+
await event.message.answer("Введите имя:")
|
|
163
|
+
|
|
164
|
+
@router.message_created(MyState.waiting_name)
|
|
165
|
+
async def process_name(event, state):
|
|
166
|
+
await state.update_data(name=event.message.body.text)
|
|
167
|
+
await state.set_state(MyState.waiting_age)
|
|
168
|
+
await event.message.answer("Введите возраст:")
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Webhook mode (aiohttp)
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
async def main():
|
|
175
|
+
bot = Bot()
|
|
176
|
+
await dp.handle_webhook(bot=bot, host="0.0.0.0", port=8080)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## API Coverage
|
|
180
|
+
|
|
181
|
+
### Implemented Methods (35/35 core methods)
|
|
182
|
+
|
|
183
|
+
| Category | Methods |
|
|
184
|
+
|----------|---------|
|
|
185
|
+
| **Bot Info** | `get_me`, `get_me_from_chat`, `change_info` |
|
|
186
|
+
| **Messages** | `send_message`, `edit_message`, `delete_message`, `get_message`, `get_messages`, `pin_message`, `delete_pin_message`, `get_pin_message` |
|
|
187
|
+
| **Callbacks/Actions** | `send_callback`, `send_action` |
|
|
188
|
+
| **Chats** | `get_chats`, `get_chat_by_id`, `get_chat_by_link`, `edit_chat`, `delete_chat`, `add_chat_members`, `remove_member_chat`, `add_list_admin_chat`, `remove_admin`, `get_chat_members`, `get_chat_member`, `get_list_admin_chat`, `delete_me_from_chat` |
|
|
189
|
+
| **Updates** | `get_updates`, `get_last_marker` |
|
|
190
|
+
| **Webhooks** | `subscribe_webhook`, `unsubscribe_webhook`, `delete_webhook`, `get_subscriptions` |
|
|
191
|
+
| **Media** | `get_upload_url`, `upload_attachment`, `get_video` |
|
|
192
|
+
|
|
193
|
+
### Event Types (14 types)
|
|
194
|
+
|
|
195
|
+
`message_created`, `message_callback`, `message_edited`, `message_removed`, `bot_started`, `bot_stopped`, `bot_added`, `bot_removed`, `chat_title_changed`, `dialog_cleared`, `dialog_muted`, `dialog_unmuted`, `user_added`, `user_removed`
|
|
196
|
+
|
|
197
|
+
### Button Types (8 implemented)
|
|
198
|
+
|
|
199
|
+
`CallbackButton`, `LinkButton`, `ChatButton`, `MessageButton`, `ClipboardButton`, `OpenAppButton`, `RequestContactButton`, `RequestGeoLocationButton`
|
|
200
|
+
|
|
201
|
+
### Sender Actions (9 types)
|
|
202
|
+
|
|
203
|
+
`typing`, `upload_photo`, `record_video`, `upload_video`, `record_audio`, `upload_audio`, `upload_document`, `finding_location`, `choosing_sticker`
|
|
204
|
+
|
|
205
|
+
## Project Structure
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
aioscam/
|
|
209
|
+
├── bot/ # Bot client (35 API methods)
|
|
210
|
+
├── client/ # HTTP client (aiohttp wrapper)
|
|
211
|
+
├── dispatcher/ # Dispatcher, Router, EventContext, StateGuard
|
|
212
|
+
├── enums/ # 12 enumeration files
|
|
213
|
+
├── exceptions/ # 12 exception classes
|
|
214
|
+
├── filters/ # BaseFilter, Command, Text, State, Magic Filters
|
|
215
|
+
├── fsm/ # State, StatesGroup, MemoryStorage, Scene
|
|
216
|
+
├── handler/ # MessageHandler, CallbackHandler, EventHandler
|
|
217
|
+
├── methods/ # API method wrappers
|
|
218
|
+
├── middleware/ # BaseMiddleware, MiddlewareManager
|
|
219
|
+
├── types/ # Pydantic models (User, Chat, Message, etc.)
|
|
220
|
+
├── utils/ # KeyboardBuilder, formatting, deep_linking
|
|
221
|
+
└── webhook/ # aiohttp webhook handler
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Configuration
|
|
225
|
+
|
|
226
|
+
Create `.env` file:
|
|
227
|
+
|
|
228
|
+
```env
|
|
229
|
+
MAX_BOT_TOKEN=your_token_here
|
|
230
|
+
AIOSCAM_ENV=prod # debug, test, prod
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Testing
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Run tests
|
|
237
|
+
python -m pytest tests/ -v
|
|
238
|
+
|
|
239
|
+
# Core tests (74/74 passing)
|
|
240
|
+
python -m pytest tests/ -v --ignore=tests/test_integration.py
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Documentation
|
|
244
|
+
|
|
245
|
+
Full documentation available at: [https://aioscam.readthedocs.io/](https://aioscam.readthedocs.io/)
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
|
|
249
|
+
MIT License
|
aioscam-0.1.1/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# AioScam
|
|
2
|
+
|
|
3
|
+
Async Python framework for building Max messenger bots, inspired by aiogram architecture.
|
|
4
|
+
|
|
5
|
+
## Version
|
|
6
|
+
|
|
7
|
+
**v0.1.1** — Production Ready
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🚀 **Fully async** - Built on `asyncio` and `aiohttp`
|
|
12
|
+
- 🎯 **aiogram-style API** - Familiar decorators and patterns
|
|
13
|
+
- 🔄 **Router system** - Modular bot architecture with nesting support
|
|
14
|
+
- 🎭 **Magic Filters** - Declarative event filtering (`F.text`, `F.callback.payload`)
|
|
15
|
+
- 🔧 **Middleware** - Request/response processing pipeline
|
|
16
|
+
- 📦 **FSM** - Built-in finite state machine with MemoryStorage
|
|
17
|
+
- 🛡️ **StateGuard** - Blocks unauthorized commands/callbacks during active FSM states
|
|
18
|
+
- 📱 **Contact & Location** - Inline buttons for requesting phone number and geolocation
|
|
19
|
+
- 🗑️ **Message Management** - Delete sent messages
|
|
20
|
+
- 🌐 **Webhook support** - aiohttp, FastAPI, Litestar
|
|
21
|
+
- 📡 **Polling mode** - Long-polling with exponential backoff
|
|
22
|
+
- 🔒 **Security** - Webhook secret token, circular router detection, race condition prevention
|
|
23
|
+
- 📦 **Python 3.9-3.12** - Wide version support
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### TestPyPI (Testing)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install --index-url https://test.pypi.org/simple/ \
|
|
31
|
+
--extra-index-url https://pypi.org/simple/ aioscam
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> ⚠️ Test version on TestPyPI. For production, install from source.
|
|
35
|
+
|
|
36
|
+
### Basic installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install aioscam
|
|
40
|
+
|
|
41
|
+
# With FastAPI webhook support
|
|
42
|
+
pip install aioscam[fastapi]
|
|
43
|
+
|
|
44
|
+
# With Litestar webhook support
|
|
45
|
+
pip install aioscam[litestar]
|
|
46
|
+
|
|
47
|
+
# Development mode
|
|
48
|
+
pip install aioscam[dev]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### PyPI Status
|
|
52
|
+
|
|
53
|
+
- **TestPyPI**: ✅ Published ([test.pypi.org/project/aioscam/](https://test.pypi.org/project/aioscam/))
|
|
54
|
+
- **PyPI**: 🟡 Planned
|
|
55
|
+
|
|
56
|
+
### From source
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/aioscam/aioscam.git
|
|
60
|
+
cd aioscam
|
|
61
|
+
pip install -e .
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
### Echo Bot (Polling mode)
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import asyncio
|
|
70
|
+
from aioscam import Bot, Dispatcher, Router
|
|
71
|
+
from aioscam.filters import Command, F
|
|
72
|
+
|
|
73
|
+
dp = Dispatcher()
|
|
74
|
+
router = Router()
|
|
75
|
+
|
|
76
|
+
@router.message_created(Command("start"))
|
|
77
|
+
async def cmd_start(event):
|
|
78
|
+
await event.message.answer("Привет! Я эхо-бот. Напиши мне что-нибудь!")
|
|
79
|
+
|
|
80
|
+
@router.message_created()
|
|
81
|
+
async def echo_message(event):
|
|
82
|
+
await event.message.answer(event.message.body.text)
|
|
83
|
+
|
|
84
|
+
dp.include_router(router)
|
|
85
|
+
|
|
86
|
+
async def main():
|
|
87
|
+
bot = Bot() # Token from MAX_BOT_TOKEN env
|
|
88
|
+
await dp.start_polling(bot)
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
asyncio.run(main())
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### With Magic Filters
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
@router.message_created(F.message.body.text.func(lambda t: "привет" in t.lower()))
|
|
98
|
+
async def handle_hello(event):
|
|
99
|
+
await event.message.answer("Привет! Как дела?")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### FSM Example
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from aioscam.fsm import State, StatesGroup
|
|
106
|
+
|
|
107
|
+
class MyState(StatesGroup):
|
|
108
|
+
waiting_name = State()
|
|
109
|
+
waiting_age = State()
|
|
110
|
+
|
|
111
|
+
@router.message_created(Command("register"))
|
|
112
|
+
async def cmd_register(event, state):
|
|
113
|
+
await state.set_state(MyState.waiting_name)
|
|
114
|
+
await event.message.answer("Введите имя:")
|
|
115
|
+
|
|
116
|
+
@router.message_created(MyState.waiting_name)
|
|
117
|
+
async def process_name(event, state):
|
|
118
|
+
await state.update_data(name=event.message.body.text)
|
|
119
|
+
await state.set_state(MyState.waiting_age)
|
|
120
|
+
await event.message.answer("Введите возраст:")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Webhook mode (aiohttp)
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
async def main():
|
|
127
|
+
bot = Bot()
|
|
128
|
+
await dp.handle_webhook(bot=bot, host="0.0.0.0", port=8080)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## API Coverage
|
|
132
|
+
|
|
133
|
+
### Implemented Methods (35/35 core methods)
|
|
134
|
+
|
|
135
|
+
| Category | Methods |
|
|
136
|
+
|----------|---------|
|
|
137
|
+
| **Bot Info** | `get_me`, `get_me_from_chat`, `change_info` |
|
|
138
|
+
| **Messages** | `send_message`, `edit_message`, `delete_message`, `get_message`, `get_messages`, `pin_message`, `delete_pin_message`, `get_pin_message` |
|
|
139
|
+
| **Callbacks/Actions** | `send_callback`, `send_action` |
|
|
140
|
+
| **Chats** | `get_chats`, `get_chat_by_id`, `get_chat_by_link`, `edit_chat`, `delete_chat`, `add_chat_members`, `remove_member_chat`, `add_list_admin_chat`, `remove_admin`, `get_chat_members`, `get_chat_member`, `get_list_admin_chat`, `delete_me_from_chat` |
|
|
141
|
+
| **Updates** | `get_updates`, `get_last_marker` |
|
|
142
|
+
| **Webhooks** | `subscribe_webhook`, `unsubscribe_webhook`, `delete_webhook`, `get_subscriptions` |
|
|
143
|
+
| **Media** | `get_upload_url`, `upload_attachment`, `get_video` |
|
|
144
|
+
|
|
145
|
+
### Event Types (14 types)
|
|
146
|
+
|
|
147
|
+
`message_created`, `message_callback`, `message_edited`, `message_removed`, `bot_started`, `bot_stopped`, `bot_added`, `bot_removed`, `chat_title_changed`, `dialog_cleared`, `dialog_muted`, `dialog_unmuted`, `user_added`, `user_removed`
|
|
148
|
+
|
|
149
|
+
### Button Types (8 implemented)
|
|
150
|
+
|
|
151
|
+
`CallbackButton`, `LinkButton`, `ChatButton`, `MessageButton`, `ClipboardButton`, `OpenAppButton`, `RequestContactButton`, `RequestGeoLocationButton`
|
|
152
|
+
|
|
153
|
+
### Sender Actions (9 types)
|
|
154
|
+
|
|
155
|
+
`typing`, `upload_photo`, `record_video`, `upload_video`, `record_audio`, `upload_audio`, `upload_document`, `finding_location`, `choosing_sticker`
|
|
156
|
+
|
|
157
|
+
## Project Structure
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
aioscam/
|
|
161
|
+
├── bot/ # Bot client (35 API methods)
|
|
162
|
+
├── client/ # HTTP client (aiohttp wrapper)
|
|
163
|
+
├── dispatcher/ # Dispatcher, Router, EventContext, StateGuard
|
|
164
|
+
├── enums/ # 12 enumeration files
|
|
165
|
+
├── exceptions/ # 12 exception classes
|
|
166
|
+
├── filters/ # BaseFilter, Command, Text, State, Magic Filters
|
|
167
|
+
├── fsm/ # State, StatesGroup, MemoryStorage, Scene
|
|
168
|
+
├── handler/ # MessageHandler, CallbackHandler, EventHandler
|
|
169
|
+
├── methods/ # API method wrappers
|
|
170
|
+
├── middleware/ # BaseMiddleware, MiddlewareManager
|
|
171
|
+
├── types/ # Pydantic models (User, Chat, Message, etc.)
|
|
172
|
+
├── utils/ # KeyboardBuilder, formatting, deep_linking
|
|
173
|
+
└── webhook/ # aiohttp webhook handler
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Configuration
|
|
177
|
+
|
|
178
|
+
Create `.env` file:
|
|
179
|
+
|
|
180
|
+
```env
|
|
181
|
+
MAX_BOT_TOKEN=your_token_here
|
|
182
|
+
AIOSCAM_ENV=prod # debug, test, prod
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Testing
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Run tests
|
|
189
|
+
python -m pytest tests/ -v
|
|
190
|
+
|
|
191
|
+
# Core tests (74/74 passing)
|
|
192
|
+
python -m pytest tests/ -v --ignore=tests/test_integration.py
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Documentation
|
|
196
|
+
|
|
197
|
+
Full documentation available at: [https://aioscam.readthedocs.io/](https://aioscam.readthedocs.io/)
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT License
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AioScam - Async framework for Max messenger bots (aiogram-style)
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.1"
|
|
6
|
+
__author__ = "AioScam Contributors"
|
|
7
|
+
|
|
8
|
+
from aioscam.bot import Bot
|
|
9
|
+
from aioscam.dispatcher import Dispatcher, Router
|
|
10
|
+
from aioscam.filters import Command, F, StateFilter
|
|
11
|
+
from aioscam.config import Config, get_config, EnvMode
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"Bot",
|
|
15
|
+
"Dispatcher",
|
|
16
|
+
"Router",
|
|
17
|
+
"Command",
|
|
18
|
+
"F",
|
|
19
|
+
"StateFilter",
|
|
20
|
+
"Config",
|
|
21
|
+
"get_config",
|
|
22
|
+
"EnvMode",
|
|
23
|
+
]
|