python-twitter icon indicating copy to clipboard operation
python-twitter copied to clipboard

UpdateFriendship needs hardcoded device notifications argument, set to False

Open nitinthewiz opened this issue 7 years ago • 2 comments
trafficstars

This is somewhat a followup of Issue #522 where a user asked you to add the retweet kwarg to the UpdateFriendship function.

Well, I used that recently and it caused an unintended consequence. I was trying to get rid of all retweets from my TL and I ran the following bit of code -

friends = api.GetFriends()
for friend in friends:
    api.UpdateFriendship(user_id=friend.id, retweets=False)

This did turn off all retweets but it also turned on device notifications for all users I follow. That was a horrible 5 minutes for my phone! 😆

So I fixed it using -

api.UpdateFriendship(user_id=friend.id, retweets=False, device=False)

I noticed this is because 'device' is not a specified keyword and doesn't have a default value (therefore I missed it in the function definition in the first try).

I'm wondering if you can take it out of the kwargs and add it to the function declaration and set it to False, so by default, it doesn't turn on. Something to the tune of -

def UpdateFriendship(self,
                     user_id=None,
                     screen_name=None,
                     follow=True,
                     retweets=True,
                     device=False,
                     **kwargs):

For that matter, I'd like to recommend that retweets should also be set to False, as per this article here but changing that now would mean breaking a lot of other users' code, so it's up to you.

nitinthewiz avatar Mar 12 '18 20:03 nitinthewiz

Geez, yeah. Don't know where that snuck in, but that's bad. I'll fix it.

jeremylow avatar Mar 13 '18 11:03 jeremylow

No worries. Glad I caught it. Thanks for fixing it! 👍

nitinthewiz avatar Mar 13 '18 18:03 nitinthewiz