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
Multiple chat processors
taizan-hokuto edited this page Dec 31, 2019
·
6 revisions
You can use multiple chat processors simultaneously,
by specifying chat processors as tuple.
複数のChat Processorを使用する場合は、タプルで指定します。
chat = LiveChat("video_id", processor = (DefaultProcessor(), SpeedCalculator()) )
The return values are also tuple.
各々のprocessorの戻り値(加工後データ)もタブルで返ってきます。
data, speed = chat.get()
## on the asyncio context
data, speed = await chat.get()
In the above example, data
is return of DefaultProcessor, and speed
is return of SpeedCalculator.
The order of returns depends on the order of specified processors.
from pytchat import LiveChat, DefaultProcessor, SpeedCalculator
def multiple_processor():
chat = LiveChat("video_id",
processor = ( DefaultProcessor(), SpeedCalculator() ))
while chat.is_alive():
data, speed = chat.get()
for c in data.items:
print(f"{c.elapsedTime.rjust(8)} <{c.datetime}> [{c.author.name}]-{c.message}")
data.tick()
print(f"[speed:{speed} it/m]")
if __name__ =='__main__':
multiple_processor()