-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Amele9/master
Fixed #4
- Loading branch information
Showing
47 changed files
with
1,140 additions
and
1,309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.