add customizable prefix
This commit is contained in:
parent
a5463c09ee
commit
3caaed4b35
|
@ -4,4 +4,5 @@ OWNCAST_INSTANCE_URL='http://localhost:8080'
|
||||||
POINTS_CYCLE_TIME=600
|
POINTS_CYCLE_TIME=600
|
||||||
POINTS_AMOUNT_GIVEN=10
|
POINTS_AMOUNT_GIVEN=10
|
||||||
LIST_REDEEMS=False
|
LIST_REDEEMS=False
|
||||||
GUNICORN=False
|
GUNICORN=False
|
||||||
|
PREFIX='!'
|
|
@ -30,22 +30,23 @@ def owncast_webhook():
|
||||||
if data["eventData"]["user"]["authenticated"]:
|
if data["eventData"]["user"]["authenticated"]:
|
||||||
remove_duplicate_usernames(db, user_id, new_name)
|
remove_duplicate_usernames(db, user_id, new_name)
|
||||||
elif data["type"] == "CHAT":
|
elif data["type"] == "CHAT":
|
||||||
|
prefix = current_app.config['PREFIX']
|
||||||
user_id = data["eventData"]["user"]["id"]
|
user_id = data["eventData"]["user"]["id"]
|
||||||
display_name = data["eventData"]["user"]["displayName"]
|
display_name = data["eventData"]["user"]["displayName"]
|
||||||
current_app.logger.debug(f'New chat message from {display_name}:')
|
current_app.logger.debug(f'New chat message from {display_name}:')
|
||||||
current_app.logger.debug(f'{data["eventData"]["body"]}')
|
current_app.logger.debug(f'{data["eventData"]["body"]}')
|
||||||
if data["eventData"]["body"].startswith("!help"):
|
if data["eventData"]["body"].startswith(f"{prefix}help"):
|
||||||
send_help()
|
send_help()
|
||||||
elif data["eventData"]["body"].startswith("!points"):
|
elif data["eventData"]["body"].startswith(f"{prefix}points"):
|
||||||
points = read_users_points(db, user_id)
|
points = read_users_points(db, user_id)
|
||||||
send_chat(f"{display_name}'s points: {points}")
|
send_chat(f"{display_name}'s points: {points}")
|
||||||
elif data["eventData"]["body"].startswith("!name_update"):
|
elif data["eventData"]["body"].startswith(f"{prefix}name_update"):
|
||||||
# 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. Also removes saved usernames from users with same name
|
# event. Also removes saved usernames from users with same name
|
||||||
# if user is authenticated.
|
# 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"]:
|
if data["eventData"]["user"]["authenticated"]:
|
||||||
remove_duplicate_usernames(db, user_id, display_name)
|
remove_duplicate_usernames(db, user_id, display_name)
|
||||||
elif data["eventData"]["body"].startswith("!"): # TODO: make prefix configurable
|
elif data["eventData"]["body"].startswith(prefix): # 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