Skip to content

Commit 836167f

Browse files
committed
Added match for like bot action
1 parent fb665a1 commit 836167f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

backend/PyMatcha/utils/bot_actions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from chatterbot.trainers import ChatterBotCorpusTrainer
77
from PyMatcha import redis
88
from PyMatcha.models.like import Like
9+
from PyMatcha.models.match import Match
910
from PyMatcha.models.message import Message
1011
from PyMatcha.models.user import User
1112
from PyMatcha.models.view import View
@@ -56,7 +57,12 @@ def botaction_like(bot_user: User):
5657
user_to_like = choice(recommendations)
5758
except IndexError:
5859
return
59-
Like.create(liker_id=bot_user.id, liked_id=user_to_like["id"])
60+
user_to_like = User.get(id=user_to_like["id"])
61+
View.create(profile_id=user_to_like.id, viewer_id=bot_user.id)
62+
Like.create(liker_id=bot_user.id, liked_id=user_to_like.id)
63+
64+
if user_to_like.already_likes(bot_user.id):
65+
Match.create(user_1=bot_user.id, user_2=user_to_like.id)
6066

6167

6268
def botaction_unlike(bot_user: User):

0 commit comments

Comments
 (0)