浏览代码

Fixed announcements not refreshing bug, and kofi message appearing with Kofi integration disabled

deadtom 2 周之前
父节点
当前提交
4d9d70ef01
共有 4 个文件被更改,包括 9 次插入6 次删除
  1. 3 1
      TODO.md
  2. 1 2
      ownchatbot/__init__.py
  3. 4 3
      ownchatbot/bot_messages.py
  4. 1 0
      ownchatbot/reward_handlers.py

+ 3 - 1
TODO.md

@@ -1 +1,3 @@
-
+* Get Kofi subscriptions and tiers sorted out.
+* Add acknowledgement to install script, that I am not responsible for any loss of viewers data, and the streamer is solely responsible for backing it up and maintaining it.
+* Add celebration emojis in messages for things like goals and milestones.

+ 1 - 2
ownchatbot/__init__.py

@@ -43,11 +43,10 @@ def create_app(test_config=None):
     from . import db  # Set up cli commands
     from . import db  # Set up cli commands
     db.init_app(app)
     db.init_app(app)
 
 
-    announcements = app.config['ANNOUNCEMENTS']
-
     def announce():
     def announce():
         if app.config['ANNOUNCE_ENABLE']:  # If announcements are enabled
         if app.config['ANNOUNCE_ENABLE']:  # If announcements are enabled
             global current_index
             global current_index
+            announcements = app.config['ANNOUNCEMENTS']
             message = announcements[current_index]
             message = announcements[current_index]
             send_system_chat(message)
             send_system_chat(message)
             current_index = (current_index + 1) % len(announcements)
             current_index = (current_index + 1) % len(announcements)

+ 4 - 3
ownchatbot/bot_messages.py

@@ -138,9 +138,9 @@ def help_message(user_id):
         message = f'{message}<br><br>\
         message = f'{message}<br><br>\
             Kofi is enabled! <br>\
             Kofi is enabled! <br>\
             Authenticate with Owncast, and enter your email address into the Stream Rewards Info page to get Kofi perks.'
             Authenticate with Owncast, and enter your email address into the Stream Rewards Info page to get Kofi perks.'
-    if kofi_settings['tips']:
-        message = f'{message}<br>\
-        You\'ll recieve {kofi_settings["tip_points"]} points for every dollar you tip on Kofi.'
+        if kofi_settings['tips']:
+            message = f'{message}<br>\
+            You\'ll recieve {kofi_settings["tip_points"]} points for every dollar you tip on Kofi.'
     send_private_chat(user_id, message)
     send_private_chat(user_id, message)
 
 
 
 
@@ -153,6 +153,7 @@ ANNOUNCE_INTERVAL = {announce_dict['ANNOUNCE_INTERVAL']}  # How long, in minutes
     try:
     try:
         with open(announce_file, 'w') as f:
         with open(announce_file, 'w') as f:
             f.write(new_announce)
             f.write(new_announce)
+            f.close()
     except Exception as saerror:
     except Exception as saerror:
         current_app.logger.error(f'Couldn\'t save announce.py: {saerror.args[0]}')
         current_app.logger.error(f'Couldn\'t save announce.py: {saerror.args[0]}')
         return False
         return False

+ 1 - 0
ownchatbot/reward_handlers.py

@@ -295,6 +295,7 @@ def save_rewards(reward_info):  # Write rewards to rewards.py
     try:
     try:
         with open(rewards_file, 'w') as f:
         with open(rewards_file, 'w') as f:
             f.write(f'REWARDS = {new_rewards}')
             f.write(f'REWARDS = {new_rewards}')
+            f.close()
     except Exception as srerror:
     except Exception as srerror:
         current_app.logger.error(f'Couldn\'t save rewards.py: {srerror.args[0]}')
         current_app.logger.error(f'Couldn\'t save rewards.py: {srerror.args[0]}')
         return False
         return False