예제 #1
0
def chat_bot(event, thisUser):

  scripts['gan'] = f"{thisUser.name}不要鬧"

  for kw in scripts:
    if(event.message.text == kw):
      return line_bot_api.reply_message(event.reply_token,TextSendMessage(
        text= scripts[kw],
        quick_reply=QUICKREPLY_MENU(event, thisUser)
      ))

  return line_bot_api.reply_message(event.reply_token,TextSendMessage(
    text= f"hello, {thisUser.name}.",
    quick_reply=QUICKREPLY_MENU(event, thisUser)
  ))
예제 #2
0
def send_score_to_sheet(event, thisUser):

    testName = thisUser.memo.split('%')

    thisUser.status = ''
    thisUser.where = ''
    thisUser.memo = ''
    thisUser.save()

    requests.post(env('GAS_ENTRY'),
                  data={
                      'subj':
                      thisUser.job if len(testName) == 1 else testName[1],
                      'name': testName[0],
                      'scores': string_to_scores_list(event.message.text)
                  })

    url = 'https://docs.google.com/spreadsheets/d/1OUR9r-VDK834KXHBubOWS1EqXB3Tre07q7HKXHxSYFE/edit?usp=sharing'

    return line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(
            text=f"成績已送出(表單需要一點時間更新)\n{url}",
            quick_reply=QUICKREPLY_MENU(event, thisUser),
        ))
예제 #3
0
def score_main(event, thisUser):
    thisUser.where = 'score'
    thisUser.status = 'wfi_testName'
    thisUser.save()

    return line_bot_api.reply_message(event.reply_token,
                                      TextSendMessage(text="請輸入考試名稱 :"))
예제 #4
0
def score_registerJob(event, thisUser):
    thisUser.where = 'score'
    thisUser.status = 'wfi_job'
    thisUser.save()

    return line_bot_api.reply_message(event.reply_token,
                                      TextSendMessage(text="請輸入小老師名稱 :"))
예제 #5
0
def chat_bot_group(event):
  for kw in scripts:
    if(event.message.text == kw):
      return line_bot_api.reply_message(event.reply_token,TextSendMessage(
        text= scripts[kw],
      ))

  return
예제 #6
0
def bike(event, thisUser):
  url = 'https://data.tycg.gov.tw/api/v1/rest/datastore/a1b4714b-3b75-4ff8-a8f2-cc377e4eaa0f?format=json'

  resp = requests.get(url)
  data = resp.json()['result']['records'][1]
  update = data['mday'][8:]

  result = f"""車子數量 : {data['sbi']}
空位 : {data['bemp']}
最後更新時間 : {update[:2]}:{update[2:4]}:{update[4:]}"""

  if event.source.type == 'group':
    return line_bot_api.reply_message(event.reply_token,TextSendMessage(
      text= result
    ))

  return line_bot_api.reply_message(event.reply_token,TextSendMessage(
    text= result,
    quick_reply=QUICKREPLY_MENU(event, thisUser)
  ))
예제 #7
0
def score_applyJob(event, thisUser):
    thisUser.where = ''
    thisUser.status = ''
    thisUser.job = event.message.text
    thisUser.save()

    return line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(
            text="登記完成 !",
            quick_reply=QUICKREPLY_MENU(event, thisUser),
        ))
예제 #8
0
def register(event, thisUser):
    try:
        number, name = event.message.text.split()
        number = int(number)

        thisUser.number = number
        thisUser.name = name

    except:
        return line_bot_api.reply_message(
            event.reply_token, TextSendMessage(text="出現問題, 請重新輸入 :"))

    thisUser.status = ""
    thisUser.where = ""
    thisUser.save()

    return line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(
            text="已建檔完成 !",
            quick_reply=QUICKREPLY_MENU(event, thisUser),
        ))
예제 #9
0
def score_gi_main(event, thisUser):
    if thisUser.status == 'wfi_testName':

        thisUser.status = 'wfi_testScores'
        thisUser.memo = event.message.text
        thisUser.save()

        return line_bot_api.reply_message(event.reply_token,
                                          TextSendMessage(text="請輸入成績 :"))

    if thisUser.status == 'wfi_testScores':
        return send_score_to_sheet(event, thisUser)

    if thisUser.status == 'wfi_job':
        return score_applyJob(event, thisUser)
예제 #10
0
def help(event, thisUser):
  return line_bot_api.reply_message(event.reply_token,TextSendMessage(
    text= """bike : 取得校門口Ubike資訊""",
    quick_reply= QUICKREPLY_MENU(event, thisUser)
  ))