Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

DefaultProcessor

taizan-hokuto edited this page Nov 15, 2020 · 26 revisions

DefaultProcessor is a default chat processor of pytchat.

Usage

import pytchat
# `DefaultProcessor` parameter is optional.
chat = pytchat.create(video_id="uIx8l2xlYVY", processor=DefaultProcessor())
while chat.is_alive():
    for c in chat.get().sync_items():
        print(f"{c.datetime} [{c.author.name}]- {c.message}")

items

description return value
Get list of chat items. List of chat items

sync_items()

description return value
Get chat items with automatically calculated interval. Generator iterator that yields chat items.

async_items()

description return value
Get chat items with automatically calculated interval in asyncio context. Async generator iterator that yields chat items.

*When you use async_items(), use async for sentence.

async for c in chat.get().async_items():
   print(c.json())

tick() [DEPRECATE]

description return value
wait for next chat. -

[await] tick_async() [DEPRECATE]

description return value
wait for next chat on asyncio context. -

json()

return JSON format chat data.

chat = pytchat.create(video_id="xxxxxxxx")
while chat.is_alive():
    print(chat.get().json())
    time.sleep(5)
    '''
    # Each chat item can also be output in JSON format.
    for c in chat.get().sync_items():
        print(c.json())
    '''     

Attributes of Chat Item

name type remarks
type str "superChat","textMessage","superSticker","newSponsor"
id str
message str Emojis are represented by ":(shortcut text):"
messageEx str List of messages and emojis: emojis are represented by URL for image.
timestamp int unixtime milliseconds
datetime str e.g. "2019-10-10 12:34:56"
elapsedTime str elapsed time. (e.g. "1:02:27") *Replay Only.
amountValue float e.g. 1,234.0
amountString str e.g. "$ 1,234"
currency str ISO 4217 currency codes (e.g. "USD")
bgColor int (ARGB)
author object see author
colors object see colors

author

Attributes of author object.

name type remarks
name str
channelId str chatter's channel ID.
channelUrl str
imageUrl str chatter's icon
badgeUrl str member badge
isVerified bool
isChatOwner bool
isChatSponsor bool when the chat is superchat/supersticker, always False
isChatModerator bool

colors

Attributes of colors object.

name type remarks
headerBackgroundColor int (ARGB) available only type:`superChat`
headerTextColor int (ARGB) available only type:`superChat`.
bodyBackgroundColor int (ARGB) available only type:`superChat`. Same as `bgColor`.
bodyTextColor int (ARGB) available only type:`superChat`
timestampColor int (ARGB) available only type:`superChat`
authorNameTextColor int (ARGB) available only type:`superChat` and `superSticker`
backgroundColor int (ARGB) available only type:`superSticker` Same as `bgColor`.
moneyChipBackgroundColor int (ARGB) available only type:`superSticker`
moneyChipTextColor int (ARGB) available only type:`superSticker`