-
Notifications
You must be signed in to change notification settings - Fork 0
/
modulo_infousers.py
37 lines (32 loc) · 1.21 KB
/
modulo_infousers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from database import Database
import datetime
# Crea un'istanza della classe Database
database_instance = Database()
db = database_instance.get_db()
def fetch_user_info(message, bot):
db = database_instance.get_db()
# Trova il documento relativo all'utente
user_doc = db.Users.find_one({"user_id": message.from_user.id})
if user_doc:
# Estrae le informazioni necessarie
user_id = user_doc.get('user_id')
bot_chat_id = user_doc.get('bot_chat_id')
chat_id = user_doc.get('chat_id')
is_logged = user_doc.get('is_logged', False)
permessi = user_doc.get('permessi')
user_name = user_doc.get('user_name')
if is_logged:
return {
'user_id': user_id,
'bot_chat_id': bot_chat_id,
'chat_id': chat_id,
'is_logged': is_logged,
'permessi': permessi,
'user_name': user_name
}
else:
bot.send_message(chat_id=chat_id, text="Non sei loggato, premi /start per loggarti.")
return
else:
bot.send_message(chat_id=message.chat.id, text="Non sei loggato, premi /start per loggarti.")
return