Skip to main content

A simple python binding for the great project Mirai

Project description

Py-mirai

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.

Insall

pip install pymirai --upgrade pymirai

Write a bot from scratch

from pymirai import *

@FriendMessageHandler(restricted_sender=[])
async def friend_msg_handler(event : FriendMessageEvent):
    # 纯文字
    await event.reply_text('hello, world!', quote=True)
    # 组合消息 + 图片
    image_id = await event.bot.uploadImage('sample.gif', 'friend')
    message_chain = [
        miraiPlain('photo\n'),
        miraiImage(image_id),
        miraiPlain('\nend')
    ]
    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
        bot.addEventHandler(friend_msg_handler)
        await bot.loopEvent()

if __name__ == '__main__':
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        exit()

Info

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.

Source Distribution

pymirai-0.0.4.6.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymirai-0.0.4.6-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file pymirai-0.0.4.6.tar.gz.

File metadata

  • Download URL: pymirai-0.0.4.6.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pymirai-0.0.4.6.tar.gz
Algorithm Hash digest
SHA256 367f054692a3eaebd9d6a5db3cde35a5877928e0a2bcec8eafd7ea1086a21b0d
MD5 a8537652e7dfc5e8fe0f598a2c2c6c18
BLAKE2b-256 6cceb7762a0dd4e27a85b8d92933a315257070534dc51f06640bd67fc05911fc

See more details on using hashes here.

File details

Details for the file pymirai-0.0.4.6-py3-none-any.whl.

File metadata

  • Download URL: pymirai-0.0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pymirai-0.0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 08f796cb97c1581398dfe209916e9ae53e3b90d38bc3b0a9e0d6b0823e5f7b73
MD5 f55d800b6f96e1b0df7f9c7fbe914aaa
BLAKE2b-256 861d87723696e1226aded6829a5aa5af96166dedcf2c01082b544cb31175a996

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page