funpaybotengine 0.1.0.dev1__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.
- funpaybotengine-0.1.0.dev1/.env +8 -0
- funpaybotengine-0.1.0.dev1/.github/CODEOWNERS +1 -0
- funpaybotengine-0.1.0.dev1/.gitignore +20 -0
- funpaybotengine-0.1.0.dev1/PKG-INFO +32 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/.gitignore +8 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/MypyPlugin.xml +7 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/funpaybotengine.iml +12 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/inspectionProfiles/Project_Default.xml +18 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/misc.xml +7 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/modules.xml +8 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/vcs.xml +6 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/.idea/workspace.xml +70 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/__init__.py +19 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/base.py +64 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/client/__init__.py +4 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/client/bot.py +860 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/client/session/__init__.py +5 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/client/session/aiohttp_session.py +183 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/client/session/base.py +112 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/client/session/http_methods.py +18 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/__init__.py +6 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/events/__init__.py +4 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/events/base.py +52 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/events/builtin_events.py +198 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/filters/__init__.py +5 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/filters/base.py +12 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/filters/message_filters.py +86 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/filters/order_filters.py +53 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/handlers/__init__.py +3 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/handlers/handler_manager.py +56 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/routers/__init__.py +4 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/routers/base.py +76 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/dispatching/routers/dispatcher.py +27 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/__init__.py +8 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/action_exceptions.py +30 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/base.py +11 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/bot_exceptions.py +46 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/message_check_errors.py +38 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/runner_exceptions.py +26 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/exceptions/session_exceptions.py +79 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/loggers.py +13 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/__init__.py +30 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/base.py +230 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/calc_chips.py +41 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/calc_lots.py +44 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/check_banned.py +38 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/delete_review.py +52 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_2fa_status.py +38 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_chat_history.py +90 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_chat_page.py +45 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_main_page.py +44 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_offer_fields.py +53 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_order_page.py +35 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_profile_page.py +37 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_purchases.py +103 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_reviews.py +53 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_sales.py +110 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_settings_page.py +28 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_subcategory_page.py +42 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_telegram_connect_url.py +34 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/get_transactions.py +57 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/logout.py +43 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/raise_offers.py +82 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/refund.py +59 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/review.py +68 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/runner_request.py +80 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/save_offer_fields.py +45 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/set_offers_hidden.py +50 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/update_notice_channel.py +50 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/upload_avatar.py +42 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/methods/upload_image.py +47 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/runner/__init__.py +4 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/runner/config.py +49 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/runner/event_collector.py +410 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/runner/runner.py +76 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/storage/__init__.py +4 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/storage/base.py +214 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/storage/inmemory_storage.py +193 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/__init__.py +16 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/base.py +48 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/calc.py +47 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/categories.py +64 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/chat.py +132 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/common.py +156 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/common_page_elements.py +84 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/enums.py +17 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/finances.py +113 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/messages.py +223 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/offers.py +653 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/orders.py +138 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/__init__.py +10 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/base.py +20 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/chat_page.py +23 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/main_page.py +27 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/order_page.py +120 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/profile_page.py +78 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/settings_page.py +18 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/subcategory_page.py +34 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/pages/transactions_page.py +27 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/requests/__init__.py +3 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/requests/runner.py +275 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/reviews.py +128 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/settings.py +26 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/types/updates.py +170 -0
- funpaybotengine-0.1.0.dev1/funpaybotengine/utils.py +111 -0
- funpaybotengine-0.1.0.dev1/pyproject.toml +125 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
PROXY=socks5://user148430o3869r670825:dgej93@pool.proxys.io:10851
|
|
2
|
+
GOLDEN_KEY=ub4ui4fyjyukbovprql1hgdhzzf9ow8u
|
|
3
|
+
|
|
4
|
+
GOLDEN_KEY2=1ehxhs07yjocv1uchhjfqr98ydzuenpq
|
|
5
|
+
PROXY2=socks5://user148430o7342r250433:dgej93@pool.proxys.io:10699
|
|
6
|
+
|
|
7
|
+
PROXY_MAIN=socks5://user148429:dgej93@45.39.104.142:19392
|
|
8
|
+
GOLDEN_KEY_MAIN=js65bi9hojgguh8q7jb8f48wdhx0mmaq
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @qvvonk
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: funpaybotengine
|
|
3
|
+
Version: 0.1.0.dev1
|
|
4
|
+
Summary: Framework for creating FunPay bots.
|
|
5
|
+
Project-URL: Telegram Channel, https://t.me/funpay_hub
|
|
6
|
+
Project-URL: Repository, https://github.com/funpayhub/funpaybotengine
|
|
7
|
+
Project-URL: Issues, https://github.com/funpyahub/funpaybotengine/issues
|
|
8
|
+
Author-email: Qvvonk <qvvonk@gmail.com>
|
|
9
|
+
Maintainer-email: Qvvonk <qvvonk@gmail.com>
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: aiohttp-socks~=0.10.1
|
|
19
|
+
Requires-Dist: aiohttp~=3.12.14
|
|
20
|
+
Requires-Dist: eventry~=0.2.0
|
|
21
|
+
Requires-Dist: funpayparsers~=0.5.6
|
|
22
|
+
Requires-Dist: pydantic~=2.11.7
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: mypy>=1.17.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
26
|
+
Provides-Extra: docs
|
|
27
|
+
Requires-Dist: pydata-sphinx-theme>=0.16.1; extra == 'docs'
|
|
28
|
+
Requires-Dist: sphinx-design>=0.6.1; extra == 'docs'
|
|
29
|
+
Requires-Dist: sphinx>=8.1.3; extra == 'docs'
|
|
30
|
+
Provides-Extra: tests
|
|
31
|
+
Requires-Dist: pytest; extra == 'tests'
|
|
32
|
+
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'tests'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="jdk" jdkName="Python 3.13" jdkType="Python SDK" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
<component name="PyDocumentationSettings">
|
|
9
|
+
<option name="format" value="PLAIN" />
|
|
10
|
+
<option name="myDocStringFormat" value="Plain" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
|
2
|
+
<profile version="1.0">
|
|
3
|
+
<option name="myName" value="Project Default" />
|
|
4
|
+
<inspection_tool class="PyCompatibilityInspection" enabled="false" level="WARNING" enabled_by_default="false">
|
|
5
|
+
<option name="ourVersions">
|
|
6
|
+
<value>
|
|
7
|
+
<list size="5">
|
|
8
|
+
<item index="0" class="java.lang.String" itemvalue="3.13" />
|
|
9
|
+
<item index="1" class="java.lang.String" itemvalue="3.12" />
|
|
10
|
+
<item index="2" class="java.lang.String" itemvalue="3.11" />
|
|
11
|
+
<item index="3" class="java.lang.String" itemvalue="3.10" />
|
|
12
|
+
<item index="4" class="java.lang.String" itemvalue="3.9" />
|
|
13
|
+
</list>
|
|
14
|
+
</value>
|
|
15
|
+
</option>
|
|
16
|
+
</inspection_tool>
|
|
17
|
+
</profile>
|
|
18
|
+
</component>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="Black">
|
|
4
|
+
<option name="sdkName" value="Python 3.13" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13" project-jdk-type="Python SDK" />
|
|
7
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/funpaybotengine.iml" filepath="$PROJECT_DIR$/.idea/funpaybotengine.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="AutoImportSettings">
|
|
4
|
+
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ChangeListManager">
|
|
7
|
+
<list default="true" id="be6c7dab-f721-4460-b7b4-0d8768c318dc" name="Changes" comment="" />
|
|
8
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
9
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
10
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
11
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
12
|
+
</component>
|
|
13
|
+
<component name="Git.Settings">
|
|
14
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
|
15
|
+
</component>
|
|
16
|
+
<component name="ProjectColorInfo">{
|
|
17
|
+
"associatedIndex": 0
|
|
18
|
+
}</component>
|
|
19
|
+
<component name="ProjectId" id="30KOzQtxp8XPapuqSjaGsPeZsax" />
|
|
20
|
+
<component name="ProjectViewState">
|
|
21
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
22
|
+
<option name="showLibraryContents" value="true" />
|
|
23
|
+
</component>
|
|
24
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
25
|
+
"keyToString": {
|
|
26
|
+
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
|
27
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
28
|
+
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
|
29
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
30
|
+
"git-widget-placeholder": "dev",
|
|
31
|
+
"last_opened_file_path": "/home/qvvonk/projects/funpaybotengine",
|
|
32
|
+
"node.js.detected.package.eslint": "true",
|
|
33
|
+
"node.js.detected.package.tslint": "true",
|
|
34
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
35
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
36
|
+
"nodejs_package_manager_path": "npm",
|
|
37
|
+
"settings.editor.selected.configurable": "preferences.lookFeel",
|
|
38
|
+
"vue.rearranger.settings.migration": "true"
|
|
39
|
+
}
|
|
40
|
+
}]]></component>
|
|
41
|
+
<component name="SharedIndexes">
|
|
42
|
+
<attachedChunks>
|
|
43
|
+
<set>
|
|
44
|
+
<option value="bundled-js-predefined-d6986cc7102b-b598e85cdad2-JavaScript-PY-252.25557.178" />
|
|
45
|
+
<option value="bundled-python-sdk-ce6832f46686-7b97d883f26b-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-252.25557.178" />
|
|
46
|
+
</set>
|
|
47
|
+
</attachedChunks>
|
|
48
|
+
</component>
|
|
49
|
+
<component name="TaskManager">
|
|
50
|
+
<task active="true" id="Default" summary="Default task">
|
|
51
|
+
<changelist id="be6c7dab-f721-4460-b7b4-0d8768c318dc" name="Changes" comment="" />
|
|
52
|
+
<created>1753373060154</created>
|
|
53
|
+
<option name="number" value="Default" />
|
|
54
|
+
<option name="presentableId" value="Default" />
|
|
55
|
+
<updated>1753373060154</updated>
|
|
56
|
+
<workItem from="1753373061197" duration="27000" />
|
|
57
|
+
<workItem from="1763209333536" duration="897000" />
|
|
58
|
+
<workItem from="1763558110149" duration="3121000" />
|
|
59
|
+
<workItem from="1763591533259" duration="538000" />
|
|
60
|
+
<workItem from="1765123562076" duration="554000" />
|
|
61
|
+
<workItem from="1765124126231" duration="25000" />
|
|
62
|
+
<workItem from="1765136987976" duration="77000" />
|
|
63
|
+
<workItem from="1765225184113" duration="5000" />
|
|
64
|
+
</task>
|
|
65
|
+
<servers />
|
|
66
|
+
</component>
|
|
67
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
68
|
+
<option name="version" value="3" />
|
|
69
|
+
</component>
|
|
70
|
+
</project>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import funpaybotengine.dispatching.events as events
|
|
4
|
+
import funpaybotengine.dispatching.filters as filters
|
|
5
|
+
from funpaybotengine.client.bot import Bot
|
|
6
|
+
from funpaybotengine.client.session import BaseSession, AioHttpSession
|
|
7
|
+
from funpaybotengine.dispatching.routers.base import Router
|
|
8
|
+
from funpaybotengine.dispatching.routers.dispatcher import Dispatcher
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
'Bot',
|
|
13
|
+
'BaseSession',
|
|
14
|
+
'AioHttpSession',
|
|
15
|
+
'Router',
|
|
16
|
+
'Dispatcher',
|
|
17
|
+
'events',
|
|
18
|
+
'filters',
|
|
19
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
__all__ = ('BindableObject', 'check_bound')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, PrivateAttr
|
|
11
|
+
from typing_extensions import Self
|
|
12
|
+
|
|
13
|
+
from funpaybotengine.exceptions import BotNotBoundError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from funpaybotengine.client.bot import Bot
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
F = TypeVar('F', bound=Callable[..., Any])
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BindableObject(BaseModel):
|
|
24
|
+
_bot: Bot | None = PrivateAttr(None)
|
|
25
|
+
|
|
26
|
+
def model_post_init(self, context: dict[Any, Any]) -> None:
|
|
27
|
+
self._bot = context.get('bot') if context else None
|
|
28
|
+
|
|
29
|
+
def as_(self, bot: Bot | None, /) -> Self:
|
|
30
|
+
self.bind_to(bot)
|
|
31
|
+
return self
|
|
32
|
+
|
|
33
|
+
def unbind(self) -> None:
|
|
34
|
+
self._bot = None
|
|
35
|
+
|
|
36
|
+
def bind_to(self, bot: Bot | None, /) -> None:
|
|
37
|
+
self._bot = bot
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def bot(self) -> Bot | None:
|
|
41
|
+
return self._bot
|
|
42
|
+
|
|
43
|
+
def get_bound_bot(self) -> Bot:
|
|
44
|
+
if not self.bot:
|
|
45
|
+
raise BotNotBoundError(self)
|
|
46
|
+
return self.bot
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def check_bound(func: F) -> F:
|
|
50
|
+
"""
|
|
51
|
+
Decorator for instance methods to ensure the object is bound to any Bot instance.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
55
|
+
if not args:
|
|
56
|
+
raise RuntimeError('Can be used only with instance methods.')
|
|
57
|
+
|
|
58
|
+
if not isinstance(args[0], BindableObject):
|
|
59
|
+
raise ValueError(f'{args[0].__class__.__name__} is not a bindable object.')
|
|
60
|
+
if args[0].bot is None:
|
|
61
|
+
raise RuntimeError(f'{args[0]} is not bound to any `Bot` instance.')
|
|
62
|
+
return func(*args, **kwargs)
|
|
63
|
+
|
|
64
|
+
return wrapper # type: ignore
|