Spaces:
Running on Zero
Running on Zero
Download app/core/notify.py from cipher-attacks/Dbu-central-bot: direct link, hf CLI and curl.
- Browser
- Download file 611 Bytes
-
https://huggingface.co/spaces/cipher-attacks/Dbu-central-bot/resolve/main/app/core/notify.py
- Command line
-
hf download hf://spaces/cipher-attacks/Dbu-central-bot/app/core/notify.py
-
curl -L -o notify.py https://huggingface.co/spaces/cipher-attacks/Dbu-central-bot/resolve/main/app/core/notify.py
611 Bytes
| import logging | |
| from aiogram import Bot | |
| from app.config import get_settings | |
| log = logging.getLogger(__name__) | |
| async def safe_send(bot: Bot, chat_id: int, text: str, reply_markup=None) -> bool: | |
| try: | |
| await bot.send_message(chat_id, text, reply_markup=reply_markup) | |
| return True | |
| except Exception as exc: | |
| log.info("Could not message %s: %r", chat_id, exc) | |
| return False | |
| async def notify_admins(bot: Bot, text: str, reply_markup=None) -> None: | |
| for admin_id in get_settings().admin_id_set: | |
| await safe_send(bot, admin_id, text[:4000], reply_markup=reply_markup) | |