philip-zhan / badminton-group

3 stars 0 forks source link

Adding wechat bot #15

Open t3rryw1 opened 3 years ago

t3rryw1 commented 3 years ago

Explore existing solutions and see how it can fit into our codebase

philip-zhan commented 3 years ago

Some ideas:

t3rryw1 commented 3 years ago

yes looks like wechaty is the way to go.

On Tue, Sep 28, 2021 at 2:01 PM Philip Zhan @.***> wrote:

Some ideas:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/philip-zhan/badminton-group/issues/15#issuecomment-929621901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2Q2HH7UNRHH3SJ2IIC4TUEIUMBANCNFSM5E3ELVUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- -Thanks

Terry .Wang Web Developer

philip-zhan commented 3 years ago

Ideas about bot workflow:

  1. 群主通过web UI创建event
  2. 群主把event链接放入群公告
  3. bot监听@botkeyword and get event ID from群公告

Terry:

@bot 报名单打

bot:

Mon Oct 4 Stage 18 8:00 PM - 10:00 PM Single (12)

  1. Terry

Double (12)

Phil:

@bot 报名双打

bot:

Mon Oct 4 Stage 18 8:00 PM - 10:00 PM Single (12)

  1. Terry

Double (12)

  1. Phil

Phil:

@bot 取消双打

bot:

Mon Oct 4 Stage 18 8:00 PM - 10:00 PM Single (12)

  1. Terry

Double (12)

t3rryw1 commented 3 years ago

We can simplify the workflow to:

  1. Event created in Web UI, and linked to a certain wechat group (possibly by its group id)
  2. Bot sit in the wechat group and wait for trigger commands like ++, ++1, ++2, --1, --2
  3. when message is received by bot, bots does the following:
    1. check if meesage is received from a group context.
    2. check if message content matches any command
    3. grab group id, name, command and user id from the message
    4. request flask REST API with the data above.
    5. REST API check if the group matches any active event, along with other checks, and return error if check fails.
    6. Otherwise return success with event link or event detail text.
    7. bot process API return and reply user with corresponding content.
t3rryw1 commented 3 years ago

Currently only one API endpoint Event Signup/retreat is needed for the above operation. Fields needed for this operation include:

  1. name
  2. number of spots asked
  3. operation ( signup/retreat)
  4. group id
  5. user id

Draft response fields include:

  • success: boolean
  • error: object
  • event: object