# coding:utf-8 | |
# Python 3.6 | |
import json | |
import re | |
import requests # Please upload by zip, see also: https://qiita.com/Hironsan/items/0eb5578f3321c72637b4 | |
WEB_HOOK_URL = "" # Please set your slack incoming webhook url | |
attachments = [] | |
attachments.append({ | |
'token': 'Processing for App Store', | |
'text': u'アップロードが完了しました。アプリの処理中です。', | |
'color': u'#00BBAA' | |
}) | |
attachments.append({ | |
'token': 'has completed processing', | |
'text': u'アップロード後の処理が完了しました。', | |
'color': u'#00BBAA' | |
}) | |
attachments.append({ | |
'token': 'Waiting For Review', | |
'text': u'申請が完了しました。レビュー待ちです。', | |
'color': u'#00BBAA' | |
}) | |
attachments.append({ | |
'token': 'Developer Rejected', | |
'text': u'アプリの申請を取り下げました。', | |
'color': u'#FFBB44' | |
}) | |
attachments.append({ | |
'token': 'In Review', | |
'text': u'レビューに入りました。', | |
'color': u'#FFBB44' | |
}) | |
attachments.append({ | |
'token': 'New message from App Review', | |
'text': u'レビューアプリに対して、Appleより連絡がありました。', | |
'color': u'#FFBB44' | |
}) | |
attachments.append({ | |
'token': 'Pending Developer Release', | |
'text': u'レビューが通りました。おめでとうございます~:age:', | |
'color': u'#00BBAA' | |
}) | |
attachments.append({ | |
'token': 'Ready for Sale', | |
'text': u'公開処理が完了しました。反映までしばらくお待ちください。', | |
'color': u'#00BBAA' | |
}) | |
def find_attachment(subject): | |
for a in attachments: | |
if re.search(a['token'], subject): | |
return a | |
return None | |
def post_slack(subject, attachment): | |
attachment['fields'] = [{ | |
'title': subject, | |
'short': False | |
}] | |
requests.post(WEB_HOOK_URL, data = json.dumps({ | |
'text': u'ステータスに変更がありました', | |
'username': u'AppStore Connect', | |
'icon_emoji': u':apple:', | |
'link_names': 1, | |
'attachments':[attachment] | |
})) | |
def lambda_handler(event, context): | |
subject = json.loads(event['Records'][0]['Sns']['Message'])['mail']['commonHeaders']['subject'] | |
post_slack(subject, find_attachment(subject)) | |
return { | |
'statusCode': 200, | |
'body': 'end' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment