Skip to main content

Discord.py style async library for Karrot chat

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

karrot.py

Discord.py 스타일의 당근마켓 채팅 비동기 라이브러리

설치

pip install aiohttp websockets

사용법

import asyncio
from karrot import Client, Message

client = Client(command_prefix="!")

@client.event
async def on_ready():
    print(f"로그인: {client.user_id}")

@client.event
async def on_message(message: Message):
    print(f"[{message.sender_nickname}] {message.text}")

    # 자신의 메시지에만 명령어 처리
    if message.sender_id == client.user_id:
        await client.process_commands(message)

@client.command("안녕", aliases=["hi", "hello"])
async def hello_command(message: Message, args: str):
    await message.reply("안녕하세요!")

@client.command("도움말", aliases=["help", "?"])
async def help_command(message: Message, args: str):
    help_text = """
📋 명령어 목록
!안녕 - 인사
!도움말 - 도움말
    """
    await message.reply(help_text)

client.run("YOUR_TOKEN_HERE")

주요 기능

Client

client = Client(
    command_prefix="!",  # 명령어 접두사
    region="kr",         # 지역 (kr, jp, ca, uk, us)
    auto_reconnect=True  # 자동 재연결
)

이벤트

  • on_ready() - 연결 완료
  • on_message(message) - 새 메시지
  • on_notification(notification) - 알림
  • on_disconnect() - 연결 해제

명령어

@client.command("명령어", aliases=["별칭1", "별칭2"], description="설명")
async def my_command(message: Message, args: str):
    # args: 명령어 뒤의 인자 (예: "!명령어 인자" -> args = "인자")
    await message.reply("응답")

메시지

# 답장
await message.reply("텍스트")

# 채널로 전송
await client.send_message(channel_id, "텍스트")

채널

# 모든 채널
channels = client.channels

# ID로 채널 찾기
channel = client.get_channel_by_id(channel_id)

# 채널 정보
channel.display_name  # 표시 이름
channel.type          # ChannelType.DIRECT 또는 ChannelType.GROUP

토큰 얻기

  1. 당근마켓 웹 (https://karrotmarket.com) 로그인
  2. 개발자 도구 (F12) → Network 탭
  3. chat.daangn 요청 찾기
  4. Request Headers에서 Authorization: Bearer ... 값 복사

라이선스

MIT

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

karrot-0.1.0.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

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

karrot-0.1.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file karrot-0.1.0.tar.gz.

File metadata

  • Download URL: karrot-0.1.0.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for karrot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34f01f50334e2a78c2186bb611642354301c1909be5a93c3ebd6fccf7ea8b616
MD5 acb5f2867175efd702ada06a92c7b773
BLAKE2b-256 24c7892e1454d9b6251cc117a7df6dbacfebefb71bd085066fa6896e9da666e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for karrot-0.1.0.tar.gz:

Publisher: workflow.yml on deongdion/karrot.py

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

File details

Details for the file karrot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: karrot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for karrot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de9a4123706128cafeddc9846bfb8859845c4299e70985c14c8d04950c94bd29
MD5 b625512d090f2d771caea0943d3da414
BLAKE2b-256 824d4f0b183b2be6caac3ddfb2c1d14e1a7da1449c0c29330f859f2f812d0a29

See more details on using hashes here.

Provenance

The following attestation bundles were made for karrot-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on deongdion/karrot.py

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