This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
LiveChatAsync
taizan-hokuto edited this page Dec 26, 2019
·
21 revisions
LiveChatAsync object
- fetches chat data and stores them in buffer with aiohttp on asyncio context.
- responds to user inquiries of get().
- invokes callback function with processed chat data.
from pytchat import LiveChatAsync
import asyncio
async def main():
chat = LiveChatAsync("G1w62uEMZ74", callback = func)
while chat.is_alive():
await asyncio.sleep(3)
#other background operation.
#callback function is automatically called periodically.
async def func(data):
for c in data.items:
print(f"{c.datetime} [{c.author.name}]-{c.message} {c.amountString}")
await data.tick_async()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
name | type | required | remarks | default value |
---|---|---|---|---|
video_id | str | * | ID of youtube video. | - |
processor | ChatPrcessor | DefaultProcessor | ||
buffer | Buffer | buffer of chat data fetched background. | Buffer(maxsize=20) | |
interruptable | bool | True | ||
callback | func | function called from _listen() periodically. | None | |
done_callback | func | function called when listener ends. | None | |
exception_handler | func | function called when exceptions occur. | None | |
direct_mode | bool | If True, invoke specified callback function without using buffer. | False |
description | return value |
---|---|
Get processed chat data from buffer. | processed chat data |
description | return value |
---|---|
Check if livechat stream is alive. | bool |
description | return value |
---|---|
Terminate fetching livechat. | - |