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
Release history Release notifications | RSS feed
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.5.tar.gz
(4.7 kB
view hashes)
Built Distribution
pymirai-0.0.4.5-py3-none-any.whl
(17.5 kB
view hashes)
Close
Hashes for pymirai-0.0.4.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de51dfd4f19da21ef16752f5004bf8951a4b9d94a7ad2b7bb8cc05772fcb8d5b |
|
MD5 | 8b13d0f856fa02f4dd9882e1324e326b |
|
BLAKE2b-256 | 9a157cd1b66d755c5f7d63a25c4840d531260569e3a11ec5a9bb2f449fd5523d |