add emoji html junk removing function

emoji in redeem notes now show up as their shortcodes
This commit is contained in:
Lili (Tlapka) 2023-01-09 15:08:33 +01:00
parent 85c4df9250
commit 25589ff69e
2 changed files with 9 additions and 3 deletions

View File

@ -1,7 +1,7 @@
from flask import current_app
import requests
from sqlite3 import Error
from re import sub
# # # requests stuff # # #
def is_stream_live():
@ -27,6 +27,12 @@ def send_chat(message):
r = requests.post(url, headers=headers, json={"body": message})
return r.json()
def remove_emoji(message):
return sub(
r'<img class="emoji" alt="(:.*:)" title=":.*:" src="/img/emoji/.*">',
r'\1',
message
)
# # # db stuff # # #
def read_users_points(db, user_id):

View File

@ -1,7 +1,7 @@
from flask import current_app
from tlapbot.db import get_db
from tlapbot.owncast_helpers import (use_points, add_to_redeem_queue,
add_to_counter, read_users_points, send_chat)
add_to_counter, read_users_points, send_chat, remove_emoji)
def handle_redeem(message, user_id):
@ -39,7 +39,7 @@ def handle_redeem(message, user_id):
if not note:
send_chat(f"Cannot redeem {redeem}, no note included.")
return
if add_to_redeem_queue(db, user_id, redeem, note) and use_points(db, user_id, price):
if add_to_redeem_queue(db, user_id, redeem, remove_emoji(note)) and use_points(db, user_id, price):
send_chat(f"{redeem} redeemed for {price} points.")
else:
send_chat(f"Redeeming {redeem} failed.")