mandarons / icloud-drive-docker

Dockerized iCloud Client - make a local copy of your iCloud documents and photos, and keep it automatically up-to-date.
BSD 3-Clause "New" or "Revised" License
968 stars 46 forks source link

[FEATURE] Telegram Notifications #182

Closed fidoriel closed 5 months ago

fidoriel commented 6 months ago

Use case I would love to see the option to receive the messages that are sent via mail alternatively via telegram.

Describe the solution you'd like Just put two env vars into the config files. ChatID and token https://github.com/python-telegram-bot/python-telegram-bot

jakub-zawislak commented 6 months ago

It would be nice to have a feature to type a 2FA code by Telegram, instead of logging in to terminal

mandarons commented 5 months ago

This doesn't look technically feasible in app's current form. The library is async and app is sync. Once I move the app to use async, this integration can be done.

fidoriel commented 5 months ago

This works for me. It's just sending, but it works.

import os
from telegram import Bot
import asyncio

CHAT_ID = os.environ.get("CHAT_ID")
BOT_TOKEN = os.environ.get("BOT_TOKEN")

def msg(topic: str, body: str):
    bot = Bot(BOT_TOKEN)
    asyncio.run(bot.send_message(CHAT_ID, f"{topic}\n\n{body}"))
mandarons commented 5 months ago

Please help me test the implementation using 'mandarons/icloud-drive:main' docker image and let me know if it works.