11import datetime
22import json
3+ import random
34from math import ceil
45
56from PyMatcha import celery
67from PyMatcha import redis
78from PyMatcha .models .message import Message
89from PyMatcha .models .user import User
10+ from PyMatcha .utils .bot_actions import botaction_like
11+ from PyMatcha .utils .bot_actions import botaction_message_new_conversation
12+ from PyMatcha .utils .bot_actions import botaction_respond_to_unread
13+ from PyMatcha .utils .bot_actions import botaction_send_message_over_old_one
14+ from PyMatcha .utils .bot_actions import botaction_unlike
15+ from PyMatcha .utils .bot_actions import botaction_view
916from PyMatcha .utils .recommendations import create_user_recommendations
1017
1118BASE_HEAT_SCORE = 30
@@ -28,6 +35,7 @@ def setup_periodic_tasks(sender, **kwargs):
2835 sender .add_periodic_task (
2936 600 , calc_search_min_max .s (), name = "Update Minimum and Maximum scores and ages for search every 10 minutes"
3037 )
38+ sender .add_periodic_task (30 , random_bot_action .s (), name = "Have the only bots do an action" )
3139
3240
3341@celery .task
@@ -145,6 +153,17 @@ def take_random_users_online():
145153
146154@celery .task
147155def random_bot_action ():
148- for user in User .get_multis (skip_recommendations = True ):
149- # TODO: Check notifications
150- pass
156+ for user in User .get_multis (skip_recommendations = True , is_online = True ):
157+ bot_actions = [
158+ None ,
159+ botaction_view ,
160+ botaction_like ,
161+ botaction_respond_to_unread ,
162+ botaction_message_new_conversation ,
163+ botaction_send_message_over_old_one ,
164+ botaction_unlike ,
165+ ]
166+ selected_action = random .choices (bot_actions , cum_weights = (100 , 100 , 95 , 90 , 90 , 80 , 50 ), k = 1 )
167+ if selected_action [0 ]:
168+ # Has to have the [0] because random.choices return a list
169+ selected_action [0 ](user )
0 commit comments