Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 36 additions & 39 deletions Stella/StellaGban.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ def ungban_protocol(self, user_id):
)

ReturnedJson = ReturnedData.json()
if ReturnedData.status_code == requests.codes.ok:
status = ReturnedJson['status']
operation = ReturnedJson['operation']

return (
status,
operation
)
else:
return (
'Server is currently down!',
False
)
if ReturnedData.status_code == requests.codes.ok:
status = ReturnedJson['status']
operation = ReturnedJson['operation']

return (
status,
operation
)
return (
'Server is currently down!',
False
)

def banned_list(self) -> list:
URL = f'{self.host}/admin/users/'
Expand Down Expand Up @@ -112,19 +111,18 @@ def generate_api(self, user_id, first_name, username):
)

ReturnedJson = ReturnedData.json()
if ReturnedData.status_code == requests.codes.ok:
api_key = ReturnedJson['api_key']
operation = ReturnedJson['operation']

return (
operation,
api_key
)
else:
return (
'Server is currently down!',
False
)
if ReturnedData.status_code == requests.codes.ok:
api_key = ReturnedJson['api_key']
operation = ReturnedJson['operation']

return (
operation,
api_key
)
return (
'Server is currently down!',
False
)

def promote_api(self, user_id):
URL = f'{self.host}/admin/promote/'
Expand All @@ -139,16 +137,15 @@ def promote_api(self, user_id):
)

ReturnedJson = ReturnedData.json()
if ReturnedData.status_code == requests.codes.ok:
status = ReturnedJson['status']
operation = ReturnedJson['operation']

return (
status,
operation
)
else:
return (
'Server is currently down!',
False
)
if ReturnedData.status_code == requests.codes.ok:
status = ReturnedJson['status']
operation = ReturnedJson['operation']

return (
status,
operation
)
return (
'Server is currently down!',
False
)
16 changes: 7 additions & 9 deletions Stella/database/antiflood_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def get_flood(chat_id: int) -> bool:
)
if antiflood_data is not None:
return antiflood_data['flood']
else:
return False
return False

def set_antiflood_mode(chat_id, flood_mode, until_time=None):
antiflood_data = antiflood.find_one(
Expand Down Expand Up @@ -140,10 +139,9 @@ def get_antiflood_mode(chat_id):
FloodMode,
Flood_until_time
)
else:
FloodMode = 1
Flood_until_time = None
return (
FloodMode,
Flood_until_time
)
FloodMode = 1
Flood_until_time = None
return (
FloodMode,
Flood_until_time
)
23 changes: 10 additions & 13 deletions Stella/database/blocklists_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ def getblocklistMessageDelete(chat_id) -> bool:
)
if blocklist_data is not None:
return blocklist_data['blocklistdelete']
else:
return True
return True

def setblocklistmode(chat_id, blocklist_mode, blocklist_time=None):
blocklist_data = blocklists.find_one(
Expand Down Expand Up @@ -250,23 +249,21 @@ def getblocklistmode(chat_id):
blocklist_mode = blocklist_data['blocklist_mode']['blocklist_mode']
blocklist_time = blocklist_data['blocklist_mode']['blocklist_time']
blocklist_default_reason = blocklist_data['blocklist_default_reason']

return (
blocklist_mode,
blocklist_time,
blocklist_default_reason
)
blocklist_mode = 1
blocklist_time = None
blocklist_default_reason = None

else:
blocklist_mode = 1
blocklist_time = None
blocklist_default_reason = None

return (
blocklist_mode,
blocklist_time,
blocklist_default_reason
)
return (
blocklist_mode,
blocklist_time,
blocklist_default_reason
)

def setblocklistreason_db(chat_id, reason):
blocklist_data = blocklists.find_one(
Expand Down
3 changes: 1 addition & 2 deletions Stella/database/chats_settings_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def get_anon_setting(chat_id) -> bool:
if chat_data is not None:
if 'anon_admin' in chat_data:
return chat_data['anon_admin']
else:
return False
return False
else:
return False
23 changes: 10 additions & 13 deletions Stella/database/connection_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,20 @@ def GetConnectedChat(user_id):
'user_id': user_id
}
)
if connectionData is not None:
chat_id = connectionData['connected_chat']
return chat_id
else:
return None
if connectionData is not None:
chat_id = connectionData['connected_chat']
return chat_id
return None

def isChatConnected(user_id) -> bool:
connectionData = connection.find_one(
{
'user_id': user_id
}
)
if connectionData is not None:
return connectionData['connection']
else:
return False
if connectionData is not None:
return connectionData['connection']
return False

