SuperMeepBoy / wikitransbot

Twitter bot for Wikitrans
https://wikitrans.co/
MIT License
3 stars 2 forks source link

Running the bot after deleting since_id.txt results in `status is a duplicate` error #1

Closed SuperMeepBoy closed 3 years ago

SuperMeepBoy commented 3 years ago

Expected Behavior

Running the bot after deleting since_id.txt should just recreate the file and loop again on the tweets.

Current Behavior

Running the bot after deleting since_id.txt makes the bot crash and give the following error :

Traceback (most recent call last):
  File "/shared/main.py", line 53, in <module>
    main()
  File "/shared/main.py", line 45, in main
    since_id = check_mentions(api, ["article"], since_id)
  File "/shared/main.py", line 32, in check_mentions
    api.update_status(f"@{tweet.author.screen_name} Check : {response.json()['data']['posts'][0]['link']}", tweet.id)
  File "/usr/local/lib/python3.9/dist-packages/tweepy/api.py", line 205, in update_status
    return bind_api(
  File "/usr/local/lib/python3.9/dist-packages/tweepy/binder.py", line 253, in _call
    return method.execute()
  File "/usr/local/lib/python3.9/dist-packages/tweepy/binder.py", line 234, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{'code': 187, 'message': 'Status is a duplicate.'}]

Possible Solution

Use a try/except. It might also resolve the unanswered question "what happens if I lose my since_id.txt file ? Will it answer to the tweets a second time ?"

Steps to Reproduce

  1. Run the bot a first time (with tweets to answer to)
  2. Delete the since_id.txt
  3. Run the bot again