iamai 0.0.1a1__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.
- iamai-0.0.1a1/.gitignore +158 -0
- iamai-0.0.1a1/COPYING +21 -0
- iamai-0.0.1a1/PKG-INFO +179 -0
- iamai-0.0.1a1/README.md +120 -0
- iamai-0.0.1a1/iamai/__init__.py +22 -0
- iamai-0.0.1a1/iamai/adapter/__init__.py +162 -0
- iamai-0.0.1a1/iamai/adapter/bililive/__init__.py +432 -0
- iamai-0.0.1a1/iamai/adapter/bililive/api/blivedm.py +432 -0
- iamai-0.0.1a1/iamai/adapter/bililive/config.py +29 -0
- iamai-0.0.1a1/iamai/adapter/bililive/event.py +308 -0
- iamai-0.0.1a1/iamai/adapter/bililive/exceptions.py +12 -0
- iamai-0.0.1a1/iamai/adapter/bililive/message.py +38 -0
- iamai-0.0.1a1/iamai/adapter/bililive/tests.py +35 -0
- iamai-0.0.1a1/iamai/adapter/bililive/utils/bilibili_api.py +233 -0
- iamai-0.0.1a1/iamai/adapter/bililive/utils/bilibili_bot.py +134 -0
- iamai-0.0.1a1/iamai/adapter/bililive/utils/file_loader.py +34 -0
- iamai-0.0.1a1/iamai/adapter/bililive/utils/main.py +68 -0
- iamai-0.0.1a1/iamai/adapter/bililive/utils/plugin.py +441 -0
- iamai-0.0.1a1/iamai/adapter/bililive/utils/plugins_loader.py +34 -0
- iamai-0.0.1a1/iamai/adapter/console/__init__.py +38 -0
- iamai-0.0.1a1/iamai/adapter/console/config.py +11 -0
- iamai-0.0.1a1/iamai/adapter/console/event.py +109 -0
- iamai-0.0.1a1/iamai/adapter/console/message.py +26 -0
- iamai-0.0.1a1/iamai/adapter/dingtalk/__init__.py +161 -0
- iamai-0.0.1a1/iamai/adapter/dingtalk/config.py +23 -0
- iamai-0.0.1a1/iamai/adapter/dingtalk/event.py +108 -0
- iamai-0.0.1a1/iamai/adapter/dingtalk/exceptions.py +16 -0
- iamai-0.0.1a1/iamai/adapter/dingtalk/message.py +139 -0
- iamai-0.0.1a1/iamai/adapter/gensokyo/__init__.py +311 -0
- iamai-0.0.1a1/iamai/adapter/gensokyo/config.py +32 -0
- iamai-0.0.1a1/iamai/adapter/gensokyo/event.py +454 -0
- iamai-0.0.1a1/iamai/adapter/gensokyo/exceptions.py +42 -0
- iamai-0.0.1a1/iamai/adapter/gensokyo/message.py +279 -0
- iamai-0.0.1a1/iamai/adapter/kook/__init__.py +408 -0
- iamai-0.0.1a1/iamai/adapter/kook/api/__init__.py +2 -0
- iamai-0.0.1a1/iamai/adapter/kook/api/client.py +2 -0
- iamai-0.0.1a1/iamai/adapter/kook/api/client.pyi +347 -0
- iamai-0.0.1a1/iamai/adapter/kook/api/handle.py +75 -0
- iamai-0.0.1a1/iamai/adapter/kook/api/model.py +461 -0
- iamai-0.0.1a1/iamai/adapter/kook/config.py +26 -0
- iamai-0.0.1a1/iamai/adapter/kook/event.py +929 -0
- iamai-0.0.1a1/iamai/adapter/kook/exceptions.py +95 -0
- iamai-0.0.1a1/iamai/adapter/kook/message.py +336 -0
- iamai-0.0.1a1/iamai/adapter/onebot11/__init__.py +291 -0
- iamai-0.0.1a1/iamai/adapter/onebot11/config.py +29 -0
- iamai-0.0.1a1/iamai/adapter/onebot11/event.py +454 -0
- iamai-0.0.1a1/iamai/adapter/onebot11/exceptions.py +42 -0
- iamai-0.0.1a1/iamai/adapter/onebot11/message.py +279 -0
- iamai-0.0.1a1/iamai/adapter/red/__init__.py +202 -0
- iamai-0.0.1a1/iamai/adapter/red/config.py +38 -0
- iamai-0.0.1a1/iamai/adapter/red/event.py +436 -0
- iamai-0.0.1a1/iamai/adapter/utils.py +278 -0
- iamai-0.0.1a1/iamai/bot.py +996 -0
- iamai-0.0.1a1/iamai/cli.py +247 -0
- iamai-0.0.1a1/iamai/config.py +76 -0
- iamai-0.0.1a1/iamai/const.py +3 -0
- iamai-0.0.1a1/iamai/dependencies.py +152 -0
- iamai-0.0.1a1/iamai/event.py +131 -0
- iamai-0.0.1a1/iamai/exceptions.py +43 -0
- iamai-0.0.1a1/iamai/log.py +30 -0
- iamai-0.0.1a1/iamai/message.py +518 -0
- iamai-0.0.1a1/iamai/models/BM25/__init__.py +68 -0
- iamai-0.0.1a1/iamai/models/BM25/config.py +0 -0
- iamai-0.0.1a1/iamai/models/__init__.py +0 -0
- iamai-0.0.1a1/iamai/plugin.py +172 -0
- iamai-0.0.1a1/iamai/py.typed +0 -0
- iamai-0.0.1a1/iamai/typing.py +41 -0
- iamai-0.0.1a1/iamai/utils.py +298 -0
- iamai-0.0.1a1/pyproject.toml +111 -0
iamai-0.0.1a1/.gitignore
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
target/
|
|
76
|
+
|
|
77
|
+
# Jupyter Notebook
|
|
78
|
+
.ipynb_checkpoints
|
|
79
|
+
|
|
80
|
+
# IPython
|
|
81
|
+
profile_default/
|
|
82
|
+
ipython_config.py
|
|
83
|
+
|
|
84
|
+
# pyenv
|
|
85
|
+
.python-version
|
|
86
|
+
|
|
87
|
+
# pipenv
|
|
88
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
89
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
90
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
91
|
+
# install all needed dependencies.
|
|
92
|
+
#Pipfile.lock
|
|
93
|
+
|
|
94
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
95
|
+
__pypackages__/
|
|
96
|
+
|
|
97
|
+
# Celery stuff
|
|
98
|
+
celerybeat-schedule
|
|
99
|
+
celerybeat.pid
|
|
100
|
+
|
|
101
|
+
# SageMath parsed files
|
|
102
|
+
*.sage.py
|
|
103
|
+
|
|
104
|
+
# Environments
|
|
105
|
+
.env
|
|
106
|
+
.venv
|
|
107
|
+
env/
|
|
108
|
+
venv/
|
|
109
|
+
ENV/
|
|
110
|
+
env.bak/
|
|
111
|
+
venv.bak/
|
|
112
|
+
|
|
113
|
+
# Spyder project settings
|
|
114
|
+
.spyderproject
|
|
115
|
+
.spyproject
|
|
116
|
+
|
|
117
|
+
# Rope project settings
|
|
118
|
+
.ropeproject
|
|
119
|
+
|
|
120
|
+
# mkdocs documentation
|
|
121
|
+
/site
|
|
122
|
+
|
|
123
|
+
# mypy
|
|
124
|
+
.mypy_cache/
|
|
125
|
+
.dmypy.json
|
|
126
|
+
dmypy.json
|
|
127
|
+
|
|
128
|
+
# Pyre type checker
|
|
129
|
+
.pyre/
|
|
130
|
+
|
|
131
|
+
# Node
|
|
132
|
+
node_modules/
|
|
133
|
+
.temp/
|
|
134
|
+
|
|
135
|
+
# Project
|
|
136
|
+
.idea
|
|
137
|
+
.vscode
|
|
138
|
+
docs_build/**/*.rst
|
|
139
|
+
docs_build/_build
|
|
140
|
+
/tests/config.json
|
|
141
|
+
/tests/config.toml
|
|
142
|
+
/tests/data/session.token
|
|
143
|
+
/docs/api/**/*.md
|
|
144
|
+
/docs/.next
|
|
145
|
+
tests/plugins/webui/__init__.py
|
|
146
|
+
tests/plugins/webui/config.py
|
|
147
|
+
iamai/adapter/github/
|
|
148
|
+
iamai/adapter/cqhttp/
|
|
149
|
+
|
|
150
|
+
.pdm-python
|
|
151
|
+
%Project%retrofor%iamai/chat_history/history.sqlite
|
|
152
|
+
|
|
153
|
+
# pdm
|
|
154
|
+
dist/**/*
|
|
155
|
+
.pdm-build/**/*
|
|
156
|
+
|
|
157
|
+
# tests
|
|
158
|
+
tests/logs
|
iamai-0.0.1a1/COPYING
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Retro for wut?
|
|
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.
|
iamai-0.0.1a1/PKG-INFO
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: iamai
|
|
3
|
+
Version: 0.0.1a1
|
|
4
|
+
Summary: Comprehensive AI Toolkit for Multimodal Learning and Cross-Platform Robotics.
|
|
5
|
+
Project-URL: Homepage, https://iamai.is-a.dev
|
|
6
|
+
Project-URL: Documentation, https://iamai.is-a.dev
|
|
7
|
+
Project-URL: Repository, https://github.com/retrofor/iamai
|
|
8
|
+
Project-URL: Changelog, https://iamai.is-a.dev/en/latest/changelog.html#
|
|
9
|
+
Author-email: 简律纯 <i@jyunko.cn>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: COPYING
|
|
12
|
+
Keywords: apscheduler,bilibili,bilibili-live,bot,console,dingtalk,gensokyo,kook,onebot11,red
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Framework :: Robot Framework
|
|
16
|
+
Classifier: Framework :: Robot Framework :: Library
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Topic :: Communications :: Chat
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Requires-Dist: aiohttp>=3.9.1
|
|
23
|
+
Requires-Dist: click>=8.1.7
|
|
24
|
+
Requires-Dist: loguru<0.8.0,>=0.7.0
|
|
25
|
+
Requires-Dist: pydantic<3.0.0,>=2.0.3
|
|
26
|
+
Requires-Dist: requests>=2.31.0
|
|
27
|
+
Requires-Dist: tomli<3.0.0,>=2.0.0; python_version < '3.11'
|
|
28
|
+
Requires-Dist: typing-extensions>=4.8.0
|
|
29
|
+
Requires-Dist: watchfiles>=0.21.0
|
|
30
|
+
Provides-Extra: all
|
|
31
|
+
Requires-Dist: iamai-adapter-apscheduler; extra == 'all'
|
|
32
|
+
Requires-Dist: iamai-adapter-bililive; extra == 'all'
|
|
33
|
+
Requires-Dist: iamai-adapter-console; extra == 'all'
|
|
34
|
+
Requires-Dist: iamai-adapter-dingtalk; extra == 'all'
|
|
35
|
+
Requires-Dist: iamai-adapter-gensokyo; extra == 'all'
|
|
36
|
+
Requires-Dist: iamai-adapter-kook; extra == 'all'
|
|
37
|
+
Requires-Dist: iamai-adapter-onebot11; extra == 'all'
|
|
38
|
+
Requires-Dist: iamai-adapter-red; extra == 'all'
|
|
39
|
+
Requires-Dist: watchfiles; extra == 'all'
|
|
40
|
+
Provides-Extra: apscheduler
|
|
41
|
+
Requires-Dist: iamai-adapter-apscheduler; extra == 'apscheduler'
|
|
42
|
+
Provides-Extra: bililive
|
|
43
|
+
Requires-Dist: iamai-adapter-bililive; extra == 'bililive'
|
|
44
|
+
Provides-Extra: console
|
|
45
|
+
Requires-Dist: iamai-adapter-console; extra == 'console'
|
|
46
|
+
Provides-Extra: dingtalk
|
|
47
|
+
Requires-Dist: iamai-adapter-dingtalk; extra == 'dingtalk'
|
|
48
|
+
Provides-Extra: gensokyo
|
|
49
|
+
Requires-Dist: iamai-adapter-gensokyo; extra == 'gensokyo'
|
|
50
|
+
Provides-Extra: hot-reload
|
|
51
|
+
Requires-Dist: watchfiles; extra == 'hot-reload'
|
|
52
|
+
Provides-Extra: kook
|
|
53
|
+
Requires-Dist: iamai-adapter-kook; extra == 'kook'
|
|
54
|
+
Provides-Extra: onebot11
|
|
55
|
+
Requires-Dist: iamai-adapter-onebot11; extra == 'onebot11'
|
|
56
|
+
Provides-Extra: red
|
|
57
|
+
Requires-Dist: iamai-adapter-red; extra == 'red'
|
|
58
|
+
Description-Content-Type: text/markdown
|
|
59
|
+
|
|
60
|
+
<p align="center">
|
|
61
|
+
<img width="128" align="center" src="https://cdn.jsdelivr.net/gh/retrofor/iamai@master/docs/_static/retro.png" />
|
|
62
|
+
<img width="60" align="right" src="https://cdn.jsdelivr.net/gh/retrofor/iamai@master/docs/_static/icons/retro_plus.png" />
|
|
63
|
+
<img width="60" align="left" src="https://images.repography.com/40962158/retrofor/iamai/structure/afEhYzXo83AMGRNy9EzPPQcX9ECBKj2gOPhvmpzMFSg/DQMxDEhfNZdq6zFhjPa1G61Bg9g-DRhQiwNY-W2ZHVE_table.svg" />
|
|
64
|
+
</p>
|
|
65
|
+
<br />
|
|
66
|
+
<h1 align="center">
|
|
67
|
+
iamai
|
|
68
|
+
</h1>
|
|
69
|
+
<p align="center">
|
|
70
|
+
<a href="https://discord.gg/9vG9352RXS"><img alt="Discord" src="https://img.shields.io/discord/1063871387527303188"></a>
|
|
71
|
+
<a href="https://jq.qq.com/?_wv=1027&k=OOUmgrqx"><img alt="QQ群" src="https://img.shields.io/badge/-QQ群%20761859776-002FA7?style=flat-square&logo=Tencent QQ&logoColor=white"></a>
|
|
72
|
+
</p>
|
|
73
|
+
<p align="center">
|
|
74
|
+
Comprehensive AI Toolkit for Multimodal Learning and Cross-Platform Robotics.
|
|
75
|
+
</p>
|
|
76
|
+
<p align="center">
|
|
77
|
+
<a href="https://pypi.python.org/pypi/iamai">
|
|
78
|
+
<img src="https://img.shields.io/pypi/v/iamai?style=flat-square" alt="pypi">
|
|
79
|
+
</a>
|
|
80
|
+
<img src="https://img.shields.io/badge/python-3.8+-blue?style=flat-square" alt="python">
|
|
81
|
+
<br>
|
|
82
|
+
<img src="https://results.pre-commit.ci/badge/github/retrofor/iamai/main.svg">
|
|
83
|
+
<a href='https://iamai.is-a.dev/en/latest/?badge=latest'>
|
|
84
|
+
<img src='https://readthedocs.org/projects/iamai/badge/?version=latest' alt='Documentation Status' />
|
|
85
|
+
</a>
|
|
86
|
+
<br>
|
|
87
|
+
<a style="text-decoration:none" href="https://www.codacy.com/gh/retrofor/iamai/dashboard?utm_source=github.com&utm_medium=referral&utm_content=retrofor/iamai&utm_campaign=Badge_Gradee" target="_blank">
|
|
88
|
+
<img src="https://app.codacy.com/project/badge/Grade/f3611d85db764236b65fac956bdb53df" alt="Codacy Badge" />
|
|
89
|
+
</a>
|
|
90
|
+
<img src="https://img.shields.io/badge/code_style-black-000000.svg?style=flat-square" alt="Codacy Badge" />
|
|
91
|
+
</p>
|
|
92
|
+
<p align="center">
|
|
93
|
+
</p>
|
|
94
|
+
<p align="center">
|
|
95
|
+
<!-- onebot -->
|
|
96
|
+
<a style="text-decoration:none" href="https://onebot.dev" target="_blank">
|
|
97
|
+
<img src="https://img.shields.io/badge/-Onebot%2011-000020?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==&logoColor=white" alt="onebotv11" />
|
|
98
|
+
</a>
|
|
99
|
+
<a href="https://www.kookapp.cn/">
|
|
100
|
+
<img src="https://img.shields.io/badge/-%E5%BC%80%E9%BB%91%E5%95%A6Kook-83700?style=flat-square&logo=Discord&logoColor=white">
|
|
101
|
+
</a>
|
|
102
|
+
<!-- github -->
|
|
103
|
+
<!-- <img src="https://img.shields.io/badge/-github-181717?style=flat-square&logo=github&logoColor=white"> -->
|
|
104
|
+
<!-- discord -->
|
|
105
|
+
<!-- <img src="https://img.shields.io/badge/-Discord-5865F2?style=flat-square&logo=Discord&logoColor=white"> -->
|
|
106
|
+
<!-- bilibili live -->
|
|
107
|
+
<img src="https://img.shields.io/badge/-BiliBili Live-00A1D6?style=flat-square&logo=Bilibili&logoColor=white">
|
|
108
|
+
<br />
|
|
109
|
+
<!-- dingtalk -->
|
|
110
|
+
<img src="https://img.shields.io/badge/http/stream-DingTalk-blue?style=flat-square">
|
|
111
|
+
<!-- <br> -->
|
|
112
|
+
<!-- minecraft -->
|
|
113
|
+
<!-- <img src="https://img.shields.io/badge/-Minecraft Server-62B47A?style=flat-square&logo=Minecraft&logoColor=white"> -->
|
|
114
|
+
<!-- twitter -->
|
|
115
|
+
<!-- <img src="https://img.shields.io/badge/-Twitter-1DA1F2?style=flat-square&logo=twitter&logoColor=white"> -->
|
|
116
|
+
<!-- console -->
|
|
117
|
+
<img src="https://img.shields.io/badge/-Console-4EAA25?style=flat-square&logo=GNU bash&logoColor=white">
|
|
118
|
+
<!-- tg -->
|
|
119
|
+
<!-- <img src="https://img.shields.io/badge/-Telegram-26A5E4?style=flat-square&logo=telegram&logoColor=white"> -->
|
|
120
|
+
<!-- red -->
|
|
121
|
+
<img src="https://img.shields.io/badge/Chronocat-Red-red?style=flat-square&logo=&logoColor=white">
|
|
122
|
+
<!-- gensokyo -->
|
|
123
|
+
<img src="https://img.shields.io/badge/Onebot11-Gensokyo-blue?style=flat-square&logo=[red](https://mirror.ghproxy.com/github.com/Hoshinonyaruko/Gensokyo/blob/main/frontend/public/icons/favicon-128x128.png)&logoColor=white">
|
|
124
|
+
</a>
|
|
125
|
+
</p>
|
|
126
|
+
<p align="center">
|
|
127
|
+
</p>
|
|
128
|
+
<p align="center">
|
|
129
|
+
<img src="https://img.shields.io/github/forks/retrofor/iamai?style=social" >
|
|
130
|
+
<img src="https://img.shields.io/github/stars/retrofor/iamai?style=social" >
|
|
131
|
+
<br>
|
|
132
|
+
<img src="https://img.shields.io/github/watchers/retrofor/iamai?style=social" >
|
|
133
|
+
<img src="https://img.shields.io/github/search/retrofor/iamai/goto?style=social" >
|
|
134
|
+
<br>
|
|
135
|
+
<img src="https://img.shields.io/github/repo-size/retrofor/iamai?style=social" >
|
|
136
|
+
<img src="https://img.shields.io/github/languages/top/retrofor/iamai?style=social" >
|
|
137
|
+
</p>
|
|
138
|
+
|
|
139
|
+
<!-- start intro -->
|
|
140
|
+
|
|
141
|
+
Welcome to iamai, a powerful and comprehensive AI toolkit that seamlessly integrates multimodal machine learning capabilities with advanced tools for cross-platform robot development!
|
|
142
|
+
|
|
143
|
+
> 🌍 This library is designed to provide developers with a unified solution for creating intelligent systems that span multiple modalities and operate across diverse platforms.
|
|
144
|
+
|
|
145
|
+
<!-- end intro -->
|
|
146
|
+
|
|
147
|
+
<!-- start index -->
|
|
148
|
+
|
|
149
|
+
- 🎪 **Interactive [docs](https://iamai.is-a.dev) & [demos](https://iamai.is-a.dev/)**
|
|
150
|
+
- 🕶 **Seamless migration**: Works for **both** [Rasa]() and [GPT]() and more...
|
|
151
|
+
- ⚡ **Fully tree shakeable**: Only take what you want, [bundle size](https://iamai.retrofor.space/export-size)
|
|
152
|
+
- 🔩 **Flexible**: Configurable event filters and targets
|
|
153
|
+
- 🔌 **Optional [Add-ons](https://iamai.retrofor.space/add-ons)**: [Apscheduler](https://iamai.retrofor.space/add-ons/apscheduler), etc.
|
|
154
|
+
- 👍 **Cross-platform**: [dingtalk](https://iamai.retrofor.space/guide/dingtalk-adapter.html) etc.
|
|
155
|
+
|
|
156
|
+
<!-- end index -->
|
|
157
|
+
|
|
158
|
+
First of all, in the field of machine learning, we drew inspiration from the excellent design of [Hugging Face](https://huggingface.co)'s [transformers](https://github.com/huggingface/transformers) 🤗 for the use of pre-trained models. We would like to express our gratitude to the authors of Hugging Face and their open-source community.
|
|
159
|
+
|
|
160
|
+
Secondly, regarding the cross-platform robot framework, it is primarily based on [st](https://github.com/st1020)'s [alicebot](https://github.com/AliceBotProject/alicebot). We have made numerous adaptations to make it compatible with machine learning. We would like to thank the st and alicebot open-source communities for their contributions.
|
|
161
|
+
|
|
162
|
+
To avoid any potential disputes or misunderstandings, we have listed the licenses of the projects we have used and express our gratitude towards them. please see [credits.md](./credits.md).
|
|
163
|
+
|
|
164
|
+
<!-- ## 特别的鸣谢
|
|
165
|
+
|
|
166
|
+
我们很乐意在下面列出对IamAI的发展方向和动机有着[重大贡献](https://academic.jyunko.cn/2023/04/04/April-Fours-Day.html)的组织和个人。如果你认为你应该在这里,请至少要像Bryan不可思议那样在文章底栏留言或者发送邮件联系我们 :D
|
|
167
|
+
|
|
168
|
+
个人: [A60](https://github.com/djkcyl)、[Bryan不可思议](https://github.com/ProgramRipper)
|
|
169
|
+
组织: [GariaProject](https://github.com/GraiaProject)
|
|
170
|
+
|
|
171
|
+
如果没有以上个人和组织的帮助,IamAI将不会有现在的样子。我们真的很感谢他们。 -->
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
[MIT](https://github.com/retrofor/iamai/blob/main/LICENSE) © 2023-PRESENT [Retro for Wut?](https://github.com/retrofor).
|
|
176
|
+
|
|
177
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fretrofor%2Fiamai?ref=badge_shield)
|
|
178
|
+
|
|
179
|
+
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fretrofor%2Fiamai?ref=badge_large" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fretrofor%2Fiamai.svg?type=large"/></a>
|
iamai-0.0.1a1/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="128" align="center" src="https://cdn.jsdelivr.net/gh/retrofor/iamai@master/docs/_static/retro.png" />
|
|
3
|
+
<img width="60" align="right" src="https://cdn.jsdelivr.net/gh/retrofor/iamai@master/docs/_static/icons/retro_plus.png" />
|
|
4
|
+
<img width="60" align="left" src="https://images.repography.com/40962158/retrofor/iamai/structure/afEhYzXo83AMGRNy9EzPPQcX9ECBKj2gOPhvmpzMFSg/DQMxDEhfNZdq6zFhjPa1G61Bg9g-DRhQiwNY-W2ZHVE_table.svg" />
|
|
5
|
+
</p>
|
|
6
|
+
<br />
|
|
7
|
+
<h1 align="center">
|
|
8
|
+
iamai
|
|
9
|
+
</h1>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://discord.gg/9vG9352RXS"><img alt="Discord" src="https://img.shields.io/discord/1063871387527303188"></a>
|
|
12
|
+
<a href="https://jq.qq.com/?_wv=1027&k=OOUmgrqx"><img alt="QQ群" src="https://img.shields.io/badge/-QQ群%20761859776-002FA7?style=flat-square&logo=Tencent QQ&logoColor=white"></a>
|
|
13
|
+
</p>
|
|
14
|
+
<p align="center">
|
|
15
|
+
Comprehensive AI Toolkit for Multimodal Learning and Cross-Platform Robotics.
|
|
16
|
+
</p>
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://pypi.python.org/pypi/iamai">
|
|
19
|
+
<img src="https://img.shields.io/pypi/v/iamai?style=flat-square" alt="pypi">
|
|
20
|
+
</a>
|
|
21
|
+
<img src="https://img.shields.io/badge/python-3.8+-blue?style=flat-square" alt="python">
|
|
22
|
+
<br>
|
|
23
|
+
<img src="https://results.pre-commit.ci/badge/github/retrofor/iamai/main.svg">
|
|
24
|
+
<a href='https://iamai.is-a.dev/en/latest/?badge=latest'>
|
|
25
|
+
<img src='https://readthedocs.org/projects/iamai/badge/?version=latest' alt='Documentation Status' />
|
|
26
|
+
</a>
|
|
27
|
+
<br>
|
|
28
|
+
<a style="text-decoration:none" href="https://www.codacy.com/gh/retrofor/iamai/dashboard?utm_source=github.com&utm_medium=referral&utm_content=retrofor/iamai&utm_campaign=Badge_Gradee" target="_blank">
|
|
29
|
+
<img src="https://app.codacy.com/project/badge/Grade/f3611d85db764236b65fac956bdb53df" alt="Codacy Badge" />
|
|
30
|
+
</a>
|
|
31
|
+
<img src="https://img.shields.io/badge/code_style-black-000000.svg?style=flat-square" alt="Codacy Badge" />
|
|
32
|
+
</p>
|
|
33
|
+
<p align="center">
|
|
34
|
+
</p>
|
|
35
|
+
<p align="center">
|
|
36
|
+
<!-- onebot -->
|
|
37
|
+
<a style="text-decoration:none" href="https://onebot.dev" target="_blank">
|
|
38
|
+
<img src="https://img.shields.io/badge/-Onebot%2011-000020?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==&logoColor=white" alt="onebotv11" />
|
|
39
|
+
</a>
|
|
40
|
+
<a href="https://www.kookapp.cn/">
|
|
41
|
+
<img src="https://img.shields.io/badge/-%E5%BC%80%E9%BB%91%E5%95%A6Kook-83700?style=flat-square&logo=Discord&logoColor=white">
|
|
42
|
+
</a>
|
|
43
|
+
<!-- github -->
|
|
44
|
+
<!-- <img src="https://img.shields.io/badge/-github-181717?style=flat-square&logo=github&logoColor=white"> -->
|
|
45
|
+
<!-- discord -->
|
|
46
|
+
<!-- <img src="https://img.shields.io/badge/-Discord-5865F2?style=flat-square&logo=Discord&logoColor=white"> -->
|
|
47
|
+
<!-- bilibili live -->
|
|
48
|
+
<img src="https://img.shields.io/badge/-BiliBili Live-00A1D6?style=flat-square&logo=Bilibili&logoColor=white">
|
|
49
|
+
<br />
|
|
50
|
+
<!-- dingtalk -->
|
|
51
|
+
<img src="https://img.shields.io/badge/http/stream-DingTalk-blue?style=flat-square">
|
|
52
|
+
<!-- <br> -->
|
|
53
|
+
<!-- minecraft -->
|
|
54
|
+
<!-- <img src="https://img.shields.io/badge/-Minecraft Server-62B47A?style=flat-square&logo=Minecraft&logoColor=white"> -->
|
|
55
|
+
<!-- twitter -->
|
|
56
|
+
<!-- <img src="https://img.shields.io/badge/-Twitter-1DA1F2?style=flat-square&logo=twitter&logoColor=white"> -->
|
|
57
|
+
<!-- console -->
|
|
58
|
+
<img src="https://img.shields.io/badge/-Console-4EAA25?style=flat-square&logo=GNU bash&logoColor=white">
|
|
59
|
+
<!-- tg -->
|
|
60
|
+
<!-- <img src="https://img.shields.io/badge/-Telegram-26A5E4?style=flat-square&logo=telegram&logoColor=white"> -->
|
|
61
|
+
<!-- red -->
|
|
62
|
+
<img src="https://img.shields.io/badge/Chronocat-Red-red?style=flat-square&logo=&logoColor=white">
|
|
63
|
+
<!-- gensokyo -->
|
|
64
|
+
<img src="https://img.shields.io/badge/Onebot11-Gensokyo-blue?style=flat-square&logo=[red](https://mirror.ghproxy.com/github.com/Hoshinonyaruko/Gensokyo/blob/main/frontend/public/icons/favicon-128x128.png)&logoColor=white">
|
|
65
|
+
</a>
|
|
66
|
+
</p>
|
|
67
|
+
<p align="center">
|
|
68
|
+
</p>
|
|
69
|
+
<p align="center">
|
|
70
|
+
<img src="https://img.shields.io/github/forks/retrofor/iamai?style=social" >
|
|
71
|
+
<img src="https://img.shields.io/github/stars/retrofor/iamai?style=social" >
|
|
72
|
+
<br>
|
|
73
|
+
<img src="https://img.shields.io/github/watchers/retrofor/iamai?style=social" >
|
|
74
|
+
<img src="https://img.shields.io/github/search/retrofor/iamai/goto?style=social" >
|
|
75
|
+
<br>
|
|
76
|
+
<img src="https://img.shields.io/github/repo-size/retrofor/iamai?style=social" >
|
|
77
|
+
<img src="https://img.shields.io/github/languages/top/retrofor/iamai?style=social" >
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
<!-- start intro -->
|
|
81
|
+
|
|
82
|
+
Welcome to iamai, a powerful and comprehensive AI toolkit that seamlessly integrates multimodal machine learning capabilities with advanced tools for cross-platform robot development!
|
|
83
|
+
|
|
84
|
+
> 🌍 This library is designed to provide developers with a unified solution for creating intelligent systems that span multiple modalities and operate across diverse platforms.
|
|
85
|
+
|
|
86
|
+
<!-- end intro -->
|
|
87
|
+
|
|
88
|
+
<!-- start index -->
|
|
89
|
+
|
|
90
|
+
- 🎪 **Interactive [docs](https://iamai.is-a.dev) & [demos](https://iamai.is-a.dev/)**
|
|
91
|
+
- 🕶 **Seamless migration**: Works for **both** [Rasa]() and [GPT]() and more...
|
|
92
|
+
- ⚡ **Fully tree shakeable**: Only take what you want, [bundle size](https://iamai.retrofor.space/export-size)
|
|
93
|
+
- 🔩 **Flexible**: Configurable event filters and targets
|
|
94
|
+
- 🔌 **Optional [Add-ons](https://iamai.retrofor.space/add-ons)**: [Apscheduler](https://iamai.retrofor.space/add-ons/apscheduler), etc.
|
|
95
|
+
- 👍 **Cross-platform**: [dingtalk](https://iamai.retrofor.space/guide/dingtalk-adapter.html) etc.
|
|
96
|
+
|
|
97
|
+
<!-- end index -->
|
|
98
|
+
|
|
99
|
+
First of all, in the field of machine learning, we drew inspiration from the excellent design of [Hugging Face](https://huggingface.co)'s [transformers](https://github.com/huggingface/transformers) 🤗 for the use of pre-trained models. We would like to express our gratitude to the authors of Hugging Face and their open-source community.
|
|
100
|
+
|
|
101
|
+
Secondly, regarding the cross-platform robot framework, it is primarily based on [st](https://github.com/st1020)'s [alicebot](https://github.com/AliceBotProject/alicebot). We have made numerous adaptations to make it compatible with machine learning. We would like to thank the st and alicebot open-source communities for their contributions.
|
|
102
|
+
|
|
103
|
+
To avoid any potential disputes or misunderstandings, we have listed the licenses of the projects we have used and express our gratitude towards them. please see [credits.md](./credits.md).
|
|
104
|
+
|
|
105
|
+
<!-- ## 特别的鸣谢
|
|
106
|
+
|
|
107
|
+
我们很乐意在下面列出对IamAI的发展方向和动机有着[重大贡献](https://academic.jyunko.cn/2023/04/04/April-Fours-Day.html)的组织和个人。如果你认为你应该在这里,请至少要像Bryan不可思议那样在文章底栏留言或者发送邮件联系我们 :D
|
|
108
|
+
|
|
109
|
+
个人: [A60](https://github.com/djkcyl)、[Bryan不可思议](https://github.com/ProgramRipper)
|
|
110
|
+
组织: [GariaProject](https://github.com/GraiaProject)
|
|
111
|
+
|
|
112
|
+
如果没有以上个人和组织的帮助,IamAI将不会有现在的样子。我们真的很感谢他们。 -->
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](https://github.com/retrofor/iamai/blob/main/LICENSE) © 2023-PRESENT [Retro for Wut?](https://github.com/retrofor).
|
|
117
|
+
|
|
118
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fretrofor%2Fiamai?ref=badge_shield)
|
|
119
|
+
|
|
120
|
+
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fretrofor%2Fiamai?ref=badge_large" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fretrofor%2Fiamai.svg?type=large"/></a>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""API Documentation
|
|
2
|
+
|
|
3
|
+
Comprehensive AI Toolkit for Multimodal Learning and Cross-Platform Robotics.
|
|
4
|
+
|
|
5
|
+
This Module imports the following contents from the sub-module.
|
|
6
|
+
"""
|
|
7
|
+
from iamai.adapter import Adapter
|
|
8
|
+
from iamai.bot import Bot
|
|
9
|
+
from iamai.config import ConfigModel
|
|
10
|
+
from iamai.dependencies import Depends
|
|
11
|
+
from iamai.event import Event, MessageEvent
|
|
12
|
+
from iamai.plugin import Plugin
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Adapter",
|
|
16
|
+
"Bot",
|
|
17
|
+
"ConfigModel",
|
|
18
|
+
"Depends",
|
|
19
|
+
"Event",
|
|
20
|
+
"MessageEvent",
|
|
21
|
+
"Plugin",
|
|
22
|
+
]
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""iamai 协议适配器。
|
|
2
|
+
|
|
3
|
+
所有协议适配器都必须继承自 `Adapter` 基类。
|
|
4
|
+
"""
|
|
5
|
+
import os
|
|
6
|
+
from abc import ABC, abstractmethod
|
|
7
|
+
from typing import (
|
|
8
|
+
TYPE_CHECKING,
|
|
9
|
+
Any,
|
|
10
|
+
Awaitable,
|
|
11
|
+
Callable,
|
|
12
|
+
Generic,
|
|
13
|
+
Optional,
|
|
14
|
+
Type,
|
|
15
|
+
TypeVar,
|
|
16
|
+
Union,
|
|
17
|
+
final,
|
|
18
|
+
overload,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from iamai.event import Event
|
|
22
|
+
from iamai.typing import ConfigT, EventT
|
|
23
|
+
from iamai.utils import is_config_class
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from iamai.bot import Bot
|
|
27
|
+
|
|
28
|
+
__all__ = ["Adapter"]
|
|
29
|
+
|
|
30
|
+
if os.getenv("IAMAI_DEV") == "1": # pragma: no cover
|
|
31
|
+
# 当处于开发环境时,使用 pkg_resources 风格的命名空间包
|
|
32
|
+
__import__("pkg_resources").declare_namespace(__name__)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
_EventT = TypeVar("_EventT", bound="Event[Any]")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Adapter(Generic[EventT, ConfigT], ABC):
|
|
39
|
+
"""协议适配器基类。
|
|
40
|
+
|
|
41
|
+
Attributes:
|
|
42
|
+
name: 适配器的名称。
|
|
43
|
+
bot: 当前的机器人对象。
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
name: str
|
|
47
|
+
bot: "Bot"
|
|
48
|
+
Config: Type[ConfigT]
|
|
49
|
+
|
|
50
|
+
def __init__(self, bot: "Bot") -> None:
|
|
51
|
+
"""初始化。
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
bot: 当前机器人对象。
|
|
55
|
+
"""
|
|
56
|
+
if not hasattr(self, "name"):
|
|
57
|
+
self.name = self.__class__.__name__
|
|
58
|
+
self.bot: Bot = bot
|
|
59
|
+
self.handle_event = self.bot.handle_event
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def config(self) -> ConfigT:
|
|
63
|
+
"""适配器配置。"""
|
|
64
|
+
default: Any = None
|
|
65
|
+
config_class = getattr(self, "Config", None)
|
|
66
|
+
if is_config_class(config_class):
|
|
67
|
+
return getattr(
|
|
68
|
+
self.bot.config.adapter,
|
|
69
|
+
config_class.__config_name__,
|
|
70
|
+
default,
|
|
71
|
+
)
|
|
72
|
+
return default
|
|
73
|
+
|
|
74
|
+
@final
|
|
75
|
+
async def safe_run(self) -> None:
|
|
76
|
+
"""附带有异常处理地安全运行适配器。"""
|
|
77
|
+
try:
|
|
78
|
+
await self.run()
|
|
79
|
+
except Exception as e:
|
|
80
|
+
self.bot.error_or_exception(
|
|
81
|
+
f"Run adapter {self.__class__.__name__} failed:", e
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
@abstractmethod
|
|
85
|
+
async def run(self) -> None:
|
|
86
|
+
"""适配器运行方法,适配器开发者必须实现该方法。
|
|
87
|
+
|
|
88
|
+
适配器运行过程中保持保持运行,当此方法结束后, AliceBot 不会自动重新启动适配器。
|
|
89
|
+
"""
|
|
90
|
+
raise NotImplementedError
|
|
91
|
+
|
|
92
|
+
async def startup(self) -> None:
|
|
93
|
+
"""在适配器开始运行前运行的方法,用于初始化适配器。
|
|
94
|
+
|
|
95
|
+
AliceBot 依次运行并等待所有适配器的 `startup()` 方法,待运行完毕后再创建 `run()` 任务。
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
async def shutdown(self) -> None:
|
|
99
|
+
"""在适配器结束运行时运行的方法,用于安全地关闭适配器。
|
|
100
|
+
|
|
101
|
+
AliceBot 在接收到系统的结束信号后依次运行并等待所有适配器的 `shutdown()` 方法。
|
|
102
|
+
当强制退出时此方法可能未被执行。
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
@overload
|
|
106
|
+
async def get(
|
|
107
|
+
self,
|
|
108
|
+
func: Optional[Callable[[EventT], Union[bool, Awaitable[bool]]]] = None,
|
|
109
|
+
*,
|
|
110
|
+
event_type: None = None,
|
|
111
|
+
max_try_times: Optional[int] = None,
|
|
112
|
+
timeout: Optional[Union[int, float]] = None,
|
|
113
|
+
) -> EventT:
|
|
114
|
+
...
|
|
115
|
+
|
|
116
|
+
@overload
|
|
117
|
+
async def get(
|
|
118
|
+
self,
|
|
119
|
+
func: Optional[Callable[[_EventT], Union[bool, Awaitable[bool]]]] = None,
|
|
120
|
+
*,
|
|
121
|
+
event_type: Type[_EventT],
|
|
122
|
+
max_try_times: Optional[int] = None,
|
|
123
|
+
timeout: Optional[Union[int, float]] = None,
|
|
124
|
+
) -> _EventT:
|
|
125
|
+
...
|
|
126
|
+
|
|
127
|
+
@final
|
|
128
|
+
async def get(
|
|
129
|
+
self,
|
|
130
|
+
func: Optional[Callable[[Any], Union[bool, Awaitable[bool]]]] = None,
|
|
131
|
+
*,
|
|
132
|
+
event_type: Any = None,
|
|
133
|
+
max_try_times: Optional[int] = None,
|
|
134
|
+
timeout: Optional[Union[int, float]] = None,
|
|
135
|
+
) -> Event[Any]:
|
|
136
|
+
"""获取满足指定条件的的事件,协程会等待直到适配器接收到满足条件的事件、超过最大事件数或超时。
|
|
137
|
+
|
|
138
|
+
类似 `Bot` 类的 `get()` 方法,但是隐含了判断产生事件的适配器是本适配器。
|
|
139
|
+
等效于 `Bot` 类的 `get()` 方法传入 adapter_type 为本适配器类型。
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
func: 协程或者函数,函数会被自动包装为协程执行。
|
|
143
|
+
要求接受一个事件作为参数,返回布尔值。
|
|
144
|
+
当协程返回 `True` 时返回当前事件。
|
|
145
|
+
当为 `None` 时相当于输入对于任何事件均返回真的协程,即返回适配器接收到的下一个事件。
|
|
146
|
+
event_type: 当指定时,只接受指定类型的事件,先于 func 条件生效。默认为 `None`。
|
|
147
|
+
max_try_times: 最大事件数。
|
|
148
|
+
timeout: 超时时间。
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
返回满足 func 条件的事件。
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
GetEventTimeout: 超过最大事件数或超时。
|
|
155
|
+
"""
|
|
156
|
+
return await self.bot.get(
|
|
157
|
+
func,
|
|
158
|
+
event_type=event_type,
|
|
159
|
+
adapter_type=type(self),
|
|
160
|
+
max_try_times=max_try_times,
|
|
161
|
+
timeout=timeout,
|
|
162
|
+
)
|