I'VE FINISHED!

This commit is contained in:
Stefano Assenzo 2022-12-10 18:23:53 +00:00
parent a994ca810b
commit 9ab764fa00
1 changed files with 4 additions and 2 deletions

View File

@ -1,14 +1,16 @@
from bson.objectid import ObjectId
import os
def subscribe_command(message, bot, collection_id, OBJECTID_idlist):
def subscribe_command(message, bot, collection_id):
chat_id = message.chat.id #Get chat id
send_message = bot.send_message(chat_id, "✅ You have been successfully subscribed to Epic Games Store Free Games notifications!") #Send message
#Get the ids of all users who write /subscribe
take_id = message.from_user.id #Get user id
#Insert the id of the user who writes /subscribe in the database
find_document_username = list(collection_id.find({}, {"_id": 1}))
array_username = find_document_username[0]["_id"]
collection_id.update_one(
{ "_id": ObjectId(OBJECTID_idlist)},
{ "_id": ObjectId(array_username)},
{
"$push": { "username": take_id }
}