Skip to content

Instantly share code, notes, and snippets.

@mrtopf
Created April 27, 2016 09:39
Show Gist options
  • Save mrtopf/936e0ddae9c4cf21b44cea60b9ad77e8 to your computer and use it in GitHub Desktop.
Save mrtopf/936e0ddae9c4cf21b44cea60b9ad77e8 to your computer and use it in GitHub Desktop.
handle_messages mit Versand eines Bildes
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