bisim.py 0.1.0__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.
- bisim_py-0.1.0/.gitignore +28 -0
- bisim_py-0.1.0/CHANGELOG.md +26 -0
- bisim_py-0.1.0/LICENSE +22 -0
- bisim_py-0.1.0/PKG-INFO +175 -0
- bisim_py-0.1.0/README.md +122 -0
- bisim_py-0.1.0/bisim/__init__.py +72 -0
- bisim_py-0.1.0/bisim/abc.py +1690 -0
- bisim_py-0.1.0/bisim/activity.py +502 -0
- bisim_py-0.1.0/bisim/app_commands/__init__.py +19 -0
- bisim_py-0.1.0/bisim/app_commands/checks.py +445 -0
- bisim_py-0.1.0/bisim/app_commands/commands.py +2427 -0
- bisim_py-0.1.0/bisim/app_commands/errors.py +375 -0
- bisim_py-0.1.0/bisim/app_commands/models.py +663 -0
- bisim_py-0.1.0/bisim/app_commands/namespace.py +283 -0
- bisim_py-0.1.0/bisim/app_commands/transformers.py +816 -0
- bisim_py-0.1.0/bisim/app_commands/translator.py +204 -0
- bisim_py-0.1.0/bisim/app_commands/tree.py +1092 -0
- bisim_py-0.1.0/bisim/appinfo.py +210 -0
- bisim_py-0.1.0/bisim/asset.py +315 -0
- bisim_py-0.1.0/bisim/audit_logs.py +213 -0
- bisim_py-0.1.0/bisim/backoff.py +73 -0
- bisim_py-0.1.0/bisim/channel.py +1543 -0
- bisim_py-0.1.0/bisim/client.py +1519 -0
- bisim_py-0.1.0/bisim/colour.py +372 -0
- bisim_py-0.1.0/bisim/components.py +501 -0
- bisim_py-0.1.0/bisim/context_managers.py +76 -0
- bisim_py-0.1.0/bisim/embeds.py +700 -0
- bisim_py-0.1.0/bisim/emoji.py +186 -0
- bisim_py-0.1.0/bisim/enums.py +974 -0
- bisim_py-0.1.0/bisim/errors.py +278 -0
- bisim_py-0.1.0/bisim/ext/__init__.py +1 -0
- bisim_py-0.1.0/bisim/ext/commands/__init__.py +20 -0
- bisim_py-0.1.0/bisim/ext/commands/_types.py +24 -0
- bisim_py-0.1.0/bisim/ext/commands/bot.py +1123 -0
- bisim_py-0.1.0/bisim/ext/commands/cog.py +585 -0
- bisim_py-0.1.0/bisim/ext/commands/context.py +441 -0
- bisim_py-0.1.0/bisim/ext/commands/converter.py +976 -0
- bisim_py-0.1.0/bisim/ext/commands/cooldowns.py +249 -0
- bisim_py-0.1.0/bisim/ext/commands/core.py +1987 -0
- bisim_py-0.1.0/bisim/ext/commands/errors.py +1070 -0
- bisim_py-0.1.0/bisim/ext/commands/help.py +1220 -0
- bisim_py-0.1.0/bisim/ext/commands/parameters.py +272 -0
- bisim_py-0.1.0/bisim/ext/commands/view.py +159 -0
- bisim_py-0.1.0/bisim/ext/tasks/__init__.py +691 -0
- bisim_py-0.1.0/bisim/file.py +139 -0
- bisim_py-0.1.0/bisim/flags.py +956 -0
- bisim_py-0.1.0/bisim/gateway.py +406 -0
- bisim_py-0.1.0/bisim/guild.py +2405 -0
- bisim_py-0.1.0/bisim/http.py +1176 -0
- bisim_py-0.1.0/bisim/http_interactions.py +223 -0
- bisim_py-0.1.0/bisim/interactions.py +1452 -0
- bisim_py-0.1.0/bisim/invite.py +383 -0
- bisim_py-0.1.0/bisim/member.py +966 -0
- bisim_py-0.1.0/bisim/mentions.py +112 -0
- bisim_py-0.1.0/bisim/message.py +1638 -0
- bisim_py-0.1.0/bisim/mixins.py +35 -0
- bisim_py-0.1.0/bisim/object.py +77 -0
- bisim_py-0.1.0/bisim/partial_emoji.py +220 -0
- bisim_py-0.1.0/bisim/permissions.py +799 -0
- bisim_py-0.1.0/bisim/poll.py +408 -0
- bisim_py-0.1.0/bisim/py.typed +0 -0
- bisim_py-0.1.0/bisim/raw_models.py +377 -0
- bisim_py-0.1.0/bisim/reaction.py +220 -0
- bisim_py-0.1.0/bisim/role.py +477 -0
- bisim_py-0.1.0/bisim/state.py +1264 -0
- bisim_py-0.1.0/bisim/sticker.py +234 -0
- bisim_py-0.1.0/bisim/ui/__init__.py +13 -0
- bisim_py-0.1.0/bisim/ui/button.py +308 -0
- bisim_py-0.1.0/bisim/ui/item.py +141 -0
- bisim_py-0.1.0/bisim/ui/modal.py +187 -0
- bisim_py-0.1.0/bisim/ui/select.py +793 -0
- bisim_py-0.1.0/bisim/ui/text_input.py +219 -0
- bisim_py-0.1.0/bisim/ui/view.py +638 -0
- bisim_py-0.1.0/bisim/user.py +473 -0
- bisim_py-0.1.0/bisim/utils.py +1216 -0
- bisim_py-0.1.0/bisim/webhook/__init__.py +7 -0
- bisim_py-0.1.0/bisim/webhook/async_.py +838 -0
- bisim_py-0.1.0/bisim/webhook/sync.py +203 -0
- bisim_py-0.1.0/examples/buttons.py +152 -0
- bisim_py-0.1.0/examples/prefix_bot.py +149 -0
- bisim_py-0.1.0/examples/slash_commands.py +132 -0
- bisim_py-0.1.0/pyproject.toml +71 -0
- bisim_py-0.1.0/tests/__init__.py +0 -0
- bisim_py-0.1.0/tests/conftest.py +118 -0
- bisim_py-0.1.0/tests/fake_bisim.py +176 -0
- bisim_py-0.1.0/tests/payloads.py +265 -0
- bisim_py-0.1.0/tests/test_app_commands.py +452 -0
- bisim_py-0.1.0/tests/test_commands.py +411 -0
- bisim_py-0.1.0/tests/test_gateway.py +255 -0
- bisim_py-0.1.0/tests/test_http.py +221 -0
- bisim_py-0.1.0/tests/test_http_interactions.py +82 -0
- bisim_py-0.1.0/tests/test_models.py +311 -0
- bisim_py-0.1.0/tests/test_tasks.py +138 -0
- bisim_py-0.1.0/tests/test_ui.py +292 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.mypy_cache/
|
|
10
|
+
.ruff_cache/
|
|
11
|
+
.coverage
|
|
12
|
+
htmlcov/
|
|
13
|
+
|
|
14
|
+
# Documentation
|
|
15
|
+
site/
|
|
16
|
+
|
|
17
|
+
# Environments
|
|
18
|
+
.venv/
|
|
19
|
+
venv/
|
|
20
|
+
.env
|
|
21
|
+
.env.*
|
|
22
|
+
|
|
23
|
+
# Editors
|
|
24
|
+
.vscode/
|
|
25
|
+
.idea/
|
|
26
|
+
*.swp
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to bisim.py are listed here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (unreleased)
|
|
6
|
+
|
|
7
|
+
The first version: the discord.py 2.x API on Bisim's REST API and gateway.
|
|
8
|
+
|
|
9
|
+
- `Client` with `run`, `start`, `login`, `connect`, `close`, events, `wait_for`,
|
|
10
|
+
`change_presence` and the caches (`guilds`, `users`, `get_*`, `fetch_*`).
|
|
11
|
+
- The gateway: passes, heartbeats and `latency`, reconnecting with backoff, and
|
|
12
|
+
loading the servers over REST before `on_ready` (Bisim has no READY event).
|
|
13
|
+
- Every Bisim event as its discord.py event: messages, edits, deletions,
|
|
14
|
+
reactions, members, roles, channels, presences, typing, voice states and more.
|
|
15
|
+
- Models with discord.py's names: `Guild`, `Member`, `User`, `Role`, `TextChannel`,
|
|
16
|
+
`VoiceChannel`, `CategoryChannel`, `DMChannel`, `Message`, `Embed`, `File`,
|
|
17
|
+
`Emoji`, `Invite`, `Webhook`, `Permissions`, `Colour` and the enums.
|
|
18
|
+
- File uploads through Bisim's presigned upload addresses.
|
|
19
|
+
- The REST client with per-route rate limits, the global limit and retries.
|
|
20
|
+
- Interactions and `app_commands`: slash commands, groups, context menus,
|
|
21
|
+
autocomplete, choices, transformers, checks, and syncing to Bisim.
|
|
22
|
+
- `ui`: views with buttons and select menus, persistent views, and modals.
|
|
23
|
+
- `bisim.ext.commands` and `bisim.ext.tasks`.
|
|
24
|
+
- `bisim.http_interactions` for bots that receive interactions on an Interactions URL.
|
|
25
|
+
- The documentation site: the guide in English and Persian and the API reference,
|
|
26
|
+
on GitHub Pages and docs.bisim.gg/py.
|
bisim_py-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present Rapptz
|
|
4
|
+
Copyright (c) 2026-present Bisim
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
7
|
+
copy of this software and associated documentation files (the "Software"),
|
|
8
|
+
to deal in the Software without restriction, including without limitation
|
|
9
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
10
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
11
|
+
Software is furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
22
|
+
DEALINGS IN THE SOFTWARE.
|
bisim_py-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bisim.py
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The official Python library for building Bisim bots, with the discord.py 2.x API.
|
|
5
|
+
Project-URL: Homepage, https://github.com/bisim-gg/bisim.py
|
|
6
|
+
Project-URL: Documentation, https://bisim-gg.github.io/bisim.py/
|
|
7
|
+
Project-URL: Documentation mirror, https://docs.bisim.gg/py/
|
|
8
|
+
Project-URL: Changelog, https://github.com/bisim-gg/bisim.py/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/bisim-gg/bisim.py/issues
|
|
10
|
+
Author: Bisim, Rapptz (discord.py)
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: api,bisim,bot,chat,discord.py
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Framework :: AsyncIO
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Topic :: Communications :: Chat
|
|
28
|
+
Classifier: Topic :: Internet
|
|
29
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
30
|
+
Classifier: Typing :: Typed
|
|
31
|
+
Requires-Python: >=3.9
|
|
32
|
+
Requires-Dist: aiohttp<4,>=3.8
|
|
33
|
+
Provides-Extra: docs
|
|
34
|
+
Requires-Dist: griffelib<3,>=2.3; extra == 'docs'
|
|
35
|
+
Requires-Dist: mkdocs-material<9.8,>=9.7; extra == 'docs'
|
|
36
|
+
Requires-Dist: mkdocs-static-i18n<2,>=1.3.1; extra == 'docs'
|
|
37
|
+
Requires-Dist: mkdocs<2,>=1.6.1; extra == 'docs'
|
|
38
|
+
Requires-Dist: mkdocstrings-python<3,>=2.0.9; extra == 'docs'
|
|
39
|
+
Requires-Dist: mkdocstrings<2,>=1.0.6; extra == 'docs'
|
|
40
|
+
Requires-Dist: pymdown-extensions<12,>=10.16; extra == 'docs'
|
|
41
|
+
Requires-Dist: ruff>=0.6; extra == 'docs'
|
|
42
|
+
Provides-Extra: http
|
|
43
|
+
Requires-Dist: pynacl>=1.5; extra == 'http'
|
|
44
|
+
Provides-Extra: speed
|
|
45
|
+
Requires-Dist: orjson>=3.5; extra == 'speed'
|
|
46
|
+
Provides-Extra: test
|
|
47
|
+
Requires-Dist: aiohttp<3.14; extra == 'test'
|
|
48
|
+
Requires-Dist: aioresponses>=0.7.6; extra == 'test'
|
|
49
|
+
Requires-Dist: pynacl>=1.5; extra == 'test'
|
|
50
|
+
Requires-Dist: pytest-asyncio<1,>=0.23; extra == 'test'
|
|
51
|
+
Requires-Dist: pytest<9,>=7.4; extra == 'test'
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
# bisim.py
|
|
55
|
+
|
|
56
|
+
[](https://pypi.org/project/bisim.py/)
|
|
57
|
+
[](https://github.com/bisim-gg/bisim.py/actions/workflows/ci.yml)
|
|
58
|
+
|
|
59
|
+
The official Python library for [Bisim](https://bisim.gg) bots.
|
|
60
|
+
|
|
61
|
+
It has the discord.py 2.x API: a bot written for discord.py runs on Bisim by
|
|
62
|
+
changing `import discord` to `import bisim` (and `from discord.ext import commands`
|
|
63
|
+
to `from bisim.ext import commands`). Events, models, slash commands, buttons,
|
|
64
|
+
select menus, modals and `ext.commands` work the way you know them.
|
|
65
|
+
|
|
66
|
+
Python 3.9 or newer, asyncio with aiohttp.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
pip install bisim.py
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Signed interactions on an Interactions URL need PyNaCl:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
pip install "bisim.py[http]"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## A bot in 20 lines
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import bisim
|
|
84
|
+
from bisim import app_commands
|
|
85
|
+
|
|
86
|
+
intents = bisim.Intents.default() # accepted for compatibility; Bisim has no intents
|
|
87
|
+
client = bisim.Client(intents=intents)
|
|
88
|
+
tree = app_commands.CommandTree(client)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@tree.command(description='Check that the bot is alive')
|
|
92
|
+
async def ping(interaction: bisim.Interaction):
|
|
93
|
+
await interaction.response.send_message(f'Pong! {round(client.latency * 1000)} ms')
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@client.event
|
|
97
|
+
async def on_ready():
|
|
98
|
+
await tree.sync()
|
|
99
|
+
print(f'Logged in as {client.user} ({client.user.id})')
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@client.event
|
|
103
|
+
async def on_message(message: bisim.Message):
|
|
104
|
+
if message.content == '!hello' and not message.author.bot:
|
|
105
|
+
await message.reply(f'Hello, {message.author.display_name}!')
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
client.run('your bot token')
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Create an application and copy its token in Bisim: Settings, Applications.
|
|
112
|
+
More examples are in [`examples/`](examples/): slash commands and context menus,
|
|
113
|
+
buttons with a select menu and a modal, and a prefix command bot with a cog and a
|
|
114
|
+
background task.
|
|
115
|
+
|
|
116
|
+
## Documentation
|
|
117
|
+
|
|
118
|
+
- **Guide:** [English](https://bisim-gg.github.io/bisim.py/guide/) and
|
|
119
|
+
[فارسی](https://bisim-gg.github.io/bisim.py/fa/guide/), from your first bot to slash
|
|
120
|
+
commands, buttons, modals, prefix commands, cogs and background tasks.
|
|
121
|
+
- **API reference:** [every class, function and event](https://bisim-gg.github.io/bisim.py/reference/),
|
|
122
|
+
generated from the docstrings.
|
|
123
|
+
- **Moving from discord.py:** [what changes and what Bisim does not have](https://bisim-gg.github.io/bisim.py/guide/moving-from-discord-py/).
|
|
124
|
+
- **Bisim developer docs:** [docs.bisim.gg](https://docs.bisim.gg), for webhooks, bots
|
|
125
|
+
and the HTTP API underneath this library.
|
|
126
|
+
|
|
127
|
+
The same site is also served at [docs.bisim.gg/py](https://docs.bisim.gg/py/).
|
|
128
|
+
|
|
129
|
+
## Moving from discord.py
|
|
130
|
+
|
|
131
|
+
- Change the imports. A word "Discord" in a name becomes "Bisim":
|
|
132
|
+
`discord.DiscordException` is `bisim.BisimException`, `discord.utils` is `bisim.utils`.
|
|
133
|
+
- Intents are accepted and change nothing: a bot sees what its permissions let it see.
|
|
134
|
+
- What Bisim does not have (voice connections, threads, stage and forum channels,
|
|
135
|
+
scheduled events, sharding) raises `bisim.NotSupported`, a `ClientException`.
|
|
136
|
+
- A local Bisim server: `bisim.Client(api_url='http://localhost:3000/api',
|
|
137
|
+
gateway_url='ws://localhost:4000/ws')`, or the `BISIM_API_URL` and
|
|
138
|
+
`BISIM_GATEWAY_URL` environment variables.
|
|
139
|
+
|
|
140
|
+
The [full page](https://bisim-gg.github.io/bisim.py/guide/moving-from-discord-py/) covers
|
|
141
|
+
startup, embeds, files, interactions and everything that raises `NotSupported`.
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
Issues and pull requests are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) first,
|
|
146
|
+
and follow the [code of conduct](CODE_OF_CONDUCT.md). Report security problems
|
|
147
|
+
privately as described in [SECURITY.md](SECURITY.md).
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
python -m venv .venv
|
|
151
|
+
.venv/bin/pip install -e ".[test]" # Windows: .venv\Scripts\pip
|
|
152
|
+
.venv/bin/pytest
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The tests never touch a real server: REST calls are answered from recorded
|
|
156
|
+
payloads and the gateway is a small fake served on localhost.
|
|
157
|
+
|
|
158
|
+
The documentation needs Python 3.10 or newer:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
.venv/bin/pip install -e ".[docs]"
|
|
162
|
+
.venv/bin/mkdocs build --strict # the guide and the API reference in site/
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Credits
|
|
166
|
+
|
|
167
|
+
bisim.py is built on [discord.py](https://github.com/Rapptz/discord.py) by Rapptz
|
|
168
|
+
and its contributors. Much of its code and documentation comes from discord.py,
|
|
169
|
+
adapted to Bisim's API, which is what lets a discord.py bot move over unchanged.
|
|
170
|
+
Thank you to everyone who made discord.py.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT, see [LICENSE](LICENSE). It carries discord.py's copyright notice next to
|
|
175
|
+
Bisim's, as discord.py's license asks.
|
bisim_py-0.1.0/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# bisim.py
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/bisim.py/)
|
|
4
|
+
[](https://github.com/bisim-gg/bisim.py/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
The official Python library for [Bisim](https://bisim.gg) bots.
|
|
7
|
+
|
|
8
|
+
It has the discord.py 2.x API: a bot written for discord.py runs on Bisim by
|
|
9
|
+
changing `import discord` to `import bisim` (and `from discord.ext import commands`
|
|
10
|
+
to `from bisim.ext import commands`). Events, models, slash commands, buttons,
|
|
11
|
+
select menus, modals and `ext.commands` work the way you know them.
|
|
12
|
+
|
|
13
|
+
Python 3.9 or newer, asyncio with aiohttp.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pip install bisim.py
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Signed interactions on an Interactions URL need PyNaCl:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pip install "bisim.py[http]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## A bot in 20 lines
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import bisim
|
|
31
|
+
from bisim import app_commands
|
|
32
|
+
|
|
33
|
+
intents = bisim.Intents.default() # accepted for compatibility; Bisim has no intents
|
|
34
|
+
client = bisim.Client(intents=intents)
|
|
35
|
+
tree = app_commands.CommandTree(client)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@tree.command(description='Check that the bot is alive')
|
|
39
|
+
async def ping(interaction: bisim.Interaction):
|
|
40
|
+
await interaction.response.send_message(f'Pong! {round(client.latency * 1000)} ms')
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@client.event
|
|
44
|
+
async def on_ready():
|
|
45
|
+
await tree.sync()
|
|
46
|
+
print(f'Logged in as {client.user} ({client.user.id})')
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@client.event
|
|
50
|
+
async def on_message(message: bisim.Message):
|
|
51
|
+
if message.content == '!hello' and not message.author.bot:
|
|
52
|
+
await message.reply(f'Hello, {message.author.display_name}!')
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
client.run('your bot token')
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Create an application and copy its token in Bisim: Settings, Applications.
|
|
59
|
+
More examples are in [`examples/`](examples/): slash commands and context menus,
|
|
60
|
+
buttons with a select menu and a modal, and a prefix command bot with a cog and a
|
|
61
|
+
background task.
|
|
62
|
+
|
|
63
|
+
## Documentation
|
|
64
|
+
|
|
65
|
+
- **Guide:** [English](https://bisim-gg.github.io/bisim.py/guide/) and
|
|
66
|
+
[فارسی](https://bisim-gg.github.io/bisim.py/fa/guide/), from your first bot to slash
|
|
67
|
+
commands, buttons, modals, prefix commands, cogs and background tasks.
|
|
68
|
+
- **API reference:** [every class, function and event](https://bisim-gg.github.io/bisim.py/reference/),
|
|
69
|
+
generated from the docstrings.
|
|
70
|
+
- **Moving from discord.py:** [what changes and what Bisim does not have](https://bisim-gg.github.io/bisim.py/guide/moving-from-discord-py/).
|
|
71
|
+
- **Bisim developer docs:** [docs.bisim.gg](https://docs.bisim.gg), for webhooks, bots
|
|
72
|
+
and the HTTP API underneath this library.
|
|
73
|
+
|
|
74
|
+
The same site is also served at [docs.bisim.gg/py](https://docs.bisim.gg/py/).
|
|
75
|
+
|
|
76
|
+
## Moving from discord.py
|
|
77
|
+
|
|
78
|
+
- Change the imports. A word "Discord" in a name becomes "Bisim":
|
|
79
|
+
`discord.DiscordException` is `bisim.BisimException`, `discord.utils` is `bisim.utils`.
|
|
80
|
+
- Intents are accepted and change nothing: a bot sees what its permissions let it see.
|
|
81
|
+
- What Bisim does not have (voice connections, threads, stage and forum channels,
|
|
82
|
+
scheduled events, sharding) raises `bisim.NotSupported`, a `ClientException`.
|
|
83
|
+
- A local Bisim server: `bisim.Client(api_url='http://localhost:3000/api',
|
|
84
|
+
gateway_url='ws://localhost:4000/ws')`, or the `BISIM_API_URL` and
|
|
85
|
+
`BISIM_GATEWAY_URL` environment variables.
|
|
86
|
+
|
|
87
|
+
The [full page](https://bisim-gg.github.io/bisim.py/guide/moving-from-discord-py/) covers
|
|
88
|
+
startup, embeds, files, interactions and everything that raises `NotSupported`.
|
|
89
|
+
|
|
90
|
+
## Contributing
|
|
91
|
+
|
|
92
|
+
Issues and pull requests are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) first,
|
|
93
|
+
and follow the [code of conduct](CODE_OF_CONDUCT.md). Report security problems
|
|
94
|
+
privately as described in [SECURITY.md](SECURITY.md).
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
python -m venv .venv
|
|
98
|
+
.venv/bin/pip install -e ".[test]" # Windows: .venv\Scripts\pip
|
|
99
|
+
.venv/bin/pytest
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The tests never touch a real server: REST calls are answered from recorded
|
|
103
|
+
payloads and the gateway is a small fake served on localhost.
|
|
104
|
+
|
|
105
|
+
The documentation needs Python 3.10 or newer:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
.venv/bin/pip install -e ".[docs]"
|
|
109
|
+
.venv/bin/mkdocs build --strict # the guide and the API reference in site/
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Credits
|
|
113
|
+
|
|
114
|
+
bisim.py is built on [discord.py](https://github.com/Rapptz/discord.py) by Rapptz
|
|
115
|
+
and its contributors. Much of its code and documentation comes from discord.py,
|
|
116
|
+
adapted to Bisim's API, which is what lets a discord.py bot move over unchanged.
|
|
117
|
+
Thank you to everyone who made discord.py.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT, see [LICENSE](LICENSE). It carries discord.py's copyright notice next to
|
|
122
|
+
Bisim's, as discord.py's license asks.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Bisim API Wrapper
|
|
3
|
+
~~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
The official library for building Bisim (bisim.gg) bots, with the discord.py
|
|
6
|
+
2.x API: a bot written for discord.py runs by changing ``import discord`` to
|
|
7
|
+
``import bisim``.
|
|
8
|
+
|
|
9
|
+
:copyright: (c) 2026 Bisim
|
|
10
|
+
:license: MIT, see LICENSE for more details.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
__title__ = 'bisim'
|
|
14
|
+
__author__ = 'Bisim'
|
|
15
|
+
__license__ = 'MIT'
|
|
16
|
+
__copyright__ = 'Copyright 2026 Bisim'
|
|
17
|
+
__version__ = '0.1.0'
|
|
18
|
+
|
|
19
|
+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
|
20
|
+
|
|
21
|
+
import logging
|
|
22
|
+
from typing import Literal, NamedTuple
|
|
23
|
+
|
|
24
|
+
from . import abc as abc
|
|
25
|
+
from . import app_commands as app_commands
|
|
26
|
+
from . import ui as ui
|
|
27
|
+
from . import utils as utils
|
|
28
|
+
from .activity import *
|
|
29
|
+
from .appinfo import *
|
|
30
|
+
from .asset import *
|
|
31
|
+
from .audit_logs import *
|
|
32
|
+
from .channel import *
|
|
33
|
+
from .client import *
|
|
34
|
+
from .colour import *
|
|
35
|
+
from .components import *
|
|
36
|
+
from .embeds import *
|
|
37
|
+
from .emoji import *
|
|
38
|
+
from .enums import *
|
|
39
|
+
from .errors import *
|
|
40
|
+
from .file import *
|
|
41
|
+
from .flags import *
|
|
42
|
+
from .guild import *
|
|
43
|
+
from .interactions import *
|
|
44
|
+
from .invite import *
|
|
45
|
+
from .member import *
|
|
46
|
+
from .mentions import *
|
|
47
|
+
from .message import *
|
|
48
|
+
from .object import *
|
|
49
|
+
from .partial_emoji import *
|
|
50
|
+
from .permissions import *
|
|
51
|
+
from .poll import *
|
|
52
|
+
from .raw_models import *
|
|
53
|
+
from .reaction import *
|
|
54
|
+
from .role import *
|
|
55
|
+
from .sticker import *
|
|
56
|
+
from .user import *
|
|
57
|
+
from .webhook import *
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class VersionInfo(NamedTuple):
|
|
61
|
+
major: int
|
|
62
|
+
minor: int
|
|
63
|
+
micro: int
|
|
64
|
+
releaselevel: Literal['alpha', 'beta', 'candidate', 'final']
|
|
65
|
+
serial: int
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
version_info: VersionInfo = VersionInfo(major=0, minor=1, micro=0, releaselevel='final', serial=0)
|
|
69
|
+
|
|
70
|
+
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
71
|
+
|
|
72
|
+
del logging, NamedTuple, Literal
|