| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 | <!DOCTYPE html><html lang="en"><head>    <title>OCB Management Panel</title>    <link rel="icon" type="image/x-icon" href="/static/img/favicon.ico">    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"></head>    <script src="/static/mgmtpanel.js"></script>        <div class="navbar">        <div class="tab">            <button class="tablinks" data-tab="queue" onclick="openTab(event, 'queue')">Queue</button>            <button class="tablinks" data-tab="accounts" onclick="openTab(event, 'accounts')">Manage Accounts</button>            <button class="tablinks" data-tab="managerewards" onclick="openTab(event, 'managerewards')">Rewards</button>            <button class="tablinks" data-tab="categories" onclick="openTab(event, 'categories')">Categories</button>            <button class="tablinks" data-tab="announcements" onclick="openTab(event, 'announcements')">Announcements</button>            <button class="tablinks" data-tab="settings" onclick="openTab(event, 'settings')">Settings</button>            {% if kofi_integration %}                <button class="tablinks" data-tab="kofi-settings" onclick="openTab(event, 'kofi-settings')">Kofi Settings</button>            {% endif %}        </div>        <img src="/static/img/ownchatbotwide.png">    </div>        <div id='queue' class="tabcontent">        <body>            {% if votes %}            <table>                <thead>                    <tr>                        <th style="width: 20%;">Active Votes</th>                        <th style="width: 40%;">Description</th>                        <th style="width: 20%;">Price</th>                        <th style="width: 20%;">Current Tally</th>                        <th></th>                    </tr>                </thead>                <tbody>                {% for vote in votes %}                    <tr>                        <td> {{ prefix }}{{ vote[0] }} </td>                        <td> {{ vote[2] }} </td>                                                {% set points_label = 'point' if rewards[vote[0]]["price"] == 1 else 'points' %}                        <td> {{ rewards[vote[0]]["price"] }} {{ points_label }}</td>                                                {% set votes_label = 'vote' if vote[1] == 1 else 'votes' %}                                                <td> {{ vote[1] }} {{ votes_label }}</td>                        <td></td>                    </tr>                {% endfor %}                </tbody>            </table>            {% else %}            <h3> You currently have no active votes. </h3>            {% endif %}            <br>            <hr>            {% if goals %}            <table>                <thead>                    <tr>                        <th style="width: 20%;">Active Goals</th>                        <th style="width: 40%;">Description</th>                        <th style="width: 25%;">Progress</th>                        <th></th>                    </tr>                </thead>                <tbody>                {% for goal in goals %}                    <tr>                        <td> {{ prefix }}{{ goal[0] }} </td>                        <td> {{ goal[3] }} </td>                        {% set progress = goal[1] / goal[2] * 100 %}                        <td>                            <div class="bar-light-grey bar-tiny bar-round" style="position: relative;">                                <div class="bar-round bar-blue" style="text-align: center; width:{{ progress }}%;">{{ '%0.0f'| format(progress| float) }}%                                </div>                                {% set milestones = rewards[goal[0]]["milestones"] %}                                {% for milestone_key, milestone in milestones.items() %}                                    {% if milestones[milestone_key][0] and milestones[milestone_key][1] %}                                        {% if milestones[milestone_key][1] < goal[2] %}                                            {% set milestone_progress = milestones[milestone_key][1] / goal[2] * 100 %}                                                <div class="milestone-marker" style="position: absolute; left: {{ milestone_progress }}%; transform: translateX(-50%);">                                                    <img src="/static/img/milestone.png" style="width: 16px; height: 16px;" title="{{ milestones[milestone_key][1] }} points. {{ milestones[milestone_key][0] }}">                                                </div>                                            {% endif %}                                        {% endif %}                                    {% endfor %}                            </div>                        </td>                                                {% if goal[1] == goal[2] %}                        <td> {{ goal[1] }} / {{ goal[2] }} <img src=/static/img/tada.png style="width: 24px; height: 24px;"></td>                        {% else %}                        <td> {{ goal[1] }} / {{ goal[2] }} </td>                        {% endif %}                    </tr>                {% endfor %}                    <tr style="border-bottom: none;">                        <td>                        </td>                        <td>                        </td>                        <td style="font-size: small;">                            (Mouse over flags for milestone details)                        </td>                    </tr>                </tbody>            </table>            {% else %}            <h3> You currently have no active goals. </h3>            {% endif %}            <hr>            <h3>Redeems Queue</h3>            {% if queue %}            <a href="/mgmt/clearfulfilled"><button class="button button2" onclick="openTab(event, 'queue')">Clear Fullfilled Rewards</button></a>  <a href="/mgmt/clearqueue"><button class="button button2" onclick="openTab(event, 'queue')">Clear All Rewards</button></a>            <table>                <thead>                    <tr>                        <th>Time</th>                        <th>Reward</th>                        <th>User</th>                        <th></th>                    </tr>                </thead>                <tbody>                {% for row in queue %}                    <tr>                        <td>{{ row[1].replace(tzinfo=utc_timezone).astimezone().strftime("%H:%M") }}</td>                        {% if row[4] %}                        <td><s>{{ rewards[row[2]]["info"] }}</s></td>                        {% else %}                        <td>{{ rewards[row[2]]["info"] }}</td>                        {% endif %}                        <td>{{ row[6] }}</td>                        {% if row[4] %}                        {% if row[5] %}                        <td>Refunded</td>                        {% else %}                        <td><a href="/mgmt/refund?reward={{ row[2] }}&username={{ row[6] }}&rewarder_id={{ row[3] }}&reward_id={{ row[0] }} "><button class="button button2" onclick="openTab(event, 'queue')">Refund</button></a></td>                        {% endif %}                        {% else %}                        <td><a href="/mgmt/fulfill?reward_id={{ row[0] }}&username={{ row[6] }}"><button class="button button2" onclick="openTab(event, 'queue')">Fulfill</button></a></td>                        {% endif %}                    </tr>                {% endfor %}                </tbody>            </table>            {% else %}            <p>There are currently no rewards waiting in the queue.</p>            {% endif %}        </body>    </div>    <div id='accounts' class="tabcontent">        <body>            <h3>Manage Viewer Accounts</h3>            {% if users %}            <table>                <thead>                    <tr>                        <th>User</th>                        <th>Points balance</th>                        <th>Email</th>                        <th></th>                    </tr>                </thead>                <tbody>                {% for user in users %}                    <tr>                        <td> {{ user[1] }} </td>                        {% set points_label = 'point' if user[2] == 1 else 'points' %}                                                <td>{{ user[2] }} {{ points_label }}</td>                        {% if user[4] %}                            <td>{{ user[4] }}</td>                        {% else %}                            <td>none</td>                        {% endif %}                        <td> <a href="/mgmt/edit_account/{{ user[0] }}?name={{ user[1] }}&points={{ user[2] }}&email={{ user[4] }}"><button class="button button2" onclick="openTab(event, 'panel')">Edit</button></a> </td>                    </tr>                {% endfor %}                </tbody>            </table>            {% endif %}        </body>    </div>    <div id='managerewards' class="tabcontent">        <h3>Manage Rewards</h3>        <body>        <div>        <h4>Reward Types:</h4>        <ul>                        <li><u>Redeems</u> are standard stream point redeems. They get added to the queue for the streamer to fulfill.</li>            <li><u>Specials</u> are redeems, but they run system commands and scripts. This enables you to integrate a lot of other fun things, such as letting your viewers control lighting, activate devices, trigger webhooks, etc. Specials do not go into the queue, because they happen automagically.</li>              <ul>                <li>Be careful with this one. It does require some more advanced scripting/command line knowledge. Make sure you test your specials before letting viewers use them.</li>              </ul>            <li><u>Votes</u> are just that, votes. Your viewers can vote on them.</li>            <li><u>Goals</u> are rewards that everyone in chat can contribute to. The streamer fulfills the reward when the goal is reached.</li>            <li>Add rewards to categories to enable and disable groups of rewards.</li>            <li>Rewards with no categories are inactive.</li>        </ul>        </div>            <table>                <tr>                    <td>                    </td>                    <td>                    </td>                    <td>                    </td>                    <td>                    </td>                </tr>                <tr>                    <td>                        <a href="{{ url_for('web_panels.add', reward_type='redeem') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Redeem</button></a><br>                    </td>                    <td>                        <a href="{{ url_for('web_panels.add', reward_type='special') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Special</button></a><br>                    </td>                    <td>                        <a href="{{ url_for('web_panels.add', reward_type='vote') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Vote</button></a><br>                    </td>                    <td>                        <a href="{{ url_for('web_panels.add', reward_type='goal') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Goal</button></a><br>                    </td>                </tr>            </table>            <br>            {% if rewards %}            Rewards in <span style="color: red !important;">red</span> are inactive. To activate a reward, add it to an active category.            <table>                <thead>                    <tr>                        <th style="width:15%">Name</th>                        <th>Target</th>                        <th>Price</th>                        <th>Info</th>                        <th>Cool down</th>                        <th>Category</th>                        <th style="width:15%">Actions</th>                    </tr>                </thead>                <tbody>                {% for reward, reward_info in rewards.items() %}                    {% if reward in active_rewards %}                    <tr>                    {% else %}                    <tr style="color: red;">                    {% endif %}                        <td>{{ prefix }}{{ reward }}</td>                        {% if reward_info["type"] == "goal" %}                        <td>{{ reward_info["target"] }}</td>                        {% else %}                        <td>N/A</td>                        {% endif %}                        {% if reward_info["type"] == "goal" %}                        <td>N/A</td>                        {% else %}                        <td>{{ reward_info["price"] }}</td>                        {% endif %}                        <td>{{ reward_info["info"] }}</td>                        {% if reward_info["cooldown"] > 0 %}                        {% set minutes_label = 'minute' if reward_info["cooldown"] == 1 else 'minutes' %}                        <td>{{ reward_info["cooldown"] }} {{ minutes_label }}</td>                        {% else %}                        <td>None</td>                        {% endif %}                        <td>{{ reward_info["categories"] | join(', ') }}</td>                        <td>                            <a href="{{ url_for('web_panels.edit', reward_name=reward) }}"><button class="button button2" onclick="openTab(event, 'managerewards')"><span style="color: green;">Edit</span></button></a>                             <a href="{{ url_for('web_panels.delete', reward_name=reward) }}"><button class="button button2" onclick="openTab(event, 'managerewards')"><span style="color: red;">Delete</span></button></a>                                                         {% if reward_info["type"] == "goal" or reward_info["type"] == "vote"  %}                            <a href="{{ url_for('web_panels.reset', reward_name=reward, reward_type=reward_info["type"]) }}"><button class="button button2" onclick="openTab(event, 'managerewards')"><span style="color: orange;">Reset</span></button></a>                            {% endif %}                        </td>                    </tr>                {% endfor %}                </tbody>            </table>            {% endif %}        </body>    </div>    <div id='categories' class="tabcontent">        <body>        <h3>Manage Categories</h3>        <div>              <a href="{{ url_for('web_panels.add', reward_type='category') }}"><button class="button button2" onclick="openTab(event, 'categories')">Create a new category</button></a><br>            <table>                <thead>                    <tr>                        <th style="width: 50%;"><h3>Active Categories</h3></th>                        <th style="width: 50%;"><h3>Inactive Categories</h3></th>                    </tr>                </thead>                <tbody>                    <tr>                        <td>                            {% for cat in active_categories %}                              {{ cat }} - <a href="/mgmt/deactivate/{{ cat }}"><span style="color: green;">Deactivate</span></a> <a href="/mgmt/delcat/{{ cat }}/active"><span style="color: red;">Delete</span></a><br>                            {% endfor %}                        </td>                        <td>                            {% for cat in inactive_categories %}                              {{ cat }} - <a href="/mgmt/activate/{{ cat }}"><span style="color: green;">Activate</span></a> <a href="/mgmt/delcat/{{ cat }}/inactive"><span style="color: red;">Delete</span></a><br>                            {% endfor %}                        </td>                    </tr>                </tbody>            </table>        </div>        </body>    </div>    <div id='announcements' class="tabcontent">        <body>            <form method="POST" action="/mgmt/announcements">                <table>                <h3>Manage Announcements</h3>                <table>                    <thead>                        <tr style="border-bottom: none;">                            <th style="width: 20%;"></th>                            <th style="width: 50%;"></th>                            <th></th>                        </tr>                    </thead>                    <tr>                        <td> <label for="announce_enable">Enable:</label> </td>                        {% if settings_info[9] %}                        <td> <input type="checkbox" name="announce_enable" value="{{ settings_info[9] }}" checked> </td>                        {% else %}                        <td> <input type="checkbox" name="announce_enable" value="{{ settings_info[9] }}"> </td>                        {% endif %}                        <td>Enable periodic announcements</td>                    </tr>                    <tr>                        <td> <label for="announce_interval">Interval:</label> </td>                        <td> <input type="number" name="announce_interval" value="{{ settings_info[10] }}" size="2" required> minutes</td>                        <td>How long between each announcement?</td>                    </tr>                    <tr>                        <td> <label for="announcements">Announcements:</label> </td>                        <td>                            <textarea name="announcements" rows="5" cols="50">{{ announcements | join('\n') }}</textarea>                        </td>                        <td>Enter your announcements, one per line.</td>                    </tr>                </table>                <br><button class="button button2" type="submit">Save Changes</button><br>            </form>            <br><br>        </body>    </div>    <div id='settings' class="tabcontent">        <body style="text-align: left;">            <form method="POST" action="/mgmt/settings">                <table>                <h3>OwnchatBot Settings</h3>                    <thead>                        <tr style="border-bottom: none;">                            <th style="width: 20%;"></th>                            <th></th>                            <th style="width: 50%;"></th>                        </tr>                    </thead>                    <tr>                        <td> <label for="mgmt_auth">Management Auth Code:</label> </td>                        <td style="padding: 5px;"> <input type="text" name="mgmt_auth" value="{{ settings_info[0] }}" size="30" required> </td>                        <td>Pregenerated during install. Goes in your management panel URL. Keep it secret. Keep it safe.<br>                        http://localhost:5000/mgmt?auth={{ settings_info[0] }}</td>                    </tr>                    <tr>                        <td> <label for="points_interval">Points Interval:</label> </td>                        <td> <input type="number" name="points_interval" value="{{ settings_info[1] }}" size="5" required> minutes</td>                        <td>How often do you want to award your viewers points?</td>                    </tr>                    <tr>                        <td> <label for="points_award">Points Award:</label> </td>                        <td> <input type="number" name="points_award" value="{{ settings_info[2] }}" size="5"  required> points</td>                        <td>How many points do you want to award them?</td>                    </tr>                    <tr>                        <td> <label for="gunicorn_logging">Gunicorn Logging:</label> </td>                        {% if settings_info[3] %}                        <td> <input type="checkbox" name="gunicorn_logging" value="{{ settings_info[3] }}" checked> </td>                        {% else %}                        <td> <input type="checkbox" name="gunicorn_logging" value="{{ settings_info[3] }}"> </td>                        {% endif %}                        <td>Enable Gunicorn logging integration.</td>                    </tr>                    <tr>                        <td> <label for="prefix">Chat Command Prefix:</label> </td>                        <td> <input type="text" name="prefix" maxlength="1" size="1" value="{{ settings_info[4] }}" required> </td>                        <td>Character that preceeds chat commands, so OwnchatBot knows what to look for.<br>Example: "{{ settings_info[4] }}points"</td>                    </tr>                </table>                                <h3>Owncast Integration</h3>                <table>                    <thead>                        <tr style="border-bottom: none;">                            <th style="width: 20%;"></th>                            <th></th>                            <th style="width: 50%;"></th>                        </tr>                    </thead>                    <tr>                        <td> <label for="access_token">Access Token:</label> </td>                        <td style="padding: 5px;"> <input type="text" name="access_token" value="{{ settings_info[5] }}" size="40"> </td>                        <td>Create in Owncast Admin panel. Integrations -> Access Tokens</td>                    </tr>                    <tr>                        <td> <label for="owncast_url">Your Owncast URL:</label> </td>                        <td> <input type="text" name="owncast_url" value="{{ settings_info[6] }}" size="40"> </td>                        <td>The address of your Owncast instance. Can be an internal address, such as "localhost" if that's the case.</td>                    </tr>                </table>                                <h3>Kofi Integration</h3>                <table>                    <thead>                        <tr style="border-bottom: none;">                            <th style="width: 20%;"></th>                            <th></th>                            <th style="width: 50%;"></th>                        </tr>                    </thead>                    <tr>                        <td> <label for="kofi_integration">Enable:</label> </td>                        {% if settings_info[8] %}                        <td> <input type="checkbox" name="kofi_integration" value="{{ settings_info[8] }}" checked> </td>                        {% else %}                        <td> <input type="checkbox" name="kofi_integration" value="{{ settings_info[8] }}"> </td>                        {% endif %}                        <td>Enable Ko-fi integration.</td>                    </tr>                    <tr>                        <td> <label for="kofi_token">Verification Token:</label> </td>                        <td style="padding: 5px;"> <input type="text" name="kofi_token" value="{{ settings_info[7] }}" size="40"> </td>                        <td>Get from Kofi -> More -> API -> Webhooks -> Advanced -> Verification Token.</td>                    </tr>                </table>                                <br><button class="button button2" type="submit">Save Changes</button><br>            </form>            <br><br>        </body>    </div>    <div id='kofi-settings' class="tabcontent">        <body style="text-align: left;">            <form method="POST" action="/mgmt/ksettings">                <table>                <h3>Kofi Settings</h3>                    <thead>                        <tr style="border-bottom: none;">                            <th style="width: 20%;"></th>                            <th></th>                            <th style="width: 50%;"></th>                        </tr>                    </thead>                    <tr>                        <td> <label for="enable_tips">Enable points for tips:</label> </td>                        {% if kofi_settings['tips'] %}                        <td> <input type="checkbox" name="enable_tips" value="{{ kofi_settings['tips'] }}" checked> </td>                        {% else %}                        <td> <input type="checkbox" name="enable_tips" value="{{ kofi_settings['tips'] }}"> </td>                        {% endif %}                        <td>Enable awarding points for tips</td>                    </tr>                    <tr>                        <td> <label for="set_tip_points">Points per dollar:</label> </td>                        <td> <input type="number" name="set_tip_points" value="{{ kofi_settings['tip_points'] }}" size="5" required> points</td>                        <td>How many points should viewers recieve, for every dollar they tip?</td>                    </tr>                    <tr>                        <td> <label for="kofi_url">Kofi Page:</label> </td>                        <td style="padding: 5px;"> <input type="text" name="kofi_url" value="{{ kofi_settings['kofi_url'] }}" size="30"> </td>                        <td>What is your Kofi page URL?</td>                    </tr>                    <tr>                        <table>                            <tbody>                                <tr style="border-bottom: none;">                                Which logo would you like to use?                                </tr>                            {% for kofi_logo in kofi_logos %}                                {% if loop.index0 % 8 == 0 %}                                    <tr style="border-bottom: none;">                                {% endif %}                                <td>                                    <label for="kofi_logo"><img src="/static/img/kofi/{{ kofi_logo }}"></label>                                    {% if kofi_logo == kofi_settings['kofi_logo'] %}                                        <input type="radio" name="kofi_logo" value="{{ kofi_logo }}" checked>                                    {% else %}                                        <input type="radio" name="kofi_logo" value="{{ kofi_logo }}">                                    {% endif %}                                </td>                                {% if loop.index0 % 8 == 7 or loop.last %}                                </tr> <!-- Close the row after 8 items or at the end -->                                {% endif %}                            {% endfor %}                            </tbody>                        </table>                    </tr>                </table>                <br><button class="button button2" type="submit">Save Changes</button><br>            </form>            <br><br>	    <i>Kofi subscription support coming soon.</i>        </body>    </div>        </html>
 |