Coder Social home page Coder Social logo

yuseiito / 5374-line Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 3.28 MB

5374.jp for RittoのLINE版🗑 毎日のごみの日情報をLINEで通知します🗓 5374.jp本体のCSVを使用して通知を配信できる仕様になっています。あなたの地域の5374にもLINE版を併せて導入してみませんか?🙌

TypeScript 87.78% JavaScript 11.82% Shell 0.41%
5374 civictech

5374-line's Introduction

5374-line's People

Contributors

dependabot[bot] avatar yuseiito avatar

Stargazers

 avatar

Watchers

 avatar  avatar

5374-line's Issues

リッチメニュー関係のドキュメントを書く

ドキュメントを書く。

含めること

  • リッチメニューとは的なところへのリンク
  • リッチメニューの作り方の説明
  • リッチメニューIDの発行方法の説明と.envへの書き方の説明

確認後の通知登録を実装

確認でYesがきたらユーザIDとエリアと時刻をDBに登録する。
ユーザIDをキーにして、一人一つだけ通知が設定できるようにしたい。

通知情報がDBに乗ればOK

時刻選択後の処理を実装する

処理

  • 時刻のトークンをinvalidateする
  • 確認用の新しいトークンを発行
  • 確認メッセージを返す

確認メッセージこんな感じ

Screen Shot 2020-11-26 at 17 48 51

{
  "type": "template",
  "altText": "this is a confirm template",
  "template": {
    "type": "confirm",
    "actions": [
      {
        "type": "postback",
        "label": "はい",
        "text": "はい",
        "data": "Data 1"
      },
      {
        "type": "postback",
        "label": "いいえ",
        "text": "いいえ",
        "data": "いいえ"
      }
    ],
    "text": "XXエリアのごみ収集情報を毎日00:00にお知らせします。よろしいですか?"
  }
}

AWSに対応する

Details of Improvement

  • AWSに対応したい
  • Lambda + API Gatweway + DynamoDBな構成でAWS CDKからdeployできるようにしたい

エリア選択後の処理を実装する

処理

  • エリア情報のトークンをinvalidateする
  • 時刻選択用のメッセージを返す
  • 新規トークンを発行する
  • postbackにトークンを仕組む
  • postbackに先に選択したエリア情報を仕組む

時刻選択メッセージこんな感じ

{
  "type": "template",
  "altText": "this is a buttons template",
  "template": {
    "type": "buttons",
    "title": "通知を受け取る時刻を設定",
    "text": " その日のごみの収集は8:00までです。8:00以降に設定された場合、翌日の情報を通知します。",
    "actions": [
      {
        "type": "datetimepicker",
        "label": "時刻を選択",
        "data": "Data 1",
        "mode": "time",
        "initial": "07:30",
        "max": "23:59",
        "min": "00:00"
      }
    ]
  }
}

Screen Shot 2020-11-26 at 17 43 25

「通知を設定」テキストへの応答

処理

  • エリア選択のメッセージを返す
  • メッセージにトークンを発行, postbackさせるようにする(一度使ったボタンは使えないようにするため)
  • postbackされてくるトークンを確認する仕様にする(一度使ったボタンにはエラーが帰ってくる仕様にする)

エリア選択メッセージ

{
  "type": "template",
  "altText": "this is a carousel template",
  "template": {
    "type": "carousel",
    "columns": [
      {
        "title": "大宝・大宝東・大宝西・今勝",
        "text": "青色の見出しのごみ収集カレンダーが配布されるエリア",
        "actions": [
          {
            "type": "postback",
            "label": "このエリアを選択",
            "text": "大宝・大宝東・大宝西・今勝エリア",
            "data": "{\"type\":\"selectArea\",\"selectedAreaName\":\"大宝・大宝東・大宝西・金勝エリア\"}}"
          }
        ],
        "imageBackgroundColor": "#002888"
      },
      {
        "title": "治田・治田西・治田東",
        "text": "橙色の見出しのごみ収集カレンダーが配布されるエリア",
        "actions": [
          {
            "type": "postback",
            "label": "このエリアを選択",
            "text": "治田・治田西・治田東エリア",
            "data": "{\"type\":\"selectArea\",\"selectedAreaName\":\"治田・治田西・治田東エリア\"}}"
          }
        ],
        "imageBackgroundColor": "#EA5600"
      },
      {
        "title": "葉山・葉山東",
        "text": "緑色の見出しのごみ収集カレンダーが配布されるエリア",
        "actions": [
          {
            "type": "postback",
            "label": "このエリアを選択",
            "text": "葉山・葉山東エリア",
            "data": "{\"type\":\"selectArea\",\"selectedAreaName\":\"葉山・葉山東エリア\"}}"
          }
        ],
        "imageBackgroundColor": "#058C30"
      }
    ]
  }
}

定期実行する

  • 1minに1回呼ばれる関数を作る
  • 時刻でDBを検索して該当するユーザにpushで通知メッセージを配信

8時を境に変わることを示す

栗東市のごみの収集は8:00まで。

8:00以降に通知を設定すると翌日のごみの日情報が通知されることを時刻選択メッセージで書いておく

eslint入れる

  • そろそろコーディングがしんどくなってきた感があるので

スヌーズの実装

Details of Improvement

ゴミの日情報を通知する時に、[完了] と [スヌーズ]のボタンをつける。
スヌーズを押すと15分,30分,1時間,3時間後に再通知する。

confirmに答える

  • Yesの時

  • 通知データをDBから消す

  • tokenをinvalidate

  • 消したよ! なメッセージを返す

  • Noの時

  • 消さないよ! なメッセージを返す

  • tokenをinvalidate

フォローイベントに対する応答を書く

友達追加されたら

{
  "type": "text",
  "text": "追加ありがとうございます! \n5374.jp @LINE for Rittoは、5374.jp for Ritto (https://ritto.5374.jp for Ritto) で提供しているデータをベースに、滋賀県栗東市のゴミの日情報をLINEで通知するサービスです!\n\nはじめにメニューの「通知の設定」から通知を設定しましょう! \n ※メニューはPC/Mac版LINEではご利用いただけません"
}

な感じのメッセージを送信するようにする。

Preview

Screen Shot 2020-11-26 at 17 18 38

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.