python-twitter
python-twitter copied to clipboard
UpdateFriendship needs hardcoded device notifications argument, set to False
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.
Geez, yeah. Don't know where that snuck in, but that's bad. I'll fix it.
No worries. Glad I caught it. Thanks for fixing it! 👍