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 48
Multiple chat processors
taizan-hokuto edited this page Jan 11, 2020
·
6 revisions
You can use multiple chat processors simultaneously,
by specifying chat processors as tuple.
chat = LiveChat("video_id", processor = (DefaultProcessor(), SpeedCalculator()) )
The return values are also tuple.
data, speed = 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()