Skip to main content

An unofficial Python SDK Library for CHZZK

Project description

chzzk-sdk

네이버 라이브 스트리밍 서비스 치치직(CHZZK)의 비공식 API 라이브러리.
공부 목적으로 만들었으며, 참조한 레포는 하단의 References에 명시했습니다.

  • 로그인 (쿠키 사용)
  • 검색 (채널, 영상, 생방송)
  • 채널 정보 조회
  • 방송 상태 및 상세 정보 조회
  • 채팅 보내기
  • 이벤트 구독
    • 연결 상태 (on_connect, on_disconnect)
    • 채팅 (on_chat)
    • 방송 상태 (on_broadcast_open, on_broadcast_close)
    • 후원 (on_donation)
    • 구독 (on_subscription)
    • 상단 고정 (on_pin, on_unpin)
    • 시스템 메시지 (on_system_message)
    • 메시지 관리
    • 그 외 (on_recent_chat, on_notice, on_blind, on_mission_pending, on_mission_approved, on_mission_rejected, on_mission_completed)
  • 채팅 커맨드 생성 @client.commands(name="커맨드이름")
  • 관리 (채팅 제한, 상단 고정 설정)

Requirements

  • Python 3.11+

Installation

pip install chzzk-sdk

Example

import asyncio

from chzzk import ChzzkChat, Chzzk
from chzzk.model import ChatMessage

from dotenv import dotenv_values


env = dotenv_values(".env")
chzzk = Chzzk().from_data(auth=env.get("AUTH"), session=env.get("SESSION"))
chat = ChzzkChat(chzzk=chzzk, prefix="!") # commands를 위한 prefix 지정


@chat.event
async def on_connect():
    print(f"on_connect")
    await chat.send_chat("on_connect test")


@chat.event
async def on_chat(message: ChatMessage):
    print(f"on_chat: {message.content}")

    
@chat.commands(name="공지")
async def notice(message: ChatMessage, *args):
    await chat.pin_message(message=message)


# name가 없으면, 함수이름이 커맨드 명령어 이름이 됨.
@chat.commands()
async def 공지해제(*args):
    await chat.unpin_message()


@chat.commands(name="덧셈")
async def plus(message: ChatMessage, *args):
    nums = list(map(lambda x: int(x), args))
    await chat.send_chat(f"덧셈 결과: {sum(nums)}")


async def main():
    channels = await chzzk.search.channels("갈대s")
    channel_id = channels[0].channel.channel_id
    await chat.run(channel_id=channel_id)

if __name__ == "__main__":
    asyncio.run(main())

+ 간단한 tts-bot 코드 : https://github.com/westreed/ChzzkBot

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chzzk_sdk-0.1.3.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chzzk_sdk-0.1.3-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file chzzk_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: chzzk_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for chzzk_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4b24fb5887c33968ad4fb0553ac3b5abf18f832b42f4728f4d9424e29df4d4b9
MD5 d846224982b7410f8a93017af258a434
BLAKE2b-256 3f0b427b4c790cb10d9e0b70a716ab4c152a417650d9adb3bc1a67ccdf948636

See more details on using hashes here.

Provenance

The following attestation bundles were made for chzzk_sdk-0.1.3.tar.gz:

Publisher: deploy.yml on saebyeok0306/chzzk-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chzzk_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: chzzk_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for chzzk_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d34a9c449f37f649b1e996a4267d7fba4526fdc032491919beea5b9e21117efb
MD5 a531764cbb0c99af91cdf63122e6117a
BLAKE2b-256 0d6b841a841e2010a1a05ba20a90811d22aee1df52cf8d2e92d072fcfd2b6bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for chzzk_sdk-0.1.3-py3-none-any.whl:

Publisher: deploy.yml on saebyeok0306/chzzk-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page