Skip to content

Commit

Permalink
Merge pull request #5 from Amele9/master
Browse files Browse the repository at this point in the history
Fixed #4
  • Loading branch information
ripreal authored Dec 1, 2022
2 parents 661853b + 758c3a5 commit 22895d1
Show file tree
Hide file tree
Showing 47 changed files with 1,140 additions and 1,309 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ name: Upload Python Package
on:
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read
Expand Down
223 changes: 120 additions & 103 deletions README.md

Large diffs are not rendered by default.

229 changes: 124 additions & 105 deletions README_RUS.md

Large diffs are not rendered by default.

30 changes: 0 additions & 30 deletions examples/createGroupAndSendMessage.py

This file was deleted.

30 changes: 30 additions & 0 deletions examples/create_group_and_send_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from os import environ

from whatsapp_api_client_python import GreenAPI

# First you need to set the environment variables.
ID_INSTANCE = environ["ID_INSTANCE"]
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]

greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)


def main():
create_group_response = greenAPI.groups.create_group(
groupName="Group Name",
chatIds=["[email protected]"]
)

print(create_group_response.data)

chatId = create_group_response.data["chatId"]
send_message_response = greenAPI.sending.send_message(
chatId=chatId,
message="Any message"
)

print(send_message_response.data)


if __name__ == "__main__":
main()
98 changes: 0 additions & 98 deletions examples/receiveNotification.py

This file was deleted.

17 changes: 0 additions & 17 deletions examples/sendPictureByLink.py

This file was deleted.

17 changes: 0 additions & 17 deletions examples/sendPictureByUpload.py

This file was deleted.

15 changes: 0 additions & 15 deletions examples/sendTextMessage.py

This file was deleted.

22 changes: 22 additions & 0 deletions examples/send_file_by_upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from os import environ

from whatsapp_api_client_python import GreenAPI

# First you need to set the environment variables.
ID_INSTANCE = environ["ID_INSTANCE"]
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]

greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)


def main():
response = greenAPI.sending.send_file_by_upload(
chatId="[email protected]",
path="C:\\Games\\PicFromDisk.png"
)

print(response.data)


if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions examples/send_file_by_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from os import environ

from whatsapp_api_client_python import GreenAPI

# First you need to set the environment variables.
ID_INSTANCE = environ["ID_INSTANCE"]
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]

greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)


def main():
response = greenAPI.sending.send_file_by_url(
chatId="[email protected]",
urlFile="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
fileName="googlelogo_color_272x92dp.png"
)

print(response.data)


if __name__ == "__main__":
main()
21 changes: 21 additions & 0 deletions examples/send_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from os import environ

from whatsapp_api_client_python import GreenAPI

ID_INSTANCE = environ["ID_INSTANCE"]
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]

greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)


def main():
response = greenAPI.sending.send_message(
chatId="[email protected]",
message="Any message"
)

print(response.data)


if __name__ == "__main__":
main()
36 changes: 36 additions & 0 deletions examples/webhook_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from os import environ
from typing import Union

from whatsapp_api_client_python import GreenAPI
from whatsapp_api_client_python.tools import Webhook

# First you need to set the environment variables.
ID_INSTANCE = environ["ID_INSTANCE"]
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]

greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)


def main():
webhook = Webhook(greenAPI)

webhook.run_forever(handler)


def handler(type_webhook: str, body: Union[dict, list]):
if type_webhook == "incomingMessageReceived":
sender_data = body["senderData"]
message_data = body["messageData"]

type_message = message_data["typeMessage"]
if type_message == "textMessage":
text_message = message_data["textMessageData"]["textMessage"]

greenAPI.sending.send_message(
chatId=sender_data["chatId"],
message=f"You wrote: {text_message}."
)


if __name__ == "__main__":
main()
24 changes: 16 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@
read_me_description = file.read()

setuptools.setup(
name="whatsapp-api-client-python",
version="0.0.27",
install_requires=['requests'],
name="whatsapp_api_client_python",
version="0.0.28",
install_requires=["requests"],
author="Ivan Sadovy",
author_email="[email protected]",
description="This library helps you easily create a python '\
'application to connect the WhatsApp API using service green-api.com",
description=(
"This library helps you easily create a python "
"application to connect the WhatsApp API using service green-api.com"
),
long_description=read_me_description,
long_description_content_type="text/markdown",
url="https://github.com/green-api/whatsapp-api-client-python",
packages=['whatsapp_api_client_python', 'whatsapp_api_client_python.tools'],
packages=[
"whatsapp_api_client_python",
"whatsapp_api_client_python.api",
"whatsapp_api_client_python.base",
"whatsapp_api_client_python.methods",
"whatsapp_api_client_python.tools"
],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.5',
)
python_requires='>=3.7',
)
25 changes: 25 additions & 0 deletions tests/test_library.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
from os import environ

from whatsapp_api_client_python import GreenAPI

ID_INSTANCE = environ["ID_INSTANCE"]
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]

greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)


class GreenAPITestCase(unittest.TestCase):
def test_getSettings(self):
response = greenAPI.account.get_settings()

self.assertEqual(response.status_code, 200, response.error)

def test_getStateInstance(self):
response = greenAPI.account.get_state_instance()

self.assertEqual(response.status_code, 200, response.error)


if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 22895d1

Please sign in to comment.