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 karrot

사용법

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.1.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.1-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: karrot-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2bf19b6ca8eef48d85fee261c1b98decbd3ea3d6e4739701a7d4f9a77d055dcf
MD5 a731a15315807c090e4604cd7e2a7bfa
BLAKE2b-256 74ffa17ba36bb7bbd5c46898415dc5157fd5c01e07ceb831990471c569b17024

See more details on using hashes here.

Provenance

The following attestation bundles were made for karrot-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: karrot-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 644acb86fa197a3224fa1faf776863945b882bf25abcf1a6ba2886b5da492f63
MD5 756b1934d1b4076f159258a967a02189
BLAKE2b-256 58e34d802ddbb066e79d4c0ef400c0c63c632c44673954abe10ba0e0a21678bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for karrot-0.1.1-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