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

Changes in Database

Browse files
FileStream/Database/Elements.py CHANGED
@@ -52,4 +52,13 @@ def UserSchema(id: str, details) -> dict:
52
  "links": 0,
53
  "joined": "None"
54
  },
55
- )
 
 
 
 
 
 
 
 
 
 
52
  "links": 0,
53
  "joined": "None"
54
  },
55
+ )
56
+
57
+ async def ChangeUserAccessType(self, id):
58
+ user= await self.get_user(id)
59
+ if user:
60
+ await self.users.update_one({"_id": user['_id']}, {"$set": {"access":"ADMIN" }})
61
+ else:
62
+ user = UserSchema(id)
63
+ user['access']="ADMIN"
64
+ await self.users.insert_one(user)
FileStream/bot/plugins/Admin/admin.py CHANGED
@@ -31,7 +31,6 @@ 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
- 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,6 +38,7 @@ async def add_user(c: Client, m: Message):
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:
@@ -46,7 +46,6 @@ async def add_user(c: Client, m: Message):
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,6 +53,7 @@ async def add_user(c: Client, m: Message):
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:
 
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
  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
+ details= await FileStream.get_users(user_id)
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:
 
46
 
47
  @FileStream.on_message(filters.command("add_admin") & filters.user(Telegram.OWNER_ID) )
48
  async def add_user(c: Client, m: Message):
 
49
  if await db.is_admin(m.from_user.id):
50
  if len(m.command) == 1:
51
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <user_id> </code>")
 
53
  user_id = int(m.command[1])
54
  except ValueError or UnboundLocalError:
55
  return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code>")
56
+ details= await FileStream.get_users(user_id)
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: