Set the Telegram group's avatar automatically during setup

setChatPhoto right after the group id is known — needs an actual file
upload (multipart), not a URL like sendPhoto, so this is a plain curl
-F call directly against the Bot API rather than going through the
running server. Best-effort: failure (e.g. bot not admin yet) just
prints a note instead of blocking setup.
This commit is contained in:
Folist 2026-08-14 11:48:55 +03:00
parent 8c5e3f6f63
commit a77bc4fd05
3 changed files with 14 additions and 0 deletions

View file

@ -19,6 +19,7 @@
- `/kill` — аварийный сброс: то же самое + разлогинивание MAX-сессии и полное стирание сохранённых данных
- `/version` — проверка обновлений и обновление по кнопке прямо из Telegram (см. [«Обновление»](#обновление))
- `/apikey` — напомнить ключ веб-панели, если потерялся
- Аватарка группы и цвет иконки каждой темы форума выставляются автоматически
Полный список команд бота — `/help` прямо в боте после запуска.

BIN
assets/group-avatar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View file

@ -160,6 +160,19 @@ if [ -z "$TARGET_TELEGRAM_GROUP" ]; then
done
fi
# Best-effort — needs the bot to already be a group admin with "Change Group
# Info" rights, which setup already asked for above. setChatPhoto needs an
# actual file upload (multipart), not a URL, unlike sendPhoto.
AVATAR="$(dirname "$0")/assets/group-avatar.png"
if [ -f "$AVATAR" ]; then
if curl -s -F "chat_id=$TARGET_TELEGRAM_GROUP" -F "photo=@$AVATAR" \
"https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setChatPhoto" | grep -q '"ok":true'; then
echo "Аватарка группы установлена."
else
echo "Не удалось установить аватарку группы (не критично, можно поставить вручную)."
fi
fi
API_KEY=$(openssl rand -hex 24)
MAX_SESSION_KEY=$(openssl rand -hex 32)