|
@@ -7,16 +7,12 @@ from ownchatbot.reward_handlers import all_active_goals, all_active_votes, all_a
|
|
|
from ownchatbot.kofi_handlers import accept_donation, accept_sub
|
|
from ownchatbot.kofi_handlers import accept_donation, accept_sub
|
|
|
import json
|
|
import json
|
|
|
import random
|
|
import random
|
|
|
|
|
+from ownchatbot import followers, donations, subscribers, rgoal, rmilestone
|
|
|
|
|
|
|
|
|
|
|
|
|
ocb = Blueprint('webhooks', __name__)
|
|
ocb = Blueprint('webhooks', __name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
-followers = []
|
|
|
|
|
-donations = []
|
|
|
|
|
-subscribers = []
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
def format(rawjson): # Make data legible
|
|
def format(rawjson): # Make data legible
|
|
|
formatted_data = json.dumps(rawjson, indent=4)
|
|
formatted_data = json.dumps(rawjson, indent=4)
|
|
|
return formatted_data
|
|
return formatted_data
|
|
@@ -169,6 +165,7 @@ def kofi_hook():
|
|
|
|
|
|
|
|
@ocb.route('/checkFollows') # Polled by follower.html template to check for new followers
|
|
@ocb.route('/checkFollows') # Polled by follower.html template to check for new followers
|
|
|
def check_follows():
|
|
def check_follows():
|
|
|
|
|
+ global followers
|
|
|
if followers:
|
|
if followers:
|
|
|
current_app.logger.debug(f'\n\n{format(followers[0])}\n\n')
|
|
current_app.logger.debug(f'\n\n{format(followers[0])}\n\n')
|
|
|
last_follower = followers.pop(0)
|
|
last_follower = followers.pop(0)
|
|
@@ -178,8 +175,34 @@ def check_follows():
|
|
|
return jsonify(None)
|
|
return jsonify(None)
|
|
|
|
|
|
|
|
|
|
|
|
|
-@ocb.route('/checkDonations') # Polled by follower.html template to check for new followers
|
|
|
|
|
|
|
+@ocb.route('/checkGoals') # Polled by follower.html template to check for new followers
|
|
|
|
|
+def check_goals():
|
|
|
|
|
+ global rgoals
|
|
|
|
|
+ if rgoals:
|
|
|
|
|
+ current_app.logger.debug(f'\n\n{format(rgoals[0])}\n\n')
|
|
|
|
|
+ last_goal = rgoals.pop(0)
|
|
|
|
|
+ return jsonify(last_goal)
|
|
|
|
|
+ else:
|
|
|
|
|
+ current_app.logger.info(f'No new goals reached')
|
|
|
|
|
+ return jsonify(None)
|
|
|
|
|
+ return jsonify(None)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@ocb.route('/checkMilestones') # Polled by follower.html template to check for new followers
|
|
|
|
|
+def check_milestones():
|
|
|
|
|
+ global rmilestones
|
|
|
|
|
+ if rmilestones:
|
|
|
|
|
+ current_app.logger.debug(f'\n\n{format(rmilestones[0])}\n\n')
|
|
|
|
|
+ last_milestone = rmilestones.pop(0)
|
|
|
|
|
+ return jsonify(last_milestone)
|
|
|
|
|
+ else:
|
|
|
|
|
+ current_app.logger.info(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():
|
|
def check_donations():
|
|
|
|
|
+ global donations
|
|
|
if donations:
|
|
if donations:
|
|
|
current_app.logger.info(f'\n\n{format(donations[0])}\n\n')
|
|
current_app.logger.info(f'\n\n{format(donations[0])}\n\n')
|
|
|
last_donation = donations.pop(0)
|
|
last_donation = donations.pop(0)
|
|
@@ -189,8 +212,9 @@ def check_donations():
|
|
|
return jsonify(None)
|
|
return jsonify(None)
|
|
|
|
|
|
|
|
|
|
|
|
|
-@ocb.route('/checkSubscribers') # Polled by subscriber.html template to check for new followers
|
|
|
|
|
|
|
+@ocb.route('/checkSubscribers') # Polled by subscriber.html template to check for new kofi subscribers
|
|
|
def check_subscribers():
|
|
def check_subscribers():
|
|
|
|
|
+ global subscribers
|
|
|
if subscribers:
|
|
if subscribers:
|
|
|
current_app.logger.info(f'\n\n{format(subscribers[0])}\n\n')
|
|
current_app.logger.info(f'\n\n{format(subscribers[0])}\n\n')
|
|
|
last_subscriber = subscribers.pop(0)
|
|
last_subscriber = subscribers.pop(0)
|