安装
pip install calamity
pdm add calamity
特性
- 兼容 Graia Broadcast
- 兼容 Lacia
使用
入门
Server 端
from calamity import Calamity
Calamity.server()
Client 端
- 客户端 A
import asyncio
from calamity import Calamity
from graia.broadcast import Broadcast, Dispatchable, BaseDispatcher, DispatcherInterface
loop = asyncio.get_event_loop()
bcc = Broadcast(loop=loop)
bcc = Calamity.patch()
class ExampleEvent(Dispatchable):
class Dispatcher(BaseDispatcher):
@staticmethod
async def catch(interface: DispatcherInterface):
if interface.annotation is str:
return "Calamity"
@bcc.receiver(ExampleEvent, remote=True)
async def event_receiver(event: str):
print("Hello Broadcast!", event)
@bcc.receiver(ExampleEvent)
async def event_receiver1(event: str):
print("Hello Lacia!", event)
async def main():
bcc.postEvent(ExampleEvent())
loop.run_until_complete(main())
loop.run_forever()
- 客户端 B
import asyncio
from calamity import Calamity
from graia.broadcast import Broadcast, Dispatchable, BaseDispatcher, DispatcherInterface
loop = asyncio.get_event_loop()
bcc = Broadcast(loop=loop)
bcc = Calamity.patch(debug=True)
class ExampleEvent(Dispatchable):
class Dispatcher(BaseDispatcher):
@staticmethod
async def catch(interface: DispatcherInterface):
if interface.annotation is str:
return "Calamity"
@bcc.receiver(ExampleEvent)
async def event_receiver(event: str):
print("Hello Broadcast!", event)
@bcc.receiver(ExampleEvent)
async def event_receiver1(event: str):
print("Hello Lacia!", event)
async def main():
bcc.postEvent(ExampleEvent(), remote=True)
loop.run_until_complete(main())
loop.run_forever()
提示
bcc = Broadcast(loop=loop) # 声明 bcc
bcc = Calamity.patch(debug=True) # remote bcc
Metadata
Release files for calamity 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| calamity-0.1.0.tar.gz | 4.7 kB | Without provenance | Details for calamity-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| calamity-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for calamity-0.1.0-py3-none-any.whl |
Total release size: 9.8 kB
Release files / calamity-0.1.0.tar.gz
| Download URL | calamity-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ceab0eae5de4c446b55e1d81d6fcb8de50da6273b4bf66e81ada704fdf379754
|
|
BLAKE2b-256 checksum How to use checksums |
89d307c233647dd8797d83432405305ddb9372e514df3e6047c9cd38ca3b1cc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
|
Release files / calamity-0.1.0-py3-none-any.whl
| Download URL | calamity-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d19b6a5eb8ec5d1e11a2603d6c7e7cec759cfd95e35bd588244f0b78e7b088e
|
|
BLAKE2b-256 checksum How to use checksums |
a76154fa866f5eba8a564247b5ee44bce866b1ddf3e6b76044776e831e3688c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
|
Security for calamity 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.