mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Upgrade python-telegram-bot to 5.1.0 (#3525)
This commit is contained in:
parent
d6c586bf42
commit
f3caca6a06
@ -14,16 +14,16 @@ import voluptuous as vol
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_TITLE, ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService)
|
ATTR_TITLE, ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService)
|
||||||
from homeassistant.const import (CONF_API_KEY, ATTR_LOCATION, ATTR_LATITUDE,
|
from homeassistant.const import (
|
||||||
ATTR_LONGITUDE)
|
CONF_API_KEY, ATTR_LOCATION, ATTR_LATITUDE, ATTR_LONGITUDE)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REQUIREMENTS = ['python-telegram-bot==5.0.0']
|
REQUIREMENTS = ['python-telegram-bot==5.1.0']
|
||||||
|
|
||||||
ATTR_PHOTO = "photo"
|
ATTR_PHOTO = 'photo'
|
||||||
ATTR_DOCUMENT = "document"
|
ATTR_DOCUMENT = 'document'
|
||||||
ATTR_CAPTION = "caption"
|
ATTR_CAPTION = 'caption'
|
||||||
ATTR_URL = 'url'
|
ATTR_URL = 'url'
|
||||||
ATTR_FILE = 'file'
|
ATTR_FILE = 'file'
|
||||||
ATTR_USERNAME = 'username'
|
ATTR_USERNAME = 'username'
|
||||||
@ -46,9 +46,9 @@ def get_service(hass, config):
|
|||||||
api_key = config.get(CONF_API_KEY)
|
api_key = config.get(CONF_API_KEY)
|
||||||
bot = telegram.Bot(token=api_key)
|
bot = telegram.Bot(token=api_key)
|
||||||
username = bot.getMe()['username']
|
username = bot.getMe()['username']
|
||||||
_LOGGER.info("Telegram bot is '%s'.", username)
|
_LOGGER.info("Telegram bot is '%s'", username)
|
||||||
except urllib.error.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
_LOGGER.error("Please check your access token.")
|
_LOGGER.error("Please check your access token")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return TelegramNotificationService(api_key, chat_id)
|
return TelegramNotificationService(api_key, chat_id)
|
||||||
@ -122,7 +122,7 @@ class TelegramNotificationService(BaseNotificationService):
|
|||||||
text=text,
|
text=text,
|
||||||
parse_mode=parse_mode)
|
parse_mode=parse_mode)
|
||||||
except telegram.error.TelegramError:
|
except telegram.error.TelegramError:
|
||||||
_LOGGER.exception("Error sending message.")
|
_LOGGER.exception("Error sending message")
|
||||||
return
|
return
|
||||||
|
|
||||||
def send_photo(self, data):
|
def send_photo(self, data):
|
||||||
@ -141,7 +141,7 @@ class TelegramNotificationService(BaseNotificationService):
|
|||||||
self.bot.sendPhoto(chat_id=self._chat_id,
|
self.bot.sendPhoto(chat_id=self._chat_id,
|
||||||
photo=photo, caption=caption)
|
photo=photo, caption=caption)
|
||||||
except telegram.error.TelegramError:
|
except telegram.error.TelegramError:
|
||||||
_LOGGER.exception("Error sending photo.")
|
_LOGGER.exception("Error sending photo")
|
||||||
return
|
return
|
||||||
|
|
||||||
def send_document(self, data):
|
def send_document(self, data):
|
||||||
@ -160,7 +160,7 @@ class TelegramNotificationService(BaseNotificationService):
|
|||||||
self.bot.sendDocument(chat_id=self._chat_id,
|
self.bot.sendDocument(chat_id=self._chat_id,
|
||||||
document=document, caption=caption)
|
document=document, caption=caption)
|
||||||
except telegram.error.TelegramError:
|
except telegram.error.TelegramError:
|
||||||
_LOGGER.exception("Error sending document.")
|
_LOGGER.exception("Error sending document")
|
||||||
return
|
return
|
||||||
|
|
||||||
def send_location(self, gps):
|
def send_location(self, gps):
|
||||||
@ -174,5 +174,5 @@ class TelegramNotificationService(BaseNotificationService):
|
|||||||
self.bot.sendLocation(chat_id=self._chat_id,
|
self.bot.sendLocation(chat_id=self._chat_id,
|
||||||
latitude=latitude, longitude=longitude)
|
latitude=latitude, longitude=longitude)
|
||||||
except telegram.error.TelegramError:
|
except telegram.error.TelegramError:
|
||||||
_LOGGER.exception("Error sending location.")
|
_LOGGER.exception("Error sending location")
|
||||||
return
|
return
|
||||||
|
@ -387,7 +387,7 @@ python-nmap==0.6.1
|
|||||||
python-pushover==0.2
|
python-pushover==0.2
|
||||||
|
|
||||||
# homeassistant.components.notify.telegram
|
# homeassistant.components.notify.telegram
|
||||||
python-telegram-bot==5.0.0
|
python-telegram-bot==5.1.0
|
||||||
|
|
||||||
# homeassistant.components.sensor.twitch
|
# homeassistant.components.sensor.twitch
|
||||||
python-twitch==1.3.0
|
python-twitch==1.3.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user