Skip to content

Commit

Permalink
file store for all
Browse files Browse the repository at this point in the history
  • Loading branch information
subinps committed Jan 19, 2022
1 parent 1541c1f commit d136229
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
5 changes: 1 addition & 4 deletions database/connections_mdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ async def active_connection(user_id):
return None

group_id = query['active_group']
if group_id != None:
return int(group_id)
else:
return None
return int(group_id) if group_id != None else None


async def all_connections(user_id):
Expand Down
5 changes: 1 addition & 4 deletions database/filters_mdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ async def count_filters(group_id):
mycol = mydb[str(group_id)]

count = mycol.count()
if count == 0:
return False
else:
return count
return False if count == 0 else count


async def filter_stats():
Expand Down
5 changes: 1 addition & 4 deletions database/users_chats_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ async def add_chat(self, chat, title):

async def get_chat(self, chat):
chat = await self.grp.find_one({'id':int(chat)})
if not chat:
return False
else:
return chat.get('chat_status')
return False if not chat else chat.get('chat_status')


async def re_enable_chat(self, id):
Expand Down
13 changes: 8 additions & 5 deletions plugins/genlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

@Client.on_message(filters.command(['link', 'plink']) & filters.user(ADMINS))
@Client.on_message(filters.command(['link', 'plink']))
async def gen_link_s(bot, message):
replied = message.reply_to_message
if not replied:
return await message.reply('Reply to a message to get a shareable link.')
file_type = replied.media
if file_type not in ["video", 'audio', 'document']:
return await message.reply("Reply to a supported media")
if message.has_protected_content and message.chat.id not in ADMINS:
return await message.reply("okDa")
file_id, ref = unpack_new_file_id((getattr(replied, file_type)).file_id)
string = 'filep_' if message.text.lower().strip() == "/plink" else 'file_'
string += file_id
outstr = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=")
await message.reply(f"Here is your Link:\nhttps://t.me/{temp.U_NAME}?start={outstr}")


@Client.on_message(filters.command(['batch', 'pbatch']) & filters.user(ADMINS))
@Client.on_message(filters.command(['batch', 'pbatch']))
async def gen_link_batch(bot, message):
if " " not in message.text:
return await message.reply("Use correct format.\nExample <code>/batch https://t.me/TeamEvamaria/10 https://t.me/TeamEvamaria/20</code>.")
Expand Down Expand Up @@ -69,11 +71,11 @@ async def gen_link_batch(bot, message):
string = f"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}"
b_64 = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=")
return await sts.edit(f"Here is your link https://t.me/{temp.U_NAME}?start=DSTORE-{b_64}")

FRMT = "Generating Link...\nTotal Messages: `{total}`\nDone: `{current}`\nRemaining: `{rem}`\nStatus: `{sts}`"

outlist = []

# file store without db channel
og_msg = 0
tot = 0
Expand All @@ -96,8 +98,9 @@ async def gen_link_batch(bot, message):
"caption": caption,
"title": getattr(file, "file_name", ""),
"size": file.file_size,
"protect": True if cmd.lower().strip() == "/pbatch" else False
"protect": cmd.lower().strip() == "/pbatch",
}

og_msg +=1
outlist.append(file)
except:
Expand Down

0 comments on commit d136229

Please sign in to comment.