-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51d1a1a
commit bf7d3b9
Showing
7 changed files
with
79 additions
and
14 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
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
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,18 @@ | ||
from whatsapp_chatbot_python import GreenAPIBot, Notification | ||
|
||
bot = GreenAPIBot( | ||
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345" | ||
) | ||
|
||
@bot.router.message() | ||
def message_handler(notification: Notification) -> None: | ||
if "@g.us" in notification.get_chat(): | ||
print("Incoming message", notification.get_id_message(), "in group chat", notification.get_chat(), "from", notification.get_sender()) | ||
notification.answer("Hello, group!") | ||
# Add your implementation | ||
if "@c.us" in notification.get_chat(): | ||
print("Incoming message", notification.get_id_message(), "in contact chat", notification.get_chat()) | ||
notification.answer("Hello, contact!") | ||
# Add your implementation | ||
|
||
bot.run_forever() |
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 whatsapp_chatbot_python import GreenAPIBot, Notification | ||
|
||
bot = GreenAPIBot( | ||
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345" | ||
) | ||
|
||
# Handle message, which sent from this instance without API | ||
@bot.router.outgoing_message() | ||
def message_handler(notification: Notification) -> None: | ||
print("Outgoing Message: ", notification.get_id_message()) | ||
print("Sender:", notification.get_sender()) | ||
print("Chat:", notification.get_chat()) | ||
print("Message Text:", notification.get_message_text()) | ||
print("Message:", notification.get_message_data()) | ||
|
||
# Handle message, which sent from this instance with API | ||
@bot.router.outgoing_api_message() | ||
def message_handler(notification: Notification) -> None: | ||
print("Outgoing Message from API: ", notification.get_id_message()) | ||
print("Sender:", notification.get_sender()) | ||
print("Chat:", notification.get_chat()) | ||
print("Message Text:", notification.get_message_text()) | ||
print("Message:", notification.get_message_data()) | ||
|
||
# Handle status of any sent message from this instance (sent, delivired, read) | ||
@bot.router.outgoing_message_status() | ||
def message_handler(notification: Notification) -> None: | ||
print("Status of message:", notification.get_id_message(), "is", notification.get_status_message()) | ||
|
||
bot.run_forever() |
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
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
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