Commit 41e5bc57 authored by Pietro Albini's avatar Pietro Albini

Correctly handle deleted posts

parent 3518b7df
...@@ -79,10 +79,16 @@ class PostComponent(botogram.Component): ...@@ -79,10 +79,16 @@ class PostComponent(botogram.Component):
)] )]
for post_id in to_telegram: for post_id in to_telegram:
data = self.buffer.request("get", "updates/%s.json" % post_id) data = self.buffer.request("get", "updates/%s.json" % post_id)
if data["status"] != "sent":
continue
bot.chat(channel).send(data["text_formatted"]) # For example if the update was deleted
if "error" not in data:
if data["status"] != "sent":
continue
bot.chat(channel).send(data["text_formatted"])
# This will delete the update if the message was sent to the
# channel or there was an error with it
self.db.update( self.db.update(
"DELETE FROM to_telegram WHERE post_id = ?;", post_id "DELETE FROM to_telegram WHERE post_id = ?;", post_id
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment