zulip / python-zulip-api

Python library for the Zulip API.
https://zulip.com/api/
Apache License 2.0
350 stars 352 forks source link

Duplicating same tweets when following more users with Twitter-bot #697

Open jiriryszawy opened 3 years ago

jiriryszawy commented 3 years ago

When following multiple users on Twitter with Twitter-bot using crontab, the same tweets will be will be importing again and again everytime crontab call the twitter-bot script. Using

*/5 * * * * /usr/local/share/zulip/integrations/twitter/twitter-bot --twitter-name="@TwitterUsername1" --config-file=~/zuliprc
*/5 * * * * /usr/local/share/zulip/integrations/twitter/twitter-bot --twitter-name="@TwitterUsername2" --config-file=~/zuliprc
*/5 * * * * /usr/local/share/zulip/integrations/twitter/twitter-bot --twitter-name="@TwitterUsername3" --config-file=~/zuliprc

will repeat to import last 5 tweets from two TwitterUsernames from the list every five minutes. Only one TwitterUsername will behave as expected and his tweets will not be duplicated.

@strifel proposed this solution: You could try changing line 114 in /usr/local/share/zulip/integrations/twitter/twitter-bot from

CONFIGFILE_INTERNAL = os.path.expanduser("~/.zulip_twitteruserrc_fetchuser")

to

CONFIGFILE_INTERNAL = os.path.expanduser("~/.zulip_twitteruserrc_fetchuser_" + opts.twitter_name.replace('@', ''))

It solved the problem so I suggest to embed this code to twitter-bot if this don't affect using twitter-bot with only one following TwitterUser.