Move imports in telegram_bot component (#27785)

This commit is contained in:
Quentame 2019-10-18 02:19:34 +02:00 committed by Paulus Schoutsen
parent 2d1f7932ba
commit bd0403c65e
3 changed files with 18 additions and 16 deletions

View file

@ -1,6 +1,10 @@
"""Support for Telegram bot using polling."""
import logging
from telegram import Update
from telegram.error import TelegramError, TimedOut, NetworkError, RetryAfter
from telegram.ext import Updater, Handler
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import callback
@ -32,8 +36,6 @@ async def async_setup_platform(hass, config):
def process_error(bot, update, error):
"""Telegram bot error handler."""
from telegram.error import TelegramError, TimedOut, NetworkError, RetryAfter
try:
raise error
except (TimedOut, NetworkError, RetryAfter):
@ -45,8 +47,6 @@ def process_error(bot, update, error):
def message_handler(handler):
"""Create messages handler."""
from telegram import Update
from telegram.ext import Handler
class MessageHandler(Handler):
"""Telegram bot message handler."""
@ -72,7 +72,6 @@ class TelegramPoll(BaseTelegramBotEntity):
def __init__(self, bot, hass, allowed_chat_ids):
"""Initialize the polling instance."""
from telegram.ext import Updater
BaseTelegramBotEntity.__init__(self, hass, allowed_chat_ids)