Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.telegram_bot.TelegramNotificationService Class Reference

Public Member Functions

def __init__ (self, hass, bot, allowed_chat_ids, parser)
 
def answer_callback_query (self, message, callback_query_id, show_alert=False, context=None, **kwargs)
 
def delete_message (self, chat_id=None, context=None, **kwargs)
 
def edit_message (self, type_edit, chat_id=None, context=None, **kwargs)
 
def leave_chat (self, chat_id=None, context=None)
 
def send_file (self, file_type=SERVICE_SEND_PHOTO, target=None, context=None, **kwargs)
 
def send_location (self, latitude, longitude, target=None, context=None, **kwargs)
 
def send_message (self, message="", target=None, context=None, **kwargs)
 
def send_poll (self, question, options, is_anonymous, allows_multiple_answers, target=None, context=None, **kwargs)
 
def send_sticker (self, target=None, context=None, **kwargs)
 

Public Attributes

 allowed_chat_ids
 
 bot
 
 hass
 

Private Member Functions

def _get_msg_ids (self, msg_data, chat_id)
 
def _get_msg_kwargs (self, data)
 
def _get_target_chat_ids (self, target)
 
def _send_msg (self, func_send, msg_error, message_tag, *args_msg, context=None, **kwargs_msg)
 

Private Attributes

 _default_user
 
 _last_message_id
 
 _parse_mode
 
 _parsers
 

Detailed Description

Implement the notification services for the Telegram Bot domain.

Definition at line 500 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

def homeassistant.components.telegram_bot.TelegramNotificationService.__init__ (   self,
  hass,
  bot,
  allowed_chat_ids,
  parser 
)
Initialize the service.

Definition at line 503 of file __init__.py.

Member Function Documentation

◆ _get_msg_ids()

def homeassistant.components.telegram_bot.TelegramNotificationService._get_msg_ids (   self,
  msg_data,
  chat_id 
)
private
Get the message id to edit.

This can be one of (message_id, inline_message_id) from a msg dict,
returning a tuple.
**You can use 'last' as message_id** to edit
the message last sent in the chat_id.

Definition at line 518 of file __init__.py.

◆ _get_msg_kwargs()

def homeassistant.components.telegram_bot.TelegramNotificationService._get_msg_kwargs (   self,
  data 
)
private
Get parameters in message data kwargs.

Definition at line 556 of file __init__.py.

◆ _get_target_chat_ids()

def homeassistant.components.telegram_bot.TelegramNotificationService._get_target_chat_ids (   self,
  target 
)
private
Validate chat_id targets or return default target (first).

:param target: optional list of integers ([12234, -12345])
:return list of chat_id targets (integers)

Definition at line 539 of file __init__.py.

◆ _send_msg()

def homeassistant.components.telegram_bot.TelegramNotificationService._send_msg (   self,
  func_send,
  msg_error,
  message_tag,
args_msg,
  context = None,
**  kwargs_msg 
)
private
Send one message.

Definition at line 652 of file __init__.py.

◆ answer_callback_query()

def homeassistant.components.telegram_bot.TelegramNotificationService.answer_callback_query (   self,
  message,
  callback_query_id,
  show_alert = False,
  context = None,
**  kwargs 
)
Answer a callback originated with a press in an inline keyboard.

Definition at line 791 of file __init__.py.

◆ delete_message()

def homeassistant.components.telegram_bot.TelegramNotificationService.delete_message (   self,
  chat_id = None,
  context = None,
**  kwargs 
)
Delete a previously sent message.

Definition at line 715 of file __init__.py.

◆ edit_message()

def homeassistant.components.telegram_bot.TelegramNotificationService.edit_message (   self,
  type_edit,
  chat_id = None,
  context = None,
**  kwargs 
)
Edit a previously sent message.

Definition at line 734 of file __init__.py.

◆ leave_chat()

def homeassistant.components.telegram_bot.TelegramNotificationService.leave_chat (   self,
  chat_id = None,
  context = None 
)
Remove bot from chat.

Definition at line 1015 of file __init__.py.

◆ send_file()

def homeassistant.components.telegram_bot.TelegramNotificationService.send_file (   self,
  file_type = SERVICE_SEND_PHOTO,
  target = None,
  context = None,
**  kwargs 
)
Send a photo, sticker, video, or document.

Definition at line 813 of file __init__.py.

◆ send_location()

def homeassistant.components.telegram_bot.TelegramNotificationService.send_location (   self,
  latitude,
  longitude,
  target = None,
  context = None,
**  kwargs 
)
Send a location.

Definition at line 958 of file __init__.py.

◆ send_message()

def homeassistant.components.telegram_bot.TelegramNotificationService.send_message (   self,
  message = "",
  target = None,
  context = None,
**  kwargs 
)
Send a message to one or multiple pre-allowed chat IDs.

Definition at line 692 of file __init__.py.

◆ send_poll()

def homeassistant.components.telegram_bot.TelegramNotificationService.send_poll (   self,
  question,
  options,
  is_anonymous,
  allows_multiple_answers,
  target = None,
  context = None,
**  kwargs 
)
Send a poll.

Definition at line 983 of file __init__.py.

◆ send_sticker()

def homeassistant.components.telegram_bot.TelegramNotificationService.send_sticker (   self,
  target = None,
  context = None,
**  kwargs 
)
Send a sticker from a telegram sticker pack.

Definition at line 936 of file __init__.py.

Member Data Documentation

◆ _default_user

homeassistant.components.telegram_bot.TelegramNotificationService._default_user
private

Definition at line 506 of file __init__.py.

◆ _last_message_id

homeassistant.components.telegram_bot.TelegramNotificationService._last_message_id
private

Definition at line 507 of file __init__.py.

◆ _parse_mode

homeassistant.components.telegram_bot.TelegramNotificationService._parse_mode
private

Definition at line 514 of file __init__.py.

◆ _parsers

homeassistant.components.telegram_bot.TelegramNotificationService._parsers
private

Definition at line 508 of file __init__.py.

◆ allowed_chat_ids

homeassistant.components.telegram_bot.TelegramNotificationService.allowed_chat_ids

Definition at line 505 of file __init__.py.

◆ bot

homeassistant.components.telegram_bot.TelegramNotificationService.bot

Definition at line 515 of file __init__.py.

◆ hass

homeassistant.components.telegram_bot.TelegramNotificationService.hass

Definition at line 516 of file __init__.py.


The documentation for this class was generated from the following file: