Bladeren bron

Removed subscriber and donation alerts, since kofi provides those already. Removed _ALERT from alert browser source end points

deadtom 5 dagen geleden
bovenliggende
commit
4edb10e1a8

+ 2 - 2
ownchatbot/bot_messages.py

@@ -169,7 +169,7 @@ def save_announce(announce_dict):  # Write rewards to announce.py
     new_announce = f"ANNOUNCEMENTS = {announce_dict['ANNOUNCEMENTS']}  # List of announcements\n\n\
 ANNOUNCE_ENABLE = {announce_dict['ANNOUNCE_ENABLE']}  # Enable announcements\n\
 ANNOUNCE_INTERVAL = {announce_dict['ANNOUNCE_INTERVAL']}  # How long, in minutes, between points announcements"
-    
+
     try:
         with open(announce_file, 'w') as f:
             f.write(new_announce)
@@ -177,6 +177,6 @@ ANNOUNCE_INTERVAL = {announce_dict['ANNOUNCE_INTERVAL']}  # How long, in minutes
     except Exception as saerror:
         current_app.logger.error(f'Couldn\'t save announce.py: {saerror.args[0]}')
         return False
-    
+
     current_app.config.from_pyfile('announce.py', silent=True)
     return True

+ 0 - 59
ownchatbot/templates/donation.html

@@ -1,59 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<!-- Polls the check_donations route every three seconds. When a new donation is found,
-the alert is displayed for ten seconds. -->
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <link rel="stylesheet" href="{{ url_for('static', filename='alertstyle.css') }}">
-    <title>New Donation Alert</title>
-</head>
-<body>
-    {% if not alert_name %}
-        <div id="alertVid"></div>
-        <div id="alertImg"></div>
-    {% elif "webm" in alert_name %}
-        <video id="alertVid" autoplay>
-            <source src="{{ url_for('web_panels.alerts', alert_name=alert_name) }}" type="video/webm">
-        </video>
-        <div id="alertImg"></div>
-    {% else %}
-        <div id="alertVid"></div>
-        <img id="alertImg" src="{{ url_for('web_panels.alerts', alert_name=alert_name) }}">
-    {% endif %}
-
-    <div id="textBox"></div>
-
-    <script>
-        setInterval(function() {
-            fetch('/checkDonations')
-                .then(response => response.json())
-                .then(data => {
-                    if (data) {
-                        const alertVid = document.getElementById('alertVid');
-                        const alertImg = document.getElementById('alertImg');
-                        const textBox = document.getElementById('textBox');
-
-                        const donationName = data.name;
-                        const donationAmount = data.amount;
-
-                        textBox.innerHTML = `
-                            ${donationName}<br>
-                            $${donationAmount}
-                        `;
-                        textBox.style.display = 'block';
-
-                        alertVid.style.display = 'block';
-                        alertImg.style.display = 'block';
-
-                        setTimeout(() => {
-                            alertVid.style.display = 'none';
-                            alertImg.style.display = 'none';
-                            textBox.style.display = 'none';
-                        }, 10000); // Visible for 10 seconds
-                    }
-                });
-        }, 3000); // Check for new donations every 3 seconds
-    </script>
-</body>
-</html>

+ 1 - 2
ownchatbot/templates/follower.html

@@ -35,10 +35,9 @@ the alert is displayed for ten seconds. -->
                         const textBox = document.getElementById('textBox');
 
                         const followerName = data.name;
-                        const rewardName = data.reward;
 
                         textBox.innerHTML = `
-                            ${rewardName}<br>${followerName}
+                            ${followerName}
                         `;
                         textBox.style.display = 'block';
 

+ 3 - 39
ownchatbot/templates/mgmt.html

@@ -492,7 +492,7 @@
                     <td><button id="nf_upload" class="button button2" type="submit">Upload</button>
                     </form>&nbsp
                         <a href="{{ url_for('web_panels.del_alert', alert_type='FOLLOWER_ALERT') }}"><button class="button button2" onclick="openTab(event, 'alerts')"><span style="color: red;">Clear</span></button></a></td>
-                    <td>/ocbalert/follower_alert</td>
+                    <td>/alert/follower</td>
                 </tr>
                 <tr>
                     <form id="nms_upload" action="/mgmt/alertupload/MILESTONE_ALERT" method="post" enctype="multipart/form-data">
