Skip to content

Instantly share code, notes, and snippets.

@fu-sen
Last active December 10, 2023 11:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fu-sen/1f1074935e3a837fb74f011ed6a9106f to your computer and use it in GitHub Desktop.
Misskey GitHub の releases 更新でノートする bot
#!/bin/sh
# crontab -e
# */5 * * * * ~~~/misskeyrelease.sh (5 分おき)
FEED_URL="https://github.com/misskey-dev/misskey/releases.atom" # 参照する Feed(ATOM)
TEMP_FILE="/home/ユーザー/~/misskeyrelease.txt" # 最新リンクを保存するファイル
MISSKEY_TOKEN="01234567890123456789012345678901" # アクセストークン (設定 - API から。「ノートを作成・削除する」を有効にする)
MISSKEY_INSTANCE="misskey.example.com" # インスタンス名 misskey.io など
MISSKEY_NOTEMODE="public" # 公開モード public local followers specified
set -e
NEW_URL=`curl --silent "$FEED_URL" | tail -n +7 | grep -oP 'href=".*"' | sed 's/href="//g' | tr -d '"' | head -n 1`
MARK_URL=`cat $TEMP_FILE`
if [ -z "$NEW_URL" ]; then
echo "Feed error"
exit 255
fi
if [ "$NEW_URL" = "https://support.github.com" ]; then
echo "Feed error"
exit 254
fi
if [ "$NEW_URL" = "https://support.github.com/contact" ]; then
echo "Feed error"
exit 254
fi
if [ "$NEW_URL" = "https://github.com/contact" ]; then
echo "Feed error"
exit 254
fi
if [ "$NEW_URL" = "$MARK_URL" ]; then
echo "Note not required"
exit
fi
RET_CODE=`curl -X POST -H "Content-Type: application/json" -d "{ \"i\": \"$MISSKEY_TOKEN\", \"text\": \"$NEW_URL\", \"visibility\": \"$MISSKEY_NOTEMODE\" }" https://$MISSKEY_INSTANCE/api/notes/create`
echo "$NEW_URL" > $TEMP_FILE
# 空ファイル。misskeyrelease.sh が上書きできるようにパーミッションを設定する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment