add duplicate name removal to webhook catcher
This commit is contained in:
parent
95acd70b85
commit
6ec8a31100
|
@ -17,10 +17,14 @@ def owncast_webhook():
|
||||||
display_name = data["eventData"]["user"]["displayName"]
|
display_name = data["eventData"]["user"]["displayName"]
|
||||||
# CONSIDER: join points for joining stream
|
# CONSIDER: join points for joining stream
|
||||||
add_user_to_database(db, user_id, display_name)
|
add_user_to_database(db, user_id, display_name)
|
||||||
|
if data["eventData"]["user"]["authenticated"]:
|
||||||
|
remove_duplicate_usernames(db, user_id, display_name)
|
||||||
elif data["type"] == "NAME_CHANGE":
|
elif data["type"] == "NAME_CHANGE":
|
||||||
user_id = data["eventData"]["user"]["id"]
|
user_id = data["eventData"]["user"]["id"]
|
||||||
new_name = data["eventData"]["newName"]
|
new_name = data["eventData"]["newName"]
|
||||||
change_display_name(db, user_id, new_name)
|
change_display_name(db, user_id, new_name)
|
||||||
|
if data["eventData"]["user"]["authenticated"]:
|
||||||
|
remove_duplicate_usernames(db, user_id, display_name)
|
||||||
elif data["type"] == "CHAT":
|
elif data["type"] == "CHAT":
|
||||||
user_id = data["eventData"]["user"]["id"]
|
user_id = data["eventData"]["user"]["id"]
|
||||||
display_name = data["eventData"]["user"]["displayName"]
|
display_name = data["eventData"]["user"]["displayName"]
|
||||||
|
@ -44,8 +48,11 @@ def owncast_webhook():
|
||||||
send_chat(message)
|
send_chat(message)
|
||||||
elif "!name_update" in data["eventData"]["body"]:
|
elif "!name_update" in data["eventData"]["body"]:
|
||||||
# Forces name update in case bot didn't catch the NAME_CHANGE
|
# Forces name update in case bot didn't catch the NAME_CHANGE
|
||||||
# event. Theoretically only needed when bot was off.
|
# event. Also removes saved usernames from users with same name
|
||||||
|
# if user is authenticated.
|
||||||
change_display_name(db, user_id, display_name)
|
change_display_name(db, user_id, display_name)
|
||||||
|
if data["eventData"]["user"]["authenticated"]:
|
||||||
|
remove_duplicate_usernames(db, user_id, display_name)
|
||||||
elif data["eventData"]["body"].startswith("!"): # TODO: make prefix configurable
|
elif data["eventData"]["body"].startswith("!"): # TODO: make prefix configurable
|
||||||
handle_redeem(data["eventData"]["body"], user_id)
|
handle_redeem(data["eventData"]["body"], user_id)
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Reference in New Issue