Created
April 27, 2016 09:39
-
-
Save mrtopf/936e0ddae9c4cf21b44cea60b9ad77e8 to your computer and use it in GitHub Desktop.
handle_messages mit Versand eines Bildes
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
def handle_messages(data): | |
"""handle all incoming messages""" | |
messaging_events = data['entry'][0]['messaging'] | |
for event in messaging_events: | |
sender_id = event['sender']['id'] | |
# check if we actually have some input | |
if "message" in event and event['message'].get("text","") != "": | |
text = event['message']['text'] | |
# send a simple text reply | |
reply = "Toll, Du hast folgendes gesagt: "+text | |
send_text(sender_id, reply) | |
# send an image additionally | |
send_text(sender_id, "Ein Bot von") | |
send_image(sender_id, "https://comlounge.net/wp-content/uploads/2016/02/cropped-Logo_COMlounge.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment