def send_telegram_image(chat: Chat, image_url: str, text: str, parse_mode: ParseMode = telegram.ParseMode.MARKDOWN, **kwargs): if not bot: log.warning("No telegram token. Skipping") return log.info(f"Telegram: sending the image: {image_url} {text}") return bot.send_photo(chat_id=chat.id, photo=image_url, caption=text[:1024], parse_mode=parse_mode, **kwargs)
def send_telegram_message(chat: Chat, text: str, parse_mode: ParseMode = telegram.ParseMode.MARKDOWN, disable_preview: bool = True, **kwargs): if not bot: log.warning("No telegram token. Skipping") return log.info(f"Telegram: sending the message: {text}") return bot.send_message(chat_id=chat.id, text=text, parse_mode=parse_mode, disable_web_page_preview=disable_preview, **kwargs)
def send_telegram_image(chat: Chat, image_url: str, text: str, parse_mode: ParseMode = telegram.ParseMode.HTML, **kwargs): if not bot: log.warning("No telegram token. Skipping") return log.info(f"Telegram: sending the image: {image_url} {text}") try: return bot.send_photo(chat_id=chat.id, photo=image_url, caption=text[:1024], parse_mode=parse_mode, **kwargs) except telegram.error.TelegramError as ex: log.warning(f"Telegram error: {ex}")
def send_telegram_message(chat: Chat, text: str, parse_mode: ParseMode = telegram.ParseMode.HTML, disable_preview: bool = True, **kwargs): if not bot: log.warning("No telegram token. Skipping") return log.info(f"Telegram: sending the message: {text}") try: return bot.send_message(chat_id=chat.id, text=text, parse_mode=parse_mode, disable_web_page_preview=disable_preview, **kwargs) except telegram.error.TelegramError as ex: log.warning(f"Telegram error: {ex}")