TelegramBotNotifications.core.TelegramBot

class TelegramBotNotifications.core.TelegramBot(token: str, channel_mode: bool = False, users_path: Optional[str] = None, new_users_check: bool = True)

Bases: object

Wrapper of official telegram API to send notifications from a BOT initiaed manually with @BotFather.

Parameters
  • token (str) – token of telegram bot

  • channel_mode (bool) – init class in channel_bot, send to all chat_id contained in telegram_users.csv. Defaults to False.

  • users_data_path (str, optional) – _descr_. Defaults to None.

  • new_users_check (bool, optional) – check for new users and add new ones to telegram_users.csv . Defaults to True.

token

token of telegram bot

Type

str

channel_mode

channel_mode is active

Type

bool

users_data_path

_descr_

Type

str

users

dataframe containing usernames and chat_id of known users following the bot

Type

pandas.DataFrame

updates

dataframe containing all updates fetched from bot

Type

pandas.DataFrame

Raises
  • FileNotFoundError – _description_

  • ValueError – _description_

Methods

__init__(token[, channel_mode, users_path, ...])

getUpdates()

get updates from bot

new_users()

check if unknown users have interacted with the telegram bot.

send_doc(document, chat_id[, caption])

send document.

send_message(message, chat_id)

send message to a specific user

send_message_to_all(message)

send message to all known users

send_message_to_user(message, username)

send message to specific user.

send_photo(photo, chat_id[, caption])

send photo.

send_photo_to_all(photo)

send message to all known users

getUpdates()

get updates from bot

new_users()

check if unknown users have interacted with the telegram bot. If the new users are found, they are automatically added to known users csv files.

send_doc(document, chat_id, caption='')

send document.

send_message(message, chat_id)

send message to a specific user

Parameters
  • message (str) – string containing message to send

  • chat_id (int) – chat_id code of chat to send the message to

send_message_to_all(message)

send message to all known users

Parameters

message (str) – string containing message to send

send_message_to_user(message, username)

send message to specific user.

Parameters
  • message (str) – string containing message to send

  • username (str) – string username, as saved in telegram_users.csv

  • file.

send_photo(photo, chat_id, caption='')

send photo.

Parameters
  • photo (str) – string path to photo

  • chat_id (int) – chat_id code of chat to send the message to

send_photo_to_all(photo)

send message to all known users

Parameters

photo (str) – string path to photo