Skip to content

Google App Script Automated Processing for application of NYUST-GDSC Coreteam

Notifications You must be signed in to change notification settings

NYUST-GDSC/CoreTeam-GoogleForm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CoreTeam-GoogleForm 雲林科技大學 GDSC Core Team 招募表單機器人

NYUST GDSC CoreTeam 招生表單

For Manager


Core Technic 核心技術

  • Google Form
  • Google App Script
  • Discord Webhook Bot

Get Started 開始進行

Step.1 建立 Google Form

建立好 Google Form 樣式

Step.2 根據 Google Form 表單取得需要的資料

範例程式

    const response = e.response.getItemResponses();
    let items = [];

    for (const responseAnswer of response) {
        const question = responseAnswer.getItem().getTitle(); // 取得表單標題
        const answer = responseAnswer.getResponse(); //取得表單回應
        let parts = []

        try {
            parts = answer.match(/[\s\S]{1,1024}/g) || [];
        } catch (e) {
            parts = answer;
        }

        if (!answer) {
            continue;
        }

        for (const [index, part] of Object.entries(parts)) {
            if (index == 0) {
                items.push({
                    "name": question,
                    "value": part,
                    "inline": false
                });
            } else {
                items.push({
                    "name": question.concat(" (cont.)"),
                    "value": part,
                    "inline": false
                });
            }
        }
    }

Step.3 建立發布通知的 Discord 頻道

編輯頻道資訊

找到 Integration 按下 Create Webhook

系統會自建一個基本的 Webhook Bot 給你

可以根據需求進行名稱修改,修改完畢記得 Copy Webhook URL

貼上至程式中的 Webhook 變數中

const POST_URL = "<Your Webhook URL>";

Step.4 將程式加入 Google Form

點選指令碼編輯器

Step.5 設定觸發條件

點選 [觸發條件] -> [新增觸發條件]

設定活動類型為 [提交表單時]

若出現以下情形,代表程式碼內尚未有任何函示可以觸發。解決方法:儲存程式碼並重新整理

設定完觸發條件後,就大功告成啦 !!!

成果圖


結語

若路過的朋友覺得這份專案還不錯,歡迎給予專案星星以及 Follow NYUST GDSC

About

Google App Script Automated Processing for application of NYUST-GDSC Coreteam

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published