mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Upgrade TwitterAPI to 2.5.7 (#19382)
This commit is contained in:
parent
6b8835b196
commit
90608da5c2
@ -19,7 +19,7 @@ from homeassistant.components.notify import (
|
|||||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_USERNAME
|
||||||
from homeassistant.helpers.event import async_track_point_in_time
|
from homeassistant.helpers.event import async_track_point_in_time
|
||||||
|
|
||||||
REQUIREMENTS = ['TwitterAPI==2.5.4']
|
REQUIREMENTS = ['TwitterAPI==2.5.7']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -78,10 +78,25 @@ class TwitterNotificationService(BaseNotificationService):
|
|||||||
def send_message_callback(self, message, media_id=None):
|
def send_message_callback(self, message, media_id=None):
|
||||||
"""Tweet a message, optionally with media."""
|
"""Tweet a message, optionally with media."""
|
||||||
if self.user:
|
if self.user:
|
||||||
resp = self.api.request('direct_messages/new',
|
user_resp = self.api.request(
|
||||||
{'user': self.user,
|
'users/lookup', {'screen_name': self.user})
|
||||||
'text': message,
|
user_id = user_resp.json()[0]['id']
|
||||||
'media_ids': media_id})
|
if user_resp.status_code != 200:
|
||||||
|
self.log_error_resp(user_resp)
|
||||||
|
else:
|
||||||
|
_LOGGER.debug("Message posted: %s", user_resp.json())
|
||||||
|
|
||||||
|
event = {
|
||||||
|
'event': {
|
||||||
|
'type': 'message_create',
|
||||||
|
'message_create': {
|
||||||
|
'target': {'recipient_id': user_id},
|
||||||
|
'message_data': {'text': message},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resp = self.api.request(
|
||||||
|
'direct_messages/events/new', json.dumps(event))
|
||||||
else:
|
else:
|
||||||
resp = self.api.request('statuses/update',
|
resp = self.api.request('statuses/update',
|
||||||
{'status': message,
|
{'status': message,
|
||||||
|
@ -73,7 +73,7 @@ RtmAPI==0.7.0
|
|||||||
TravisPy==0.3.5
|
TravisPy==0.3.5
|
||||||
|
|
||||||
# homeassistant.components.notify.twitter
|
# homeassistant.components.notify.twitter
|
||||||
TwitterAPI==2.5.4
|
TwitterAPI==2.5.7
|
||||||
|
|
||||||
# homeassistant.components.sensor.waze_travel_time
|
# homeassistant.components.sensor.waze_travel_time
|
||||||
WazeRouteCalculator==0.6
|
WazeRouteCalculator==0.6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user