def disconnectChat(user_id):
connection.update_one(
Expand Down Expand Up @@ -144,8 +142,7 @@ def get_allow_connection(chat_id)-> bool:
}
)
if chat_data is not None:
if 'allow_collection' in chat_data:
return chat_data['allow_collection']
else:
return False
if 'allow_collection' in chat_data:
return chat_data['allow_collection']
return False
return False
6 changes: 2 additions & 4 deletions Stella/database/disable_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def get_disabled(chat_id) -> list:

if disable_data is not None:
return disable_data['disabled_items']
else:
return []
return []

def disabledel_db(chat_id, disabledel):
disable_data = disable.find_one(
Expand Down Expand Up @@ -120,5 +119,4 @@ def get_disabledel(chat_id) -> bool:
)
if disable_data is not None:
return disable_data['disabledel']
else:
return False
return False
67 changes: 30 additions & 37 deletions Stella/database/federation_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,20 @@ def is_fed_exist(fed_id=None, owner_id=None) -> bool:
'owner_id': owner_id
}
)

if GetFed is not None:
return True
else:
return False

if GetFed is not None:
return True
return False

else:
GetFed = federation.find_one(
{
'fed_id': fed_id
}
)
if GetFed is not None:
return True
else:
return False
if GetFed is not None:
return True
return False

def join_fed_db(chat_id, chat_title, fed_id):
federation.update_one(
Expand Down Expand Up @@ -128,10 +126,9 @@ def is_user_fban(fed_id, user_id) -> bool:
for users in GetFed['banned_users']:
banned_user = users['user_id']
user_ids_list.append(banned_user)
if user_id in user_ids_list:
return True
else:
return False
if user_id in user_ids_list:
return True
return False
else:
return False
else:
Expand Down Expand Up @@ -162,23 +159,21 @@ def get_fed_from_chat(chat_id):
}
}
):
if 'fed_id' in fedData:
fed_id = fedData['fed_id']
return fed_id
else:
return None
if 'fed_id' in fedData:
fed_id = fedData['fed_id']
return fed_id
return None

def get_fed_from_ownerid(owner_id):
fedData = federation.find_one(
{
'owner_id': owner_id
}
)
if not fedData == None:
fed_id = fedData['fed_id']
return fed_id
else:
return None
if not fedData == None:
fed_id = fedData['fed_id']
return fed_id
return None

def get_fed_reason(fed_id, user_id):
fedData = federation.find_one(
Expand All @@ -200,13 +195,12 @@ def get_connected_chats(fed_id) -> list:
}
)
connected_chats = []
if 'chats' in fedData:
for chats in fedData['chats']:
chat_id = chats['chat_id']
connected_chats.append(chat_id)
return connected_chats
else:
return None
if 'chats' in fedData:
for chats in fedData['chats']:
chat_id = chats['chat_id']
connected_chats.append(chat_id)
return connected_chats
return None

def get_fed_name(fed_id=None, owner_id=None):
if fed_id == None:
Expand Down Expand Up @@ -236,13 +230,12 @@ def is_fed_creator(fed_id, owner_id) -> bool:
'fed_id': fed_id
}
)

if (
owner_id == GetFed['owner_id']
):
return True
else:
return False

if (
owner_id == GetFed['owner_id']
):
return True
return False

def fed_rename_db(owner_id, fed_name):
federation.update_one(
Expand Down
13 changes: 6 additions & 7 deletions Stella/database/filters_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ def get_filters_list(chat_id: int):
'chat_id': chat_id
}
)
if filter_data is not None:
FILTERS_NAME = list()
for filter_name in filter_data['filters']:
FILTERS_NAME.append(filter_name['filter_name'])
return FILTERS_NAME
else:
return []
if filter_data is not None:
FILTERS_NAME = list()
for filter_name in filter_data['filters']:
FILTERS_NAME.append(filter_name['filter_name'])
return FILTERS_NAME
return []
9 changes: 3 additions & 6 deletions Stella/database/locks_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def get_locks(chat_id) -> list:

if locks_data is not None:
return locks_data['locked']
else:
return []
return []

def unlock_db(chat_id, locked_item):
locks_data = locks.find_one(
Expand Down Expand Up @@ -89,8 +88,7 @@ def lockwarns_db(chat_id) -> bool:

if locks_data is not None:
return locks_data['lockwarns']
else:
return True
return True

def set_lockwarn_db(chat_id, warn_args):
locks_data = locks.find_one(
Expand Down Expand Up @@ -197,5 +195,4 @@ def get_allowlist(chat_id) -> list:
)
if locks_data is not None:
return locks_data['allow_list']
else:
return []
return []
Loading