diff --git a/idescriptor/bot.py b/idescriptor/bot.py index 7357d53..b701444 100644 --- a/idescriptor/bot.py +++ b/idescriptor/bot.py @@ -1,3 +1,5 @@ +import logging + import requests from imagebot import settings @@ -86,8 +88,12 @@ def post(): image_path = f"{settings.MEDIA_ROOT}/{image.image}" alt_text = image.alt_text - response = client.post_status_with_image(status_text, image_path, alt_text) - print(response) + try: + response = client.post_status_with_image(status_text, image_path, alt_text) + logging.info(response) + image.set_image_posted() + except requests.exceptions.ConnectionError as e: + logging.error(f"Could not post image: {e}") if __name__ == "__main__":