GithubHelp home page GithubHelp logo

pachca-client's Introduction

RU EN

Pachca Client

Python клиент для мессенджера Пачка (pachca.com).

Поддерживаемый функционал

  • чаты
  • участники чата
  • загрузка файлов
  • сообщения
  • реакции
  • статус
  • задачи
  • теги
  • треды
  • пользователи

Установка

python -m pip install pachca-client

Pachca Client требует Python 3.6 или выше.

Примеры

Создание клиента

from pachca_client import get_pachca

# клиент по умолчанию
pachca =  get_pachca('MY_ACCESS_TOKEN')

Альтернативно клиент можно создать следующим способом:

from pachca_client import Client, Cache, Pachca

pachca = Pachca(Client('MY_ACCESS_TOKEN'), Cache())

Сообщения

Отправка сообщения

# по ID чата
message = pachca.new_message(chat_id=111111, content="My message")

# по имени чата
message = pachca.new_message(chat_id='MyChatName', content="My message")

# по ID пользователя
message = pachca.new_message(chat_id=222222, chat_type='user', content="My message")

# по имени пользователя
message = pachca.new_message(chat_id='User Name', chat_type='user', content="My message")

# по ID треда
message = pachca.new_message(chat_id=333333, chat_type='thread', content="My message")

Отправка сообщений в тред

message = pachca.new_message(chat_id=111111, content="My message")
thread = pachca.new_thread(message['id'])
thread_message = pachca.new_message(chat_id=thread['id'], content="My message in the thread", chat_type='thread')

Отправка сообщения с вложением

from pachca_client import File
f = File('/home/shal/dev/pachca-client/requirements.txt')
files = [
    File('file_a.txt'),
    File('image_a.png', file_type='image')
]
message = pachca.new_message(chat_id=123456, content="Test message!", files=files)

HTTP/HTTPS Proxy

Если требуется использование http прокси, то можно указать параметр proxies или соответсвующие переменные окружения (см. https://docs.python-requests.org/en/latest/user/advanced/).

from pachca_client import get_pachca

proxies = {
  'http': 'http://10.10.1.10:3128',
  'https': 'http://10.10.1.10:1080',
}
pachca =  get_pachca('MY_ACCESS_TOKEN', proxies=proxies)

pachca-client's People

Contributors

k1nky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.