@@ -510,7 +510,7 @@
                     <td><input type="file" name="MILESTONE_ALERT" accept=".gif, .jpg, .jpeg, .png, .webm" required></td>
                     <td><button id="nms_upload" class="button button2" type="submit">Upload</button></form>&nbsp
                         <a href="{{ url_for('web_panels.del_alert', alert_type='MILESTONE_ALERT') }}"><button class="button button2" onclick="openTab(event, 'alerts')"><span style="color: red;">Clear</span></button></a></td>
-                    <td>/ocbalert/milestone_alert</td>
+                    <td>/alert/milestone</td>
                 </tr>
                 <tr>
                     <form id="ng_upload" action="/mgmt/alertupload/GOAL_ALERT" method="post" enctype="multipart/form-data">
@@ -528,43 +528,7 @@
                     <td><input type="file" name="GOAL_ALERT" accept=".gif, .jpg, .jpeg, .png, .webm" required></td>
                     <td><button id="ng_upload" class="button button2" type="submit">Upload</button></form>&nbsp
                         <a href="{{ url_for('web_panels.del_alert', alert_type='GOAL_ALERT') }}"><button class="button button2" onclick="openTab(event, 'alerts')"><span style="color: red;">Clear</span></button></a></td>
-                    <td>/ocbalert/goal_alert</td>
-                </tr>
-                <tr>
-                    <form id="nd_upload" action="/mgmt/alertupload/DONATION_ALERT" method="post" enctype="multipart/form-data">
-                    <td>Donation:</td>
-                    {% set donation_alert = alerts_dict["DONATION_ALERT"] %}
-                    {% if donation_alert %}
-                        {% if "webm" in donation_alert %}
-                            <td><video height="100" autoplay loop><source src="{{ url_for('web_panels.alerts', alert_name=donation_alert) }}" type="video/webm"></video></td>
-                        {% else %}
-                            <td><img src="{{ url_for('web_panels.alerts', alert_name=donation_alert) }}"></td>
-                        {% endif %}
-                    {% else %}
-                        <td>Empty</td>
-                    {% endif %}
-                    <td><input type="file" name="DONATION_ALERT" accept=".gif, .jpg, .jpeg, .png, .webm" required></td>
-                    <td><button id="nd_upload" class="button button2" type="submit">Upload</button></form>&nbsp
-                        <a href="{{ url_for('web_panels.del_alert', alert_type='DONATION_ALERT') }}"><button class="button button2" onclick="openTab(event, 'alerts')"><span style="color: red;">Clear</span></button></a></td>
-                    <td>/ocbalert/donation_alert</td>
-                </tr>
-                <tr>
-                    <form id="nd_upload" action="/mgmt/alertupload/SUBSCRIBER_ALERT" method="post" enctype="multipart/form-data">
-                    <td>Subscriber:</td>
-                    {% set subscriber_alert = alerts_dict["SUBSCRIBER_ALERT"] %}
-                    {% if subscriber_alert %}
-                        {% if "webm" in subscriber_alert %}
-                            <td><video height="100" autoplay loop><source src="{{ url_for('web_panels.alerts', alert_name=subscriber_alert) }}" type="video/webm"></video></td>
-                        {% else %}
-                            <td><img src="{{ url_for('web_panels.alerts', alert_name=subscriber_alert) }}"></td>
-                        {% endif %}
-                    {% else %}
-                        <td>Empty</td>
-                    {% endif %}
-                    <td><input type="file" name="SUBSCRIBER_ALERT" accept=".gif, .jpg, .jpeg, .png, .webm" required></td>
-                    <td><button id="nd_upload" class="button button2" type="submit">Upload</button></form>&nbsp
-                        <a href="{{ url_for('web_panels.del_alert', alert_type='SUBSCRIBER_ALERT') }}"><button class="button button2" onclick="openTab(event, 'alerts')"><span style="color: red;">Clear</span></button></a></td>
-                    <td>/ocbalert/subscriber_alert</td>
+                    <td>/alert/goal</td>
                 </tr>
         </table>
         </body>

+ 1 - 2
ownchatbot/templates/rgoal.html

@@ -35,10 +35,9 @@ the alert is displayed for ten seconds. -->
                         const textBox = document.getElementById('textBox');
 
                         const alertName = data.name;
-                        const rewardName = data.reward;
 
                         textBox.innerHTML = `
-                            ${rewardName}<br>${alertName}
+                            ${alertName}
                         `;
                         textBox.style.display = 'block';
 

+ 1 - 2
ownchatbot/templates/rmilestone.html

@@ -35,10 +35,9 @@ the alert is displayed for ten seconds. -->
                         const textBox = document.getElementById('textBox');
 
                         const alertName = data.name;
-                        const rewardName = data.reward;
 
                         textBox.innerHTML = `
-                            ${rewardName}<br>${alertName}
+                            ${alertName}
                         `;
                         textBox.style.display = 'block';
 

+ 0 - 59
ownchatbot/templates/subscriber.html

@@ -1,59 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<!-- Polls the check_subscribers route every three seconds. When a new subscriber is found,
-the alert is displayed for ten seconds. -->
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <link rel="stylesheet" href="{{ url_for('static', filename='alertstyle.css') }}">
-    <title>New Subscriber Alert</title>
-</head>
-<body>
-    {% if not alert_name %}
-        <div id="alertVid"></div>
-        <div id="alertImg"></div>
-    {% elif "webm" in alert_name %}
-        <video id="alertVid" autoplay>
-            <source src="{{ url_for('web_panels.alerts', alert_name=alert_name) }}" type="video/webm">
-        </video>
-        <div id="alertImg"></div>
-    {% else %}
-        <div id="alertVid"></div>
-        <img id="alertImg" src="{{ url_for('web_panels.alerts', alert_name=alert_name) }}">
-    {% endif %}
-
-    <div id="textBox"></div>
-
-    <script>
-        setInterval(function() {
-            fetch('/checkSubscribers')
-                .then(response => response.json())
-                .then(data => {
-                    if (data) {
-                        const alertVid = document.getElementById('alertVid');
-                        const alertImg = document.getElementById('alertImg');
-                        const textBox = document.getElementById('textBox');
-
-                        const subscriberName = data.name;
-                        const subscriberTier = data.tiername;
-
-                        textBox.innerHTML = `
-                            ${subscriberName}<br>
-                            ${subscriberTier} subscriber
-                        `;
-                        textBox.style.display = 'block';
-
-                        alertVid.style.display = 'block';
-                        alertImg.style.display = 'block';
-
-                        setTimeout(() => {
-                            alertVid.style.display = 'none';
-                            alertImg.style.display = 'none';
-                            textBox.style.display = 'none';
-                        }, 10000); // Visible for 10 seconds
-                    }
-                });
-        }, 3000); // Check for new subscribers every 3 seconds
-    </script>
-</body>
-</html>

+ 2 - 8
ownchatbot/web_panels.py

@@ -674,9 +674,9 @@ def alerts(alert_name):
     return send_from_directory(current_app.config['ALERTS_FOLDER'], alert_name)
 
 
-@ocb.route('/ocbalert/<alert_type>')  # Route for alerts overlay
+@ocb.route('/alert/<alert_type>')  # Route for alerts overlay
 def ocb_alert(alert_type):
-    alert_type = alert_type.upper()
+    alert_type = alert_type.upper()+'_ALERT'
     alerts_dict = current_app.config['ALERTS']
     try:
         alert_name = alerts_dict[alert_type]
@@ -686,12 +686,6 @@ def ocb_alert(alert_type):
     if alert_type == 'FOLLOWER_ALERT':
         return render_template('follower.html',
                                alert_name=alert_name)
-    elif alert_type == 'DONATION_ALERT':
-        return render_template('donation.html',
-                               alert_name=alert_name)
-    elif alert_type == 'SUBSCRIBER_ALERT':
-        return render_template('subscriber.html',
-                               alert_name=alert_name)
     elif alert_type == 'MILESTONE_ALERT':
         return render_template('rmilestone.html',
                                alert_name=alert_name)

+ 0 - 22
ownchatbot/webhooks.py

@@ -207,25 +207,3 @@ def check_milestones():
     else:
         current_app.logger.debug(f'No new milestones passed')
     return jsonify(None)
-
-
-@ocb.route('/checkDonations')  # Polled by donation.html template to check for new kofi donations
-def check_donations():
-    if donations:
-        current_app.logger.info(f'\n\n{format(donations)}\n\n')
-        last_donation = donations.clear()
-        return jsonify(last_donation)
-    else:
-        current_app.logger.debug(f'No new donations')
-    return jsonify(None)
-
-
-@ocb.route('/checkSubscribers')  # Polled by subscriber.html template to check for new kofi subscribers
-def check_subscribers():
-    if subscribers:
-        current_app.logger.info(f'\n\n{format(subscribers)}\n\n')
-        last_subscriber = subscribers.clear()
-        return jsonify(last_subscriber)
-    else:
-        current_app.logger.debug(f'No new subscribers')
-    return jsonify(None)