This library helps you easily create a python application with WhatsApp API
OTHER License
Bot releases are visible (Hide)
Published by Amele9 11 months ago
Example:
greenAPI.account.getAuthorizationCode(11001234567)
Published by Amele9 11 months ago
Example:
greenAPI.sending.getWaSettings()
Example:
greenAPI.sending.sendPoll(
"[email protected]",
"Please choose a color:",
[
{"optionName": "Red"},
{"optionName": "Green"},
{"optionName": "Blue"}
]
)
Published by Amele9 about 1 year ago
Added debug mode
In debug mode you can see data received from the Green API. To enable debug mode, add debug_mode
option with True
value
greenAPI = API.GreenAPI(
"", "", debug_mode=True
)
Added raise_errors
option
If the option is enabled, it will be raised when an error is received
greenAPI = API.GreenAPI(
"", "", raise_errors=True
)
Published by Amele9 about 1 year ago
Published by Amele9 over 1 year ago
Published by Amele9 over 1 year ago
Published by Amele9 over 1 year ago
Published by Amele9 over 1 year ago
Published by Amele9 over 1 year ago
Published by Amele9 over 1 year ago
GetMessage
Account
Sending
setup.py
linkPreview
parameter to SendMessage methodPublished by olegius88 over 1 year ago
Published by olegius88 over 1 year ago
Published by olegius88 over 1 year ago
Published by ripreal over 1 year ago
Published by olegius88 almost 2 years ago
Add ForwardMessages method
Published by ripreal almost 2 years ago
Добавил класс GreenAPIError. Он вызывается, когда происходит ошибка (status_code != 200). Его можно обработать таким образом:
try:
greenAPI.request("GetSettings")
except GreenAPIError as error:
print(error.error_message)
Добавил GET HTTP метод, как метод по умолчанию.
Мелкие исправления и улучшения
Обновил Webhook класс. Теперь он называется Bot. И хранится этот класс в директории bot. Его можно импортировать вместе с GreenAPI классом:
from whatsapp_api_client_python import GreenAPI, Bot
Теперь можно использовать функции-декораторы. При получении нового уведомления данные отправятся в ту функцию, которая декорируется.
При использовании декоратора handler, нужно указать type_webhook. Пример:
@bot.handler("stateInstanceChanged")
def handler(body: dict):
print(body["instanceData"])
print("stateInstanceChanged")
При использовании декоратора message, можно указать текст сообщения в чате WhatsApp, на который нужно ответить (если не указывать, функция будет получать все входящие сообщения). Если функция возвращает строку, то она автоматически будет отправлена в тот же чат. Пример:
@bot.message("Привет")
def message(body: dict) -> str:
print(body["senderData"])
print("incomingMessageReceived")
return f"""Привет, {body["senderData"]["senderName"]}"""
Если в чате написать сообщение Привет, то бот отправит это сообщение: Привет, <имя пользователя WhatsApp>.
Обновил setup.py. Теперь все пакеты библиотеки добавляются автоматически, исключая пакет тестов.
Published by ripreal almost 2 years ago
Refactoring that removes breaking changes prior 0.0.27
Published by ripreal almost 2 years ago
Back to stable 0.0.23
Published by ripreal almost 2 years ago
The release contains breaking changes
Улучшил импорты. Класс GreenApi переименовал в GreenAPI. Все API категории теперь property функции с подсказками типов (type hints). Улучшил функцию request (также добавил подсказки типов (typing)).
Обновлено:
Улучшил Response класс. Обновил инициализацию пакета (Теперь можно сразу импортировать GreenAPI класс). Также обновил тесты (unittest).