# Mirai Framework Core for Python

Derived from [Python-Mirai](https://github.com/Chenwe-i-lin/python-mirai). If you decided to **Star** this project, please
 also **Star** the original project.

A Flask like Python wrapper of [Mirai-HTTP-API](https://github.com/mamoe/mirai-api-http)

See full documentation [here](https://mirai-py.originpages.com/python-mirai-core/docs/mirai_core/index.html)

Synced with mirai core 0.37.4

## Installation

### Install from PyPI

``` bash
pip install python-mirai-core
```

### Install from github

``` bash
pip install git+git:://github.com/NatriumLab/python-mirai-core
```

### TL; DR

See code completion generated by PyCharm or VSCode.

Fundamentals:

`Bot` and `Updater` are two object to interact with mirai-http-api.

`Bot` contains all outbound actions (such as `send_group_message`),
 all methods are well documented, and internal methods starts with `_`

`Updater` handles all inbound updates (such as receiving events or messages)

A list of available event is under `mirai_core.models.events.EventTypes`, and each event entity is
 under `mirai_core.models.events`, and shares the same name as `EventTypes`.
 
A list of available message components (to construct MessageChain) is under `mirai_core.models.message.components`.

### Features

- Updater handshake with mirai-console automatically when console is restarted or session is expired

- Similar logic to python-telegram-bot or aiogram

- Supports multiple listener for single event, use `return True` to block further calling for this event only

- Supports Websocket (enabled by default)

- Supports xml/json/app message

### Example

Basic example: see demo folder.

Comprehensive example: see [UMR](https://github.com/jqqqqqqqqqq/UnifiedMessageRelay/blob/dev-4.0/src/Driver/Mirai/__init__.py)

### Thanks 

Thanks [`mamoe`](https://github.com/mamoe) brings us [`mirai`](https://github.com/mamoe/mirai), a tremendous work that 
enables boundless possibilities for QQ Bots. 

### License

[`GNU AGPLv3`](https://choosealicense.com/licenses/agpl-3.0/) 
 
Same as [`mirai`](https://github.com/mamoe/mirai) 
