Add --echo option to cli

This commit is contained in:
taizan-hokouto
2020-10-29 01:40:43 +09:00
parent 15a1d5c210
commit 8f5c3f312a
3 changed files with 38 additions and 2 deletions

17
pytchat/cli/echo.py Normal file
View File

@@ -0,0 +1,17 @@
import pytchat
from ..util.extract_video_id import extract_video_id
class Echo:
def __init__(self, video_id):
self.video_id = extract_video_id(video_id)
def run(self):
livechat = pytchat.create(self.video_id)
while livechat.is_alive():
chatdata = livechat.get()
for c in chatdata.sync_items():
print(f"{c.datetime} [{c.author.name}] {c.message} {c.amountString}")