Last active
October 20, 2023 00:34
-
-
Save backgr02/968620a98cc7960d2d8ae5d0c32bc98b to your computer and use it in GitHub Desktop.
AWS Lambda で Misskey ユーザーをフォローバック(リノートもフォロー)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euxo pipefail | |
cd "$(dirname "$0")" | |
./zip.sh .venv/function.zip | |
aws lambda update-function-code --function-name flowbackToMisskeyUser --zip-file fileb://.venv/function.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
from misskey import Misskey | |
def lambda_handler(event, context): | |
print(json.dumps(event)) | |
print(context) | |
result = run(json.loads(event["body"])) | |
return { | |
"statusCode": 200, | |
"body": json.dumps(result), | |
} | |
def run(body: dict) -> dict: | |
print(json.dumps(body)) | |
mk = Misskey( | |
address="misskey.io", | |
i=os.environ["MISSKEY_TOKEN"], | |
) | |
if body["type"] == "followed": | |
return mk.following_create(body["body"]["user"]["id"]) | |
if body["type"] == "renote": | |
return mk.following_create(body["body"]["note"]["user"]["id"]) | |
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
certifi==2023.7.22 | |
charset-normalizer==3.2.0 | |
idna==3.4 | |
Misskey.py==4.1.0 | |
requests==2.31.0 | |
urllib3==2.0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euxo pipefail | |
cd "$(dirname "$0")" | |
# shellcheck source=/dev/null | |
source .venv/bin/activate | |
pip install -r requirements.txt -t . | |
rm -f "${1}" | |
zip -r "${1}" ./* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment