Hexalyse / LightningTweeter

A lightning strike detector using the AS9535 sensor from AMS, that tweets about detected storms.
20 stars 10 forks source link

occasional error #1

Open thymjan opened 7 years ago

thymjan commented 7 years ago
We sensed lightning! (19:02:54 - 2017/08/01)
Energy: 17652 - distance: 8km
Unhandled exception in thread started by <function send_tweet at 0xb64533b0>
Traceback (most recent call last):
  File "./Blitzdetektor/LightningTweeter/lightning_tweeter.py", line 41, in send_tweet
    api.update_status(tweet)
  File "/usr/local/lib/python2.7/dist-packages/tweepy/api.py", line 194, in update_status
    )(post_data=post_data, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 245, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 229, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{u'message': u'Status is a duplicate.', u'code': 187}]
We sensed lightning! (19:42:12 - 2017/08/01)
Energy: 20210 - distance: 17km

I don't really understand what the problem is. Do you know/understand this error?

Hexalyse commented 7 years ago

Oh, yes. I had the same problem, and (apparently) fixed it in the version I run but forgot to push it to Github.

For me, it happened for the "storm has ended" tweets, which were exactly the same, so it triggered the Twitter protection preventing bots from posting duplicates. So I added a timestamp (date and time) to the tweets' text.

But I don't know how (on what criterias) Twitter considers tweets from being duplicates. And apparently, for you, it happened for a tweet signaling a strike has been detected... and it shouldn't be a duplicate (distance and strength values change and I doubt it would be the same as the previous tweets).

You could try adding a timestamp to the tweets, and hope that Twitter no longer flags them as duplicate. Otherwise... I don't really see a way around.

5foot8 commented 5 years ago

Could you add a duplicate check loop into the software - something along the line of lastTweet != tweet send, otherwise throw it away until one that is different. If there is a way for the software not to crash if an error is raised but gracefully start looking for next lightning strike and try again?