Is there a cleaner way to create msg
? For each event (Ping, Pull request, Issue, Issue comment, Repo, Create, Delete, Pull requset review, Push, Commit comment) is there an if clause that checks the event and creates a message according to it's action.
data = request.json
event = request.headers['X-Github-Event']
msg = ""
...
# Pull request
elif event == "pull_request":
if data['action'] == "opened":
msg = PullRequest(data).opened()
elif data['action'] == "closed":
msg = PullRequest(data).closed()
elif data['action'] == "assigned":
msg = PullRequest(data).assigned()
# Issue
elif event == "issues":
if data['action'] == "opened":
msg = Issue(data).opened()
elif data['action'] == "reopened":
msg = Issue(data).reopened()
elif data['action'] == "closed":
msg = Issue(data).closed()
elif data['action'] == "labeled":
msg = Issue(data).labeled()
elif data['action'] == "assigned":
msg = Issue(data).assigned()
...
Aucun commentaire:
Enregistrer un commentaire