Skip to content

Instantly share code, notes, and snippets.

@backgr02
Last active October 20, 2023 00:34
Show Gist options
  • Save backgr02/968620a98cc7960d2d8ae5d0c32bc98b to your computer and use it in GitHub Desktop.
Save backgr02/968620a98cc7960d2d8ae5d0c32bc98b to your computer and use it in GitHub Desktop.
AWS Lambda で Misskey ユーザーをフォローバック(リノートもフォロー)
#!/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
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 {}
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
#!/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