Skip to main content

A simple python binding for the great project Mirai

Project description


Thanks for the great work of Mirai.

This python binding relies on Mirai Console v0.3.1 with mirai-api-http-1.0.0 installed.


pip install pymirai --upgrade pymirai

Write a bot from scratch

from pymirai import *

async def friend_msg_handler(event : FriendMessageEvent):
    # 纯文字
    await event.reply_text('hello, world!', quote=True)
    # 组合消息 + 图片
    image_id = await'sample.gif', 'friend')
    message_chain = [
    await event.reply_message(message_chain)
    # 复读
    mc = event.message_chain
    await event.reply_message(mc)

async def main():
    async with Bot(QQNUM, 'auth_key', 'server', 'port') as bot:
        bot : Bot
        await bot.loopEvent()

if __name__ == '__main__':
    except KeyboardInterrupt:


This package is merely a non-complete python wrapper for mirai-api-http, use it at your own risk and for learning purposes only.

For a better experience, see kuriyama.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pymirai, version
Filename, size File type Python version Upload date Hashes
Filename, size pymirai- (17.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pymirai- (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page