|  | @@ -1,6 +1,6 @@
 | 
											
												
													
														|  |  from flask import current_app
 |  |  from flask import current_app
 | 
											
												
													
														|  |  from ownchatbot.db import get_db, is_cool
 |  |  from ownchatbot.db import get_db, is_cool
 | 
											
												
													
														|  | -from ownchatbot.owncast_com import send_chat
 |  | 
 | 
											
												
													
														|  | 
 |  | +from ownchatbot.owncast_com import send_chat, send_private_chat
 | 
											
												
													
														|  |  from ownchatbot.reward_handlers import run_script, add_to_queue, add_to_vote, add_to_goal, was_goal_reached, goal_reached, is_reward_active, check_vote, all_active_goals, goal_left, was_milestone_reached
 |  |  from ownchatbot.reward_handlers import run_script, add_to_queue, add_to_vote, add_to_goal, was_goal_reached, goal_reached, is_reward_active, check_vote, all_active_goals, goal_left, was_milestone_reached
 | 
											
												
													
														|  |  from ownchatbot.user_handlers import spend_points, get_users_points, refund_points, get_all_users_with_user_id
 |  |  from ownchatbot.user_handlers import spend_points, get_users_points, refund_points, get_all_users_with_user_id
 | 
											
												
													
														|  |  import os
 |  |  import os
 | 
											
										
											
												
													
														|  | @@ -45,7 +45,7 @@ def do_reward(message, user_id):  # Parse the chat command
 | 
											
												
													
														|  |          contribution = split_message[1]
 |  |          contribution = split_message[1]
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if reward not in current_app.config['REWARDS']:  # Check if it's a command or a reward
 |  |      if reward not in current_app.config['REWARDS']:  # Check if it's a command or a reward
 | 
											
												
													
														|  | -        send_chat(f'{username}, \"{prefix}{reward}\" is not a chat command or a reward. Check your spelling?')
 |  | 
 | 
											
												
													
														|  | 
 |  | +        send_private_chat(user_id, f'{username}, \"{prefix}{reward}\" is not a chat command or a reward. Check your spelling?')
 | 
											
												
													
														|  |          return
 |  |          return
 | 
											
												
													
														|  |      if not is_reward_active(reward):  # If reward isn't active, say so
 |  |      if not is_reward_active(reward):  # If reward isn't active, say so
 | 
											
												
													
														|  |          send_chat(f'Sorry, {username}. \"{prefix}{reward}\" is not currently an active reward.')
 |  |          send_chat(f'Sorry, {username}. \"{prefix}{reward}\" is not currently an active reward.')
 | 
											
										
											
												
													
														|  | @@ -56,20 +56,20 @@ def do_reward(message, user_id):  # Parse the chat command
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if reward_type == 'goal':  # If it's a goal contribution, do the thing
 |  |      if reward_type == 'goal':  # If it's a goal contribution, do the thing
 | 
											
												
													
														|  |          if not contribution:
 |  |          if not contribution:
 | 
											
												
													
														|  | -            send_chat(f'{username}, you didn\'t tell me how many points you want to contribute.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'{username}, you didn\'t tell me how many points you want to contribute.')
 | 
											
												
													
														|  |              return
 |  |              return
 | 
											
												
													
														|  |          if goal_reached(db, reward):
 |  |          if goal_reached(db, reward):
 | 
											
												
													
														|  | -            send_chat(f'{username}, we already completed this goal.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'{username}, we already completed this goal.')
 | 
											
												
													
														|  |              return
 |  |              return
 | 
											
												
													
														|  |          if int(contribution) > goal_left(db, reward):  # If they're contributing more than they need to
 |  |          if int(contribution) > goal_left(db, reward):  # If they're contributing more than they need to
 | 
											
												
													
														|  |              current_app.logger.info(f'{username} contributed more than what was needed to reach the target.')
 |  |              current_app.logger.info(f'{username} contributed more than what was needed to reach the target.')
 | 
											
												
													
														|  |              contribution = goal_left(db, reward)  # only spend what is needed to reach the goal.
 |  |              contribution = goal_left(db, reward)  # only spend what is needed to reach the goal.
 | 
											
												
													
														|  |          if int(contribution) > points:
 |  |          if int(contribution) > points:
 | 
											
												
													
														|  | -            send_chat(f'{username}, you don\'t have that many points.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'{username}, you don\'t have that many points.')
 | 
											
												
													
														|  |          elif int(contribution) < 0:
 |  |          elif int(contribution) < 0:
 | 
											
												
													
														|  | -            send_chat(f'{username}, you can\'t contribute negative points.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'{username}, you can\'t contribute negative points.')
 | 
											
												
													
														|  |          elif int(contribution) == 0:
 |  |          elif int(contribution) == 0:
 | 
											
												
													
														|  | -            send_chat(f'{username}, you can\'t contribute zero points.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'{username}, you can\'t contribute zero points.')
 | 
											
												
													
														|  |          elif add_to_goal(db, user_id, reward, int(contribution)):
 |  |          elif add_to_goal(db, user_id, reward, int(contribution)):
 | 
											
												
													
														|  |              send_chat(f'{username} contributed {porps(contribution)} to the \"{prefix}{reward}\" goal.')
 |  |              send_chat(f'{username} contributed {porps(contribution)} to the \"{prefix}{reward}\" goal.')
 | 
											
												
													
														|  |              wmr = was_milestone_reached(db, reward)
 |  |              wmr = was_milestone_reached(db, reward)
 | 
											
										
											
												
													
														|  | @@ -78,22 +78,22 @@ def do_reward(message, user_id):  # Parse the chat command
 | 
											
												
													
														|  |              if was_goal_reached(db, reward):
 |  |              if was_goal_reached(db, reward):
 | 
											
												
													
														|  |                  send_chat(f'\"{prefix}{reward}\" target reached! 🎉')
 |  |                  send_chat(f'\"{prefix}{reward}\" target reached! 🎉')
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  | -            send_chat(f'Couldn\'t contribute to the \"{prefix}{reward}\" goal for {username}, for some highly technical reason.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'Couldn\'t contribute to the \"{prefix}{reward}\" goal for {username}, for some highly technical reason.')
 | 
											
												
													
														|  |          return
 |  |          return
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      price = current_app.config['REWARDS'][reward]['price']  # Do they have enough points?
 |  |      price = current_app.config['REWARDS'][reward]['price']  # Do they have enough points?
 | 
											
												
													
														|  |      if not points or points < price:
 |  |      if not points or points < price:
 | 
											
												
													
														|  | -        send_chat(f'{username}, you don\'t have enough points for \"{prefix}{reward}\".')
 |  | 
 | 
											
												
													
														|  | 
 |  | +        send_private_chat(user_id, f'{username}, you don\'t have enough points for \"{prefix}{reward}\".')
 | 
											
												
													
														|  |          return
 |  |          return
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if reward_type == 'vote':  # If it's a vote, do the thing
 |  |      if reward_type == 'vote':  # If it's a vote, do the thing
 | 
											
												
													
														|  |          if check_vote(db, reward, user_id):  # See if viewer already voted
 |  |          if check_vote(db, reward, user_id):  # See if viewer already voted
 | 
											
												
													
														|  | -            send_chat(f'{username}, you already voted for \"{prefix}{reward}\".')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_private_chat(user_id, f'{username}, you already voted for \"{prefix}{reward}\".')
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  |              if add_to_vote(db, reward, user_id) and spend_points(db, user_id, price):
 |  |              if add_to_vote(db, reward, user_id) and spend_points(db, user_id, price):
 | 
											
												
													
														|  |                  send_chat(f'{username} voted for \"{prefix}{reward}\" for {porps(price)}.')
 |  |                  send_chat(f'{username} voted for \"{prefix}{reward}\" for {porps(price)}.')
 | 
											
												
													
														|  |              else:
 |  |              else:
 | 
											
												
													
														|  | -                send_chat(f'Couldn\'t vote for \"{prefix}{reward}\" for {username}, for some highly technical reason.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +                send_private_chat(user_id, f'Couldn\'t vote for \"{prefix}{reward}\" for {username}, for some highly technical reason.')
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |      elif reward_type == 'redeem':  # If it's a redeem, do the thing
 |  |      elif reward_type == 'redeem':  # If it's a redeem, do the thing
 | 
											
												
													
														|  |          if is_cool(reward)[0]:  # Is there an active cool down?
 |  |          if is_cool(reward)[0]:  # Is there an active cool down?
 | 
											
										
											
												
													
														|  | @@ -101,10 +101,10 @@ def do_reward(message, user_id):  # Parse the chat command
 | 
											
												
													
														|  |                      spend_points(db, user_id, price)):
 |  |                      spend_points(db, user_id, price)):
 | 
											
												
													
														|  |                  send_chat(f'{username} redeemed \"{prefix}{reward}\" for {porps(price)}.')
 |  |                  send_chat(f'{username} redeemed \"{prefix}{reward}\" for {porps(price)}.')
 | 
											
												
													
														|  |              else:
 |  |              else:
 | 
											
												
													
														|  | -                send_chat(f'Couldn\'t redeem \"{prefix}{reward}\"for {username}, for some highly technical reason.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +                send_private_chat(user_id, f'Couldn\'t redeem \"{prefix}{reward}\"for {username}, for some highly technical reason.')
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  |              hot_time = is_cool(reward)[1]
 |  |              hot_time = is_cool(reward)[1]
 | 
											
												
													
														|  | -            send_chat(f'Couldn\'t redeem \"{prefix}{reward}\"for {username}.<br>That reward has {mas(hot_time)} left to cool down.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_chat(f'\"{prefix}{reward}\" has {mas(hot_time)} left to cool down.')
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |      elif reward_type == 'special':  # If it's a special, do the thing
 |  |      elif reward_type == 'special':  # If it's a special, do the thing
 | 
											
												
													
														|  |          if is_cool(reward)[0]:  # Is there an active cool down?
 |  |          if is_cool(reward)[0]:  # Is there an active cool down?
 | 
											
										
											
												
													
														|  | @@ -115,30 +115,33 @@ def do_reward(message, user_id):  # Parse the chat command
 | 
											
												
													
														|  |                  send_chat(f'{username} redeemed \'{prefix}{reward}\' for {porps(price)}.')
 |  |                  send_chat(f'{username} redeemed \'{prefix}{reward}\' for {porps(price)}.')
 | 
											
												
													
														|  |              else:
 |  |              else:
 | 
											
												
													
														|  |                  if refund_points(db, user_id, price):
 |  |                  if refund_points(db, user_id, price):
 | 
											
												
													
														|  | -                    send_chat(f'Couldn\'t redeem \"{prefix}{reward}\"for {username}, for some highly technical reason.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    send_private_chat(user_id, f'Couldn\'t redeem \"{prefix}{reward}\"for {username}, for some highly technical reason.')
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  |              hot_time = is_cool(reward)[1]
 |  |              hot_time = is_cool(reward)[1]
 | 
											
												
													
														|  | -            send_chat(f'Couldn\'t redeem \"{prefix}{reward}\"for {username}.<br>That reward has {mas(hot_time)} left to cool down.')       
 |  | 
 | 
											
												
													
														|  | 
 |  | +            send_chat(f'\"{prefix}{reward}\" has {mas(hot_time)} left to cool down.')
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |      else:  # If we can't find the reward, say so
 |  |      else:  # If we can't find the reward, say so
 | 
											
												
													
														|  | -        send_chat(f'\"{prefix}{reward}\", {username}? No such reward.')
 |  | 
 | 
											
												
													
														|  | 
 |  | +        send_private_chat(user_id, f'\"{prefix}{reward}\", {username}? No such reward.')
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -def help_message():
 |  | 
 | 
											
												
													
														|  | 
 |  | +def help_message(user_id):
 | 
											
												
													
														|  |      prefix = current_app.config['PREFIX']
 |  |      prefix = current_app.config['PREFIX']
 | 
											
												
													
														|  |      kofi_settings = current_app.config['KOFI_SETTINGS']
 |  |      kofi_settings = current_app.config['KOFI_SETTINGS']
 | 
											
												
													
														|  |      kofi_integration = current_app.config['KOFI_INTEGRATION']
 |  |      kofi_integration = current_app.config['KOFI_INTEGRATION']
 | 
											
												
													
														|  | -    message = f'You get {current_app.config["POINTS_AWARD"]} points for every {current_app.config["POINTS_INTERVAL"]} seconds you\'re in chat.<br> \
 |  | 
 | 
											
												
													
														|  | 
 |  | +    message = f'You get {current_app.config["POINTS_AWARD"]} points for every {current_app.config["POINTS_INTERVAL"]} minutes you\'re in chat.<br> \
 | 
											
												
													
														|  |              You can see your points, the rewards queue, and other helpful information by clicking on the \"Points Rewards\" button.<br><br> \
 |  |              You can see your points, the rewards queue, and other helpful information by clicking on the \"Points Rewards\" button.<br><br> \
 | 
											
												
													
														|  | -            Chat commands:<br> \
 |  | 
 | 
											
												
													
														|  | -            {prefix}help to see this help message.<br> \
 |  | 
 | 
											
												
													
														|  | -            {prefix}points to see your points.<br> \
 |  | 
 | 
											
												
													
														|  | -            {prefix}rewards to see a list of currently active rewards.<br>'
 |  | 
 | 
											
												
													
														|  | -    if kofi_integration and kofi_settings['tips']:
 |  | 
 | 
											
												
													
														|  | 
 |  | +            <b><u>Chat commands:</u></b><br> \
 | 
											
												
													
														|  | 
 |  | +            <b>{prefix}help</b> to see this help message.<br> \
 | 
											
												
													
														|  | 
 |  | +            <b>{prefix}points</b> to see your points.<br> \
 | 
											
												
													
														|  | 
 |  | +            <b>{prefix}rewards</b> to see a list of currently active rewards.'
 | 
											
												
													
														|  | 
 |  | +    if kofi_integration:
 | 
											
												
													
														|  | 
 |  | +        message = f'{message}<br><br>\
 | 
											
												
													
														|  | 
 |  | +            Kofi is enabled! <br>\
 | 
											
												
													
														|  | 
 |  | +            Authenticated 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>\
 |  |          message = f'{message}<br>\
 | 
											
												
													
														|  | -        Kofi is enabled! Once you\'ve authenticated with Owncast, you\'ll recieve\
 |  | 
 | 
											
												
													
														|  | -        {kofi_settings["tip_points"]} points for every dollar you tip on Kofi.'
 |  | 
 | 
											
												
													
														|  | -    send_chat(message)
 |  | 
 | 
											
												
													
														|  | 
 |  | +        You\'ll recieve {kofi_settings["tip_points"]} points for every dollar you tip on Kofi.'
 | 
											
												
													
														|  | 
 |  | +    send_private_chat(user_id, message)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  def save_announce(announce_dict):  # Write rewards to announce.py
 |  |  def save_announce(announce_dict):  # Write rewards to announce.py
 |