Added support for deleting dm's with the new Twitter API methods

This commit is contained in:
Manuel Cortez 2018-09-29 11:13:11 -05:00
parent ca3f8779b8
commit 40105f37ed
4 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,7 @@
## changes in this version
* Added support for deleting direct messages by using the new Twitter API methods.
* When quoting a retweet, the quote will be made to the original tweet instead of the retweet.
* If the sent direct messages buffer is hidden, TWBlue should keep loading everything as expected. ([#246](https://github.com/manuelcortez/TWBlue/issues/246))
* There is a new soundpack, called FreakyBlue (Thanks to [Andre Louis](https://twitter.com/FreakyFwoof)) as a new option in TWBlue. This pack can be the default in the next stable, so users can take a look and share their opinion in snapshot versions. ([#247](https://github.com/manuelcortez/TWBlue/issues/247))

View File

@ -557,7 +557,6 @@ class baseBufferController(baseBuffers.buffer):
self.session.twitter.destroy_status(id=self.get_right_tweet()["id"])
self.session.db[self.name].pop(index)
self.buffer.list.remove_item(index)
# if index > 0:
except TwythonError:
self.session.sound.play("error.ogg")

View File

@ -153,7 +153,7 @@ class Twython(EndpointsMixin, object):
if k in ('timeout', 'allow_redirects', 'stream', 'verify'):
requests_args[k] = v
if method == 'get':
if method == 'get' or method == 'delete':
requests_args['params'] = params
else:
# Check for json_encoded so we will sent params as "data" or "json"
@ -242,7 +242,7 @@ class Twython(EndpointsMixin, object):
(e.g. search/tweets)
:type endpoint: string
:param method: (optional) Method of accessing data, either
GET or POST. (default GET)
GET, POST or DELETE. (default GET)
:type method: string
:param params: (optional) Dict of parameters (if any) accepted
the by Twitter API endpoint you are trying to
@ -281,6 +281,10 @@ class Twython(EndpointsMixin, object):
"""Shortcut for POST requests via :class:`request`"""
return self.request(endpoint, 'POST', params=params, version=version, json_encoded=json_encoded)
def delete(self, endpoint, params=None, version='1.1', json_encoded=False):
"""Shortcut for delete requests via :class:`request`"""
return self.request(endpoint, 'DELETE', params=params, version=version, json_encoded=json_encoded)
def get_lastfunction_header(self, header, default_return_value=None):
"""Returns a specific header from the last API call
This will return None if the header is not present

View File

@ -329,10 +329,10 @@ class EndpointsMixin(object):
"""Destroys the direct message specified in the required ``id`` parameter
Docs:
https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message
https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message-event
"""
return self.post('direct_messages/destroy', params=params)
return self.delete('direct_messages/events/destroy', params=params)
def send_direct_message(self, **params):
"""Sends a new direct message to the specified user from the