A Python wrapper for the Misskey API
Project description
Mi.py
使い方
クラスを継承したBOT作り
from misskey.ext import task
from misskey.reaction import Reaction
from misskey.message import Message
from misskey.router import Router
from misskey.bot import Bot
class SakuraAoi(Bot):
@task.loop(60)
async def task(self, ws):
print(ws)
print('ループしてますよ~')
async def on_ready(self, ws):
print('work on my machine')
await Router(ws).channels(['global', 'main'])
self.task.start()
async def on_message(self, ws, ctx: Message):
print(f'{ctx.note.author.instance.name} | {ctx.note.author.username}さんがノートしました: {ctx.note.text}')
async def on_reacted(self, ws, ctx: Reaction):
print(ctx.note.reaction)
async def on_deleted(self, ws, ctx: Message):
print(ctx)
async def on_error(self, err):
print(err)
if __name__ == '__main__':
url = 'wss://exmaple.com/streaming'
SakuraAoi().run(url, 'token')
インスタンス化してイベントを登録するスタイル
from misskey.message import Message
from misskey.router import Router
from misskey.bot import Bot
bot = Bot()
@bot.listen()
async def on_message(ws, ctx: Message):
print(f'{ctx.note.author.instance.name} | {ctx.note.author.username}さんがノートしました: {ctx.note.text}')
@bot.listen()
async def on_reaction(ws, ctx):
print(f'{ctx.note.author.instance.name} | {ctx.author.name}さんがリアクションを付けました: {ctx.note.text}')
@bot.event()
async def on_ready(ws):
print('work on my machine')
await Router(ws).channels(['global', 'main'])
bot.run('wss:/example.com', 'token')
Collaborators
Author | @yupix |
SpecialThanks
開発を手伝ってくれている方々です。
Adviser | @Uraking |
LICENSE
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
mi.py-0.0.2.tar.gz
(8.3 kB
view hashes)
Built Distribution
mi.py-0.0.2-py3-none-any.whl
(10.8 kB
view hashes)