Ultroid v0.3 Updates
Co-authored-by: Aditya <xditya@ultroid.tech> Co-authored-by: Danish <danish@ultroid.tech> Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com> Co-authored-by: TechiError <error@notavailable.live> Co-authored-by: Avish Kumar <85635883+aviskumar@users.noreply.github.com> Co-authored-by: Vɪɴᴀʏᴀᴋ Pᴀɴᴅᴇʏ <87496159+harpia-vieillot@users.noreply.github.com> Co-authored-by: Shrimadhav U K <6317196+spechide@users.noreply.github.com> Co-authored-by: Dark <darkbeamer.official@gmail.com> Co-authored-by: Muhamad Risman Aziz <62795826+mrismanaziz@users.noreply.github.com> Co-authored-by: Ashik Muhammed <84127769+MR-JINN-OF-TG@users.noreply.github.com> Co-authored-by: MMETMA <79155572+MMETMA@users.noreply.github.com> Co-authored-by: amirmehdinzri <94852182+amirmehdinzri@users.noreply.github.com>
This commit is contained in:
56
plugins/fileshare.py
Normal file
56
plugins/fileshare.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# Ultroid - UserBot
|
||||
# Copyright (C) 2021-2022 TeamUltroid
|
||||
#
|
||||
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
||||
# PLease read the GNU Affero General Public License in
|
||||
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
||||
"""
|
||||
✘ Commands Available -
|
||||
|
||||
• `{i}store <reply_to_message>`
|
||||
Store the replied message/media and generate a shareable link to that file, to be accessed via your assistant bot!
|
||||
|
||||
• `{i}liststored`
|
||||
Get all stored messages.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from pyUltroid.functions.tools import get_file_link
|
||||
|
||||
from . import asst, eor, get_string, udB, ultroid_cmd
|
||||
|
||||
|
||||
@ultroid_cmd(pattern="store")
|
||||
async def filestoreplg(event):
|
||||
msg = await event.get_reply_message()
|
||||
if msg is None:
|
||||
await event.eor(get_string("fsh_3"), time=10)
|
||||
return
|
||||
# allow storing both messages and media.
|
||||
filehash = await get_file_link(msg)
|
||||
link_to_file = "https://t.me/{}?start={}".format(asst.me.username, filehash)
|
||||
await eor(
|
||||
event,
|
||||
get_string("fsh_2").format(link_to_file),
|
||||
link_preview=False,
|
||||
)
|
||||
|
||||
|
||||
@ultroid_cmd("liststored$")
|
||||
async def liststored(event):
|
||||
get = udB.get_key("FILE_STORE") or {}
|
||||
if not get:
|
||||
await event.eor(get_string("fsh_4"), time=5)
|
||||
return
|
||||
msg = "**Stored files:**\n"
|
||||
for c, i in enumerate(list(get.keys())):
|
||||
c += 1
|
||||
msg += f"`{c}`. https://t.me/{asst.me.username}?start={i}\n"
|
||||
if len(msg) > 4095:
|
||||
with open("liststored.txt", "w") as f:
|
||||
f.write(msg.replace("**", "").replace("`", ""))
|
||||
await event.reply(get_string("fsh_1"), file="liststored.txt")
|
||||
os.remove("liststored.txt")
|
||||
return
|
||||
await event.eor(msg, link_preview=False)
|
||||
Reference in New Issue
Block a user