1010from PyMatcha .models .like import Like
1111from PyMatcha .models .match import Match
1212from PyMatcha .models .message import Message
13+ from PyMatcha .models .notification import Notification
1314from PyMatcha .models .user import User
1415from PyMatcha .models .view import View
1516from PyMatcha .utils .recommendations import create_user_recommendations
@@ -60,10 +61,30 @@ def _botaction_like(bot_user: User, recommendations):
6061 return
6162 user_to_like = User .get (id = user_to_like ["id" ])
6263 View .create (profile_id = user_to_like .id , viewer_id = bot_user .id )
64+ Notification .create (
65+ trigger_id = bot_user .id ,
66+ user_id = user_to_like ["id" ],
67+ content = f"{ bot_user .first_name } just viewed your profile! Go check their profile out!" ,
68+ type = "view" ,
69+ link_to = f"users/{ bot_user .id } " ,
70+ )
6371 Like .create (liker_id = bot_user .id , liked_id = user_to_like .id )
64-
72+ Notification .create (
73+ trigger_id = bot_user .id ,
74+ user_id = user_to_like .id ,
75+ content = f"{ bot_user .first_name } liked you! Go check them out!" ,
76+ type = "like" ,
77+ link_to = f"users/{ bot_user .id } " ,
78+ )
6579 if user_to_like .already_likes (bot_user .id ):
6680 Match .create (user_1 = bot_user .id , user_2 = user_to_like .id )
81+ Notification .create (
82+ trigger_id = bot_user .id ,
83+ user_id = user_to_like .id ,
84+ content = f"You and { bot_user .first_name } matched!" ,
85+ type = "match" ,
86+ link_to = f"conversation/{ bot_user .id } " ,
87+ )
6788
6889
6990def botaction_unlike (bot_user : User ):
@@ -81,6 +102,13 @@ def _botaction_view(bot_user: User, recommendations):
81102 except IndexError :
82103 return
83104 View .create (profile_id = user_to_view ["id" ], viewer_id = bot_user .id )
105+ Notification .create (
106+ trigger_id = bot_user .id ,
107+ user_id = user_to_view ["id" ],
108+ content = f"{ bot_user .first_name } just viewed your profile! Go check their profile out!" ,
109+ type = "view" ,
110+ link_to = f"users/{ bot_user .id } " ,
111+ )
84112
85113
86114def _botaction_message_new_conversation (bot_user : User ):
@@ -102,7 +130,15 @@ def _botaction_message_new_conversation(bot_user: User):
102130 else :
103131 other_user = match_to_open_conv .user_1
104132
105- bot_user .send_message (to_id = other_user , content = choice (BOT_CONV_OPENERS ))
133+ content = choice (BOT_CONV_OPENERS )
134+ bot_user .send_message (to_id = other_user , content = content )
135+ Notification .create (
136+ trigger_id = bot_user .id ,
137+ user_id = other_user ,
138+ content = f"{ bot_user .first_name } said: { content } " ,
139+ type = "message" ,
140+ link_to = f"conversation/{ bot_user .id } " ,
141+ )
106142
107143
108144def _botaction_respond_to_unread (bot_user : User , chatbot ):
@@ -118,6 +154,13 @@ def _botaction_respond_to_unread(bot_user: User, chatbot):
118154 return
119155 bot_reply = chatbot .get_response (message_to_reply .content )
120156 bot_user .send_message (to_id = message_to_reply .from_id , content = bot_reply .text )
157+ Notification .create (
158+ trigger_id = bot_user .id ,
159+ user_id = message_to_reply .from_id ,
160+ content = f"{ bot_user .first_name } said: { bot_reply .text } " ,
161+ type = "message" ,
162+ link_to = f"conversation/{ bot_user .id } " ,
163+ )
121164
122165
123166def _botaction_send_message_over_old_one (bot_user : User , chatbot ):
@@ -133,6 +176,13 @@ def _botaction_send_message_over_old_one(bot_user: User, chatbot):
133176
134177 bot_reply = chatbot .get_response ("." )
135178 bot_user .send_message (to_id = other_user , content = bot_reply .text )
179+ Notification .create (
180+ trigger_id = bot_user .id ,
181+ user_id = message_to_reply .from_id ,
182+ content = f"{ bot_user .first_name } said: { bot_reply .text } " ,
183+ type = "message" ,
184+ link_to = f"conversation/{ bot_user .id } " ,
185+ )
136186
137187
138188def decide_bot_action (bot_user : User ):
0 commit comments