wip changes

This commit is contained in:
Micha Albert 2024-07-27 21:20:57 +00:00
parent 34da8cebda
commit 8cf027d67a

View file

@ -83,17 +83,92 @@ def handle_app_home_opened_events(body, logger, event, client):
@bolt.view("apply")
def handle_application_submission(ack, body):
ack()
print(body)
convo = bolt.client.conversations_open(users=body["user"]["id"], return_im=True)
user = body["user"]["id"]
sumbitter_convo = bolt.client.conversations_open(users=user, return_im=True)
user_verified = (
"Eligible L" not
in requests.get(
"https://verify.hackclub.dev/api/status", json={"slack_id": user}
).text
)
bolt.client.chat_postMessage(
channel=convo["channel"]["id"], text=f"Your application has been submitted! We will review it shortly. Please do not send another application - If you haven't heard back in over 48 hours, message @mra! Here's a copy of your responses for your reference:\n{body['view']['state']['values']['project-info']['project-desc-value']['value']}"
channel=sumbitter_convo["channel"]["id"],
text=f"Your application has been submitted! We will review it shortly. Please do not send another application - If you haven't heard back in over 48 hours, or you forgot something in your application, please message <@{os.environ['ADMIN_SLACK_ID']}>! Here's a copy of your responses for your reference:\nSome info on your project(s): {body['view']['state']['values']['project-info']['project-desc-value']['value']}{f"\nPlease fill out <https://forms.hackclub.com/eligibility?program=Onboard%20Live&slack_id={user}|the verification form>! We can't approve your application until this is done." if not user_verified else ""}",
)
admin_convo = bolt.client.conversations_open(
users=os.environ["ADMIN_SLACK_ID"], return_im=True
)
bolt.client.chat_postMessage(
channel=admin_convo["channel"]["id"],
text=":siren-real: New OnBoard Live application! :siren-real:",
blocks=[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":siren-real: New OnBoard Live application! :siren-real:",
},
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": f":technologist: Name: SUB_ME",
"emoji": True,
},
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": f":white_check_mark: Is verified: {user_verified}",
"emoji": True,
},
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": f":hammer_and_wrench: Will make: {body['view']['state']['values']['project-info']['project-desc-value']['value']}",
"emoji": True,
},
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": f":pray: Will behave on stream: Yes",
"emoji": True,
},
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": True,
"text": "Approve",
},
"style": "primary",
"value": "deny",
},
{
"type": "button",
"text": {"type": "plain_text", "emoji": True, "text": "Deny"},
"style": "danger",
"value": "approve",
},
],
},
],
)
@bolt.command("/onboard-live-apply")
def apply(ack: Ack, command):
ack()
print(command)
r = requests.post(
"https://slack.com/api/views.open",
headers={"Authorization": f"Bearer {os.environ['SLACK_TOKEN']}"},