BinaryONe commited on
Commit
d84acbc
·
1 Parent(s): c0a2997

Changes in Database

Browse files
FileStream/Database/Elements.py CHANGED
@@ -28,11 +28,12 @@ def NewTG_Files(details:dict) -> dict:
28
  }
29
 
30
 
31
- def UserSchema(id: str) -> dict:
32
 
33
  return dict(
34
  telegram_id=id,
35
  access="USER",
 
36
  tele_status={
37
  "status": "ACTIVE",
38
  "activity": None,
 
28
  }
29
 
30
 
31
+ def UserSchema(id: str, details) -> dict:
32
 
33
  return dict(
34
  telegram_id=id,
35
  access="USER",
36
+ name= details.first_name + details.last_name if details else "Unknown",
37
  tele_status={
38
  "status": "ACTIVE",
39
  "activity": None,
FileStream/Database/database.py CHANGED
@@ -28,8 +28,8 @@ class Database:
28
  #---------------------[ NEW USER ]---------------------#
29
  # ---------------------[ ADD USER ]---------------------#
30
 
31
- async def add_user(self, id):
32
- user = UserSchema(id)
33
  await self.users.insert_one(user)
34
 
35
  async def add_admin(self, id):
 
28
  #---------------------[ NEW USER ]---------------------#
29
  # ---------------------[ ADD USER ]---------------------#
30
 
31
+ async def add_user(self, id, details=None):
32
+ user = UserSchema(id, details)
33
  await self.users.insert_one(user)
34
 
35
  async def add_admin(self, id):
FileStream/bot/plugins/Admin/admin.py CHANGED
@@ -31,6 +31,7 @@ async def sts(c: Client, m: Message):
31
 
32
  @FileStream.on_message(filters.command("add_user") & filters.private )
33
  async def add_user(c: Client, m: Message):
 
34
  if await db.is_admin(m.from_user.id):
35
  if len(m.command) == 1:
36
  return await m.reply_text("**Usage:**\n /add_user <user_id>")
@@ -38,13 +39,14 @@ async def add_user(c: Client, m: Message):
38
  user_id = int(m.command[1])
39
  except ValueError or UnboundLocalError:
40
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code> ")
41
- await db.add_user(user_id)
42
  await m.reply_text(f"**User[{m.from_user.first_name} {m.from_user.last_name}] \n User ID : {user_id} Added Successfully**")
43
  else:
44
  await m.reply_text(f"** Sorry Sir {user_id} You are not Admin **")
45
 
46
  @FileStream.on_message(filters.command("add_admin") & filters.user(Telegram.OWNER_ID) )
47
  async def add_user(c: Client, m: Message):
 
48
  if await db.is_admin(m.from_user.id):
49
  if len(m.command) == 1:
50
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <user_id> </code>")
@@ -52,7 +54,7 @@ async def add_user(c: Client, m: Message):
52
  user_id = int(m.command[1])
53
  except ValueError or UnboundLocalError:
54
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code>")
55
- await db.add_admin(user_id)
56
  await m.reply_text(f"**Admin [{m.from_user.first_name} {m.from_user.last_name}]\n {user_id} Added Successfully**")
57
  else:
58
  await m.reply_text(f"** Sorry Sir [{m.from_user.first_name} {m.from_user.last_name}] {user_id} You are not Admin **")
 
31
 
32
  @FileStream.on_message(filters.command("add_user") & filters.private )
33
  async def add_user(c: Client, m: Message):
34
+ details= await FileStream.get_users(user_id)
35
  if await db.is_admin(m.from_user.id):
36
  if len(m.command) == 1:
37
  return await m.reply_text("**Usage:**\n /add_user <user_id>")
 
39
  user_id = int(m.command[1])
40
  except ValueError or UnboundLocalError:
41
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code> ")
42
+ await db.add_user(user_id, details)
43
  await m.reply_text(f"**User[{m.from_user.first_name} {m.from_user.last_name}] \n User ID : {user_id} Added Successfully**")
44
  else:
45
  await m.reply_text(f"** Sorry Sir {user_id} You are not Admin **")
46
 
47
  @FileStream.on_message(filters.command("add_admin") & filters.user(Telegram.OWNER_ID) )
48
  async def add_user(c: Client, m: Message):
49
+ details= await FileStream.get_users(user_id)
50
  if await db.is_admin(m.from_user.id):
51
  if len(m.command) == 1:
52
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <user_id> </code>")
 
54
  user_id = int(m.command[1])
55
  except ValueError or UnboundLocalError:
56
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code>")
57
+ await db.add_admin(user_id, details )
58
  await m.reply_text(f"**Admin [{m.from_user.first_name} {m.from_user.last_name}]\n {user_id} Added Successfully**")
59
  else:
60
  await m.reply_text(f"** Sorry Sir [{m.from_user.first_name} {m.from_user.last_name}] {user_id} You are not Admin **")
FileStream/bot/plugins/FileHandlers/callback.py CHANGED
@@ -112,6 +112,7 @@ async def cb_data(bot: Client, update: CallbackQuery):
112
  reply_markup=reply_markup,
113
  )
114
  elif usr_cmd[0] == "pubup":
 
115
  try:
116
  print("Public Upload :",usr_cmd)
117
  user_id = str(usr_cmd[1])
 
112
  reply_markup=reply_markup,
113
  )
114
  elif usr_cmd[0] == "pubup":
115
+
116
  try:
117
  print("Public Upload :",usr_cmd)
118
  user_id = str(usr_cmd[1])