Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
add register requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
hyder308116 committed Nov 15, 2022
1 parent 461fabf commit 307963e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ def write_db() -> None:
# with open("stations.json", "w", newline="\n", encoding="utf-8") as json_file:
# json.dump(tmp_stations, json_file, ensure_ascii=False, indent=4)

def registered(uid: str) -> bool:
global Teams
return uid in Teams.keys()


@app.route("/callback", methods=['POST'])
def callback():
Expand All @@ -173,7 +177,6 @@ def callback():

return 'OK'


@handler.add(MessageEvent, message=TextMessage)
def getCommand(event: MessageEvent):
# Ignore Line's verify message
Expand Down Expand Up @@ -204,6 +207,14 @@ def getCommand(event: MessageEvent):
msgs.append(TextSendMessage(
text=f"已成功註冊為「{args[1]}」"
))

elif not registered(event.source.user_id):
msgs.append(TextSendMessage(text=(
"你還沒註冊喔!\n"
"指令格式: register <team name>\n"
"範例: register 第一組\n"
"備註: 隊伍名稱不能含有空白、換行"
)))

elif cmd == "leaderboard" or cmd == "Leaderboard" or cmd == "l" or cmd == "L":
# Show leaderboard & status of each question
Expand Down

0 comments on commit 307963e

Please sign in to comment.