watatakahashi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 2020/08/05インターンシップ ## [説明資料](https://gitpitch.com/JapanComputerServicesInc/training-for-prospective-employees/20200805#/) ## QRコード情報 - ユーザー1 ![](https://i.imgur.com/GFkD01j.png) - ユーザー2(講師用) ![](https://i.imgur.com/epJwEa3.png) - ユーザー3(人事用:大矢さん) ![](https://i.imgur.com/7pQb7Dl.png) - ユーザー4(人事用:藤さん) ![](https://i.imgur.com/g41cUS2.png) ## Google Apps Scriptに出た URL - ここにウェブアプリケーションのURL(WebhookURL)を貼ってください - ユーザ1 https://script.google.com/macros/s/AKfycbywHzZl0iCuQ6vUvSZz7XU3b92ELqKMFh1gIE3e4Qna5MaVeh3P/exec - ユーザ2(講師用) https://script.google.com/macros/s/AKfycbzY3EqsbcK-cIXuNAdvbTxKaN_yTfalKQ2LdkkkpdhiCjpJVJuK/exec - ユーザー3(人事用:大矢さん) https://script.google.com/macros/s/AKfycbw5cvdq07k3yU7_r0cr1MTkZyP3zIMII4gzr7Dgmqx89PX96XEK/exec - ユーザー4(人事用:藤さん) - https://script.google.com/macros/s/AKfycbzP_Oh4J7_BXs99uj_l4zHpPQt8bS-mQS_IUngVwwZg_AVW6i0/exec ## アクセストークン情報 - ユーザー1 /rHFV1RsScOA89KHPKlUQagC4w9J8rEi8J1YFnYQdLX7VQ0ZS5wsmRNZYwQ3rpzv8fy0Tf6tRmXx2/UsmjPgJX2TtjZnTV6UEG+ZskvOSZ+EHScHA5ohZIGM5IWoN2MpyBo6iSA8t+ztH89GAa+UqgdB04t89/1O/w1cDnyilFU= - ユーザー2(講師用) qN0JCUioNBUnM162EJDVoKUZpufQm369a5vNyyj38ZQZqSXi4zDHlpL2IOWOTRY/fMxH1oTE6QlCRzHH6mXx1bdjIBY9rJ4A+FhyNS7C13SjXN6EKvrOky3XIir5kLfvGqVEYQRSOi5l0Ge4QNGBlAdB04t89/1O/w1cDnyilFU= - ユーザー3(人事用:大矢さん) eIWIktdk0A+RUYrJMI8c2X0DleR2jaOByuxvaneN/miW1TQranudHIg9KWOugzLw/DuCDjEQVc2Oj+93QaKqQvkBXM15NKUvS7HDS+c7SDpIQrMKNg7Bn4M/7PpIL3XH/tRt+2BVHZKjV5IhpC8xogdB04t89/1O/w1cDnyilFU= - ユーザー4(人事用:藤さん) McaOgBCq/OnpDnI1RS88b0E3/CyFrhiWGsCUs26b4PSQrX0IIJ9qTitzFGFDjCbJe/8o6ZZ9hWIS5uy6jRrOgzwd3WYtlSJKKYV2OMgW6jmN+io8QkF0uogR9DNNHQUl4eM7L1I79IWEhSR7KZhhjwdB04t89/1O/w1cDnyilFU= --- ## 課題1: やりたいことを決めてくれるBotをつくる コピペする ``` =TEXTJOIN("、",TRUE,A:A) ``` ### ゴール 「③ゴニョゴニョ〜」の部分をプログラミングしてつくる💪 ![2](https://crowi.jcslabs.net/uploads/attachment/5d91998448525b4b3e33564d/4dce076993cf55a04fec408a9650e025.png) ### 1. 下準備: おまじないをしておく #### 1-1. [新しいGoogleスプレッドシートを作成](https://docs.google.com/spreadsheets)->[ツール]->[スクリプトエディタ] #### 1-2. 「ファイル」->「New」->「スクリプトファイル」から、新規ファイル「おまじない.gs」を作成する #### 1-3. おまじない.gsの中身を以下に書き換える ```:javascript // CHANNEL_ACCESS_TOKENを設定 var CHANNEL_ACCESS_TOKEN = ""; // 作成したスプレッドシートのURLを入力する var SPREAD_SHEET_URL = ""; var LINE_ENDPOINT = "https://api.line.me/v2/bot/message/reply"; // SpreadSheetの取得 var spreadSheet = SpreadsheetApp.openByUrl(SPREAD_SHEET_URL); var sheet = spreadSheet.getSheets()[0]; // 変換に使う連想配列 var COL_STRING_TO_NUMBER = {"A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6 }; /** * LINEから情報を受け取るためのもの */ function doPost(e) { // LINEから受け取ったデータを扱いやすい形式(JSON)に変換する var json = JSON.parse(e.postData.contents); // 返信するためのトークン(鍵みたいなもの)取得 var replyToken = json.events[0].replyToken; // トークンがない場合は何もせずに処理を終了する if (typeof replyToken === "undefined") { return; } // 送られたLINEメッセージを取得 var lineMessage = json.events[0].message.text; // メッセージを求める var replyMessage = [] try { replyMessage = [createReply(lineMessage)]; } catch (e) { replyMessage = [e.message]; } // メッセージを返信 var messages = replyMessage.map(function(v) { return { type: "text", text: v }; }); UrlFetchApp.fetch(LINE_ENDPOINT, { headers: { "Content-Type": "application/json; charset=UTF-8", Authorization: "Bearer " + CHANNEL_ACCESS_TOKEN }, method: "post", payload: JSON.stringify({ replyToken: replyToken, messages: messages }) }); return ContentService.createTextOutput( JSON.stringify({ content: "post ok" }) ).setMimeType(ContentService.MimeType.JSON); } // 列の中からランダムで項目を返す function getRandomItem(col) { var lastRow = sheet.getLastRow(); var lastCol = sheet.getLastColumn(); var sheetData = sheet.getSheetValues(1, 1, lastRow, lastCol); var colNumber = COL_STRING_TO_NUMBER[col]; var columnVals = sheet.getRange(col + ":" + col).getValues(); var rowLength = columnVals.filter(String).length; return sheetData[getRandomInt(rowLength)][colNumber]; } // 乱数を求める function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } ``` #### 1-4. おまじないの中にある「CHANNEL_ACCESS_TOKEN」を自分用のものに書き換える #### 1-5. おまじないの中にある「SPREAD_SHEET_URL」を自分のスプレッドシートのURLに書き換える ### 2. やるべきことを返すプログラミングをする #### 2-1. 「ファイル」->「New」->「スクリプトファイル」から、新規ファイル「メイン.gs」を作成する #### 2-2. メイン.gsの中身を以下に書き換える ```:javascript /** * LINEに返すメッセージを作成する * @param {string} lineMessage */ function createReply(lineMessage) { // 返信する内容をいれる箱を用意 var replyMessage = ""; // スプレッドシートから取得 var todo = getRandomItem("A"); var list = sheet.getRange("D1").getValue() if (lineMessage == "リスト") { // リストと入力されたときの処理 replyMessage = "現在の登録内容は、こちら!\n" + list; } else { // リスト以外が入力されたときの処理 replyMessage = "「" + todo + "」をすべし!"; } // LINEに返す return replyMessage; } ``` ### 3. プログラムを更新する - 「公開」 => 「ウェブアプリケーションとして導入...」をクリック - バージョンをNewにする - 導入ボタンをクリック - (注意)初回のみ権限を許可にする ![](https://i.imgur.com/7GLDUAc.png) - 「許可を確認」をクリック ![](https://i.imgur.com/PuRzoI7.png) - アカウントを選択 ![](https://i.imgur.com/jtlriej.png) - 「詳細」をクリック ![](https://i.imgur.com/EBdEE1g.png) - xxxx(安全ではないページ)に移動 ![](https://i.imgur.com/ZxGSWbC.png) - 「許可」をクリック ![](https://i.imgur.com/3TyeGgF.png) ![](https://i.imgur.com/6lMuv6k.png) ### 4. LINEと会話してみる - 「リスト」と入力してみる - 「リスト」以外を入力してみる ![IMG_5EBCDBD0AF2A-1.jpeg](https://crowi.jcslabs.net/uploads/attachment/5d92fd2f48525b4b3e33565c/63738ea8d42e6a8385a72e2ac8ba9757.jpeg) ![IMG_06CC63FC06FF-1.jpeg](https://crowi.jcslabs.net/uploads/attachment/5d92fd2f48525b4b3e33565c/7b48f9920921f3b37a794ab575d5b84a.jpeg) --- ## 課題2: やりたいことを増やしてみる ### ゴール 追加したやりたいことが返ってくる ### 1. スプレッドシートのA列にやりたいことを2つ追加して、LINEと会話してみる 例 - 旅行にいく - 買い物に行く ### 2. LINEと会話してみる - 「リスト」と入力してみる - 「リスト」以外を入力してみる --- ## 課題3: 「リスト」と「教えて」以外の会話には反応させない ### ゴール 「リスト」と「教えて」以外の会話をしたら「リストまたは教えてと入力してください」と返ってくるようにする ![IMG_2865.PNG](https://crowi.jcslabs.net/uploads/attachment/5d92fd2f48525b4b3e33565c/06a86f118fe82176fa21fbffb363b95e.PNG) ### 1. 以下のヒントを参考にプログラムを書き換えてみる ヒント1 ```:javascript /* * AとBが同一かどうかの判定 */ if (A == B) { // 同一だったときの処理 } ``` ```:javascript /* * 「もし○○ならば」という条件判定の書き方 */ if (条件A) { // 条件Aをみたしたときの処理 } else if (条件B) { // 条件Aではないが、条件Bをみたしたときの処理 } else { // それ以外の処理 } ``` ヒント2 ``` 後ほど追加 ``` ## 課題4: やりたいことに「誰と」を追加してみる ### ゴール B列の「誰と」とA列の「やりたいこと」がそれぞれランダムでつながって返ってくる 例 A | B --- | --- 野球をしたい | 親と デートしたい | 友達と 焼き肉を食べたい | 恋人と この状態で会話すると、 - 親とデートしたい - 友達と野球をしたい などが返ってくる ![](https://crowi.jcslabs.net/uploads/attachment/5d92fd2f48525b4b3e33565c/c0c9a0049a1302159969dccf97c809d9.jpeg) ### 1. スプレッドシートのB列に「誰と」を入力する 例 - 友達と - 〇〇さんと - 彼女と - 彼氏と - トランプ大統領と - ひとりで ### 2. 以下のヒントを参考にプログラムを書き換えてみる ヒント ```:javascript /* * スプレッドシートの列の中からランダムで返す関数 */ getRandomItem("列名"); // 例 var whois = getRandomItem("B"); // whoisにはB列の中からランダムで選ばれたものが入る ``` ## 課題5: LINEから返ってくるやりたいことを英語に翻訳する ![](https://crowi.jcslabs.net/uploads/attachment/5d92fd2f48525b4b3e33565c/52e9ad05611fe831e97dd17409100369.PNG) ヒント ```:javascript /* * 翻訳するための関数 */ LanguageApp.translate("翻訳したい文章", "前の言語", "後の言語"); // 例 var english = LanguageApp.translate("りんご", "ja", "en"); // englishには"apple"が入る ``` ## 裏課題 ## 裏課題: 教えてもらった数をカウントする ![](https://crowi.jcslabs.net/uploads/attachment/5e39224048525b4b3e3358c3/99cd17b399509566bd4ab06a14208c2b.png) ヒント ```:javascript /* * 値を書き込む */ sheet.getRange("c1").setValue("おはよう"); // c1におはようが書き込まれる ``` ``` /** * LINEに返すメッセージを作成する * @param {string} lineMessage */ function createReply(lineMessage) { // 返信する内容をいれる箱を用意 var replyMessage = ""; // スプレッドシートから取得 var todo = getRandomItem("A"); var list = sheet.getRange("D1").getValue() var count = sheet.getRange("C1").getValue() if (lineMessage == "リスト") { // リストと入力されたときの処理 replyMessage = "現在の登録内容は、こちら!\n" + list; } else if(lineMessage == "教えて") { // リスト以外が入力されたときの処理 replyMessage = "「" + todo + "」をすべし!"; sheet.getRange("c1").setValue(count + 1); } else if (lineMessage == "カウント"){ replyMessage = count } else { replyMessage = "「リスト」または「教えて」と入力してください" } // LINEに返す return replyMessage; } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully