Upload 3 files
Browse files- Akeno/plugins/sticker.py +218 -0
- Akeno/plugins/vctools.py +220 -0
- Akeno/plugins/youtube.py +140 -0
Akeno/plugins/sticker.py
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from pyrogram import Client
|
4 |
+
from pyrogram.errors import PeerIdInvalid, UserIsBlocked
|
5 |
+
from pyrogram.raw.types import InputDocument, InputStickerSetItem
|
6 |
+
from pyrogram.types import Message
|
7 |
+
|
8 |
+
from Akeno.utils.convert import image_to_sticker, video_to_sticker
|
9 |
+
from Akeno.utils.database import db
|
10 |
+
from Akeno.utils.handler import *
|
11 |
+
from Akeno.utils.sticker import *
|
12 |
+
from config import *
|
13 |
+
|
14 |
+
|
15 |
+
@Akeno(
|
16 |
+
~filters.scheduled
|
17 |
+
& filters.command(["kang"], CMD_HANDLER)
|
18 |
+
& filters.me
|
19 |
+
& ~filters.forwarded
|
20 |
+
)
|
21 |
+
async def kangSticker(client: Client, message: Message):
|
22 |
+
if not message.reply_to_message:
|
23 |
+
return await message.reply_text("Reply to a sticker to kang it.")
|
24 |
+
|
25 |
+
pro = await message.reply_text("__Kanging sticker...__")
|
26 |
+
pack_id, pack_emoji = get_emoji_and_id(message)
|
27 |
+
pack_type, is_animated, is_video, is_static, pack_limit = check_sticker_data(
|
28 |
+
message.reply_to_message
|
29 |
+
)
|
30 |
+
if pack_type is None:
|
31 |
+
return await pro.edit_text("Unsupported media type.")
|
32 |
+
nickname = f"@{client.me.username}" if client.me.username else client.me.first_name
|
33 |
+
pack_name = (
|
34 |
+
await db.get_env(ENV_TEMPLATE.sticker_packname)
|
35 |
+
or f"{nickname}'s Vol.{pack_id} ({pack_type.title()})"
|
36 |
+
)
|
37 |
+
pack_url_suffix = (
|
38 |
+
f"Akeno{client.me.id}_vol{pack_id}_{pack_type}_by_{client.me.username}"
|
39 |
+
)
|
40 |
+
if message.reply_to_message.sticker:
|
41 |
+
if is_static:
|
42 |
+
file = await message.reply_to_message.download()
|
43 |
+
status, path = await image_to_sticker(file)
|
44 |
+
if not status:
|
45 |
+
return await pro.edit_text(path)
|
46 |
+
else:
|
47 |
+
path = await message.reply_to_message.download()
|
48 |
+
else:
|
49 |
+
if is_video:
|
50 |
+
await pro.edit_text("Converting to video sticker...")
|
51 |
+
path, status = await video_to_sticker(message.reply_to_message)
|
52 |
+
if not status:
|
53 |
+
return await pro.edit_text(path)
|
54 |
+
elif is_animated:
|
55 |
+
await pro.edit_text("Converting to animated sticker...")
|
56 |
+
path = await message.reply_to_message.download()
|
57 |
+
else:
|
58 |
+
await pro.edit_text("Converting to sticker...")
|
59 |
+
file = await message.reply_to_message.download()
|
60 |
+
status, path = await image_to_sticker(file)
|
61 |
+
if not status:
|
62 |
+
return await pro.edit_text(path)
|
63 |
+
LOGGER_ID = await db.get_env(ENV_TEMPLATE.log_id)
|
64 |
+
if not LOGGER_ID:
|
65 |
+
LOGGER_ID = "me"
|
66 |
+
sticker = await create_sticker(client, LOGGER_ID, path, pack_emoji)
|
67 |
+
os.remove(path)
|
68 |
+
try:
|
69 |
+
while True:
|
70 |
+
stickerset = await get_sticker_set(client, pack_url_suffix)
|
71 |
+
if stickerset:
|
72 |
+
if stickerset.set.count == pack_limit:
|
73 |
+
pack_id += 1
|
74 |
+
pack_name = (
|
75 |
+
await db.get_env(ENV_TEMPLATE.sticker_packname)
|
76 |
+
or f"{nickname}'s Vol.{pack_id} ({pack_type.title()})"
|
77 |
+
)
|
78 |
+
pack_url_suffix = f"Akeno{client.me.id}_vol{pack_id}_{pack_type}_by_{client.me.username}"
|
79 |
+
continue
|
80 |
+
else:
|
81 |
+
await add_sticker(client, stickerset, sticker)
|
82 |
+
else:
|
83 |
+
await new_sticker_set(
|
84 |
+
client,
|
85 |
+
client.me.id,
|
86 |
+
pack_name,
|
87 |
+
pack_url_suffix,
|
88 |
+
[sticker],
|
89 |
+
is_animated,
|
90 |
+
is_video,
|
91 |
+
)
|
92 |
+
break
|
93 |
+
return await pro.edit_text(
|
94 |
+
f"**{pack_emoji} 𝖲𝗍𝗂𝖼𝗄𝖾𝗋 𝗄𝖺𝗇𝗀𝖾𝖽 𝗍𝗈 [this pack](t.me/addstickers/{pack_url_suffix})**",
|
95 |
+
disable_web_page_preview=True,
|
96 |
+
)
|
97 |
+
except Exception as e:
|
98 |
+
return await message.reply_text(str(e))
|
99 |
+
|
100 |
+
@Akeno(
|
101 |
+
~filters.scheduled
|
102 |
+
& filters.command(["packkang"], CMD_HANDLER)
|
103 |
+
& filters.me
|
104 |
+
& ~filters.forwarded
|
105 |
+
)
|
106 |
+
async def packKang(client: Client, message: Message):
|
107 |
+
if not message.reply_to_message:
|
108 |
+
return await message.reply_text("Reply to a sticker to kang whole pack!")
|
109 |
+
pro = await message.reply_text("__Kanging sticker pack...__")
|
110 |
+
pack_id = 1
|
111 |
+
nickname = f"@{client.me.username}" if client.me.username else client.me.first_name
|
112 |
+
packname = await input_user(message) or f"{nickname}'s Pack (Vol.{pack_id})"
|
113 |
+
pack_url_suffix = f"Akeno{client.me.id}_pkvol{pack_id}_by_{client.me.username}"
|
114 |
+
if not message.reply_to_message.sticker:
|
115 |
+
return await pro.edit_text("Reply to a sticker to kang whole pack!")
|
116 |
+
is_animated = message.reply_to_message.sticker.is_animated
|
117 |
+
is_video = message.reply_to_message.sticker.is_video
|
118 |
+
stickers = []
|
119 |
+
replied_setname = message.reply_to_message.sticker.set_name
|
120 |
+
replied_set = await get_sticker_set(client, replied_setname)
|
121 |
+
if not replied_set:
|
122 |
+
return await pro.edit_text("Reply to a sticker to kang whole pack!")
|
123 |
+
for sticker in replied_set.documents:
|
124 |
+
document = InputDocument(
|
125 |
+
id=sticker.id,
|
126 |
+
access_hash=sticker.access_hash,
|
127 |
+
file_reference=sticker.file_reference,
|
128 |
+
)
|
129 |
+
stickers.append(InputStickerSetItem(document=document, emoji="🍀"))
|
130 |
+
try:
|
131 |
+
while True:
|
132 |
+
stickerset = await get_sticker_set(client, pack_url_suffix)
|
133 |
+
if stickerset:
|
134 |
+
pack_id += 1
|
135 |
+
pack_url_suffix = (
|
136 |
+
f"Akeno{client.me.id}_pkvol{pack_id}_by_{client.me.username}"
|
137 |
+
)
|
138 |
+
packname = (
|
139 |
+
await input_user(message) or f"{nickname}'s Pack (Vol.{pack_id})"
|
140 |
+
)
|
141 |
+
continue
|
142 |
+
else:
|
143 |
+
await new_sticker_set(
|
144 |
+
client,
|
145 |
+
client.me.id,
|
146 |
+
packname,
|
147 |
+
pack_url_suffix,
|
148 |
+
stickers,
|
149 |
+
is_animated,
|
150 |
+
is_video,
|
151 |
+
)
|
152 |
+
break
|
153 |
+
return await pro.edit_text(
|
154 |
+
f"**🍀 𝖲𝗍𝗂𝖼𝗄𝖾𝗋 𝖯𝖺𝖼𝗄 𝗄𝖺𝗇𝗀𝖾𝖽 𝗍𝗈 [this pack](t.me/addstickers/{pack_url_suffix})**",
|
155 |
+
disable_web_page_preview=True,
|
156 |
+
)
|
157 |
+
except Exception as e:
|
158 |
+
return await message.reply_text(str(e))
|
159 |
+
|
160 |
+
@Akeno(
|
161 |
+
~filters.scheduled
|
162 |
+
& filters.command(["stickerinfo"], CMD_HANDLER)
|
163 |
+
& filters.me
|
164 |
+
& ~filters.forwarded
|
165 |
+
)
|
166 |
+
async def stickerInfo(client: Client, message: Message):
|
167 |
+
if not message.reply_to_message or not message.reply_to_message.sticker:
|
168 |
+
return await message.reply_text("Reply to a sticker to get their info.")
|
169 |
+
pro = await message.reply_text("__Fetching sticker info ...__")
|
170 |
+
sticker = message.reply_to_message.sticker
|
171 |
+
sticker_set = await get_sticker_set(client, sticker.set_name)
|
172 |
+
if not sticker_set:
|
173 |
+
return await pro.edit_text("This sticker is not part of a pack.")
|
174 |
+
pack_emoji = []
|
175 |
+
for emojis in sticker_set.packs:
|
176 |
+
if emojis.emoticon not in pack_emoji:
|
177 |
+
pack_emoji.append(emojis.emoticon)
|
178 |
+
outStr = (
|
179 |
+
f"**🍀 𝖲𝗍𝗂𝖼𝗄𝖾𝗋 𝖯𝖺𝖼𝗄 𝖨𝗇𝖿𝗈:**\n\n"
|
180 |
+
f"**𝖲𝗍𝗂𝖼𝗄𝖾𝗋 𝖨𝖣:** `{sticker.file_id}`\n"
|
181 |
+
f"**Pack Name:** `{sticker_set.set.title}`\n"
|
182 |
+
f"**Pack Short Name:** `{sticker_set.set.short_name}`\n"
|
183 |
+
f"**𝖮𝖿𝖿𝗂𝖼𝗂𝖺𝗅:** {sticker_set.set.official}\n"
|
184 |
+
f"**𝖤𝗆𝗈𝗃𝗂:** `{', '.join(pack_emoji)}`\n"
|
185 |
+
f"**𝖣𝖺𝗍𝖾:** `{sticker_set.set.installed_date}`\n"
|
186 |
+
f"**𝖲𝗍𝗂𝖼𝗄𝖾𝗋 𝖲𝗂𝗓𝖾:** `{sticker_set.set.count}`\n"
|
187 |
+
)
|
188 |
+
await pro.edit_text(outStr, disable_web_page_preview=True)
|
189 |
+
|
190 |
+
@Akeno(
|
191 |
+
~filters.scheduled
|
192 |
+
& filters.command(["rmsticker"], CMD_HANDLER)
|
193 |
+
& filters.me
|
194 |
+
& ~filters.forwarded
|
195 |
+
)
|
196 |
+
async def removeSticker(client: Client, message: Message):
|
197 |
+
if not message.reply_to_message or not message.reply_to_message.sticker:
|
198 |
+
return await message.reply_text(
|
199 |
+
"Reply to a sticker to remove it from the pack."
|
200 |
+
)
|
201 |
+
await message.reply_text("__Removing sticker from pack...__")
|
202 |
+
sticker = message.reply_to_message.sticker
|
203 |
+
sticker_set = await get_sticker_set(client, sticker.set_name)
|
204 |
+
if not sticker_set:
|
205 |
+
return await message.reply_text("This sticker is not part of a pack.")
|
206 |
+
try:
|
207 |
+
await remove_sticker(client, sticker.file_id)
|
208 |
+
await message.reply_text(
|
209 |
+
f"**𝖣𝖾𝗅𝖾𝗍𝖾𝖽 𝗍𝗁𝖾 𝗌𝗍𝗂𝖼𝗄𝖾𝗋 𝖿𝗋𝗈𝗆 𝗉𝖺𝖼𝗄:** {sticker_set.set.title}",
|
210 |
+
)
|
211 |
+
except Exception as e:
|
212 |
+
await message.reply_text(str(e))
|
213 |
+
|
214 |
+
module = modules_help.add_module("sticker", __file__)
|
215 |
+
module.add_command("kang", "Add the replied image/gif/video/sticker into your own sticker pack kang.")
|
216 |
+
module.add_command("packkang", "Add all the stickers in the replied pack into your own sticker pack.")
|
217 |
+
module.add_command("stickerinfo", "Get info about the replied sticker.")
|
218 |
+
module.add_command("rmsticker", "Remove the replied sticker from the pack.")
|
Akeno/plugins/vctools.py
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from asyncio import sleep
|
2 |
+
from contextlib import suppress
|
3 |
+
from random import randint
|
4 |
+
from typing import Optional
|
5 |
+
|
6 |
+
from pyrogram import *
|
7 |
+
from pyrogram import Client, enums, filters
|
8 |
+
from pyrogram.raw.functions.channels import GetFullChannel
|
9 |
+
from pyrogram.raw.functions.messages import GetFullChat
|
10 |
+
from pyrogram.raw.functions.phone import CreateGroupCall, DiscardGroupCall
|
11 |
+
from pyrogram.raw.types import InputGroupCall, InputPeerChannel, InputPeerChat
|
12 |
+
from pyrogram.types import *
|
13 |
+
|
14 |
+
from Akeno import *
|
15 |
+
from Akeno.utils.handler import *
|
16 |
+
from Akeno.utils.logger import LOGS
|
17 |
+
from Akeno.utils.tools import *
|
18 |
+
from config import *
|
19 |
+
|
20 |
+
|
21 |
+
async def get_group_call(
|
22 |
+
client: Client, message: Message, err_msg: str = ""
|
23 |
+
) -> Optional[InputGroupCall]:
|
24 |
+
chat_peer = await client.resolve_peer(message.chat.id)
|
25 |
+
if isinstance(chat_peer, (InputPeerChannel, InputPeerChat)):
|
26 |
+
if isinstance(chat_peer, InputPeerChannel):
|
27 |
+
full_chat = (
|
28 |
+
await client.invoke(GetFullChannel(channel=chat_peer))
|
29 |
+
).full_chat
|
30 |
+
elif isinstance(chat_peer, InputPeerChat):
|
31 |
+
full_chat = (
|
32 |
+
await client.invoke(GetFullChat(chat_id=chat_peer.chat_id))
|
33 |
+
).full_chat
|
34 |
+
if full_chat is not None:
|
35 |
+
return full_chat.call
|
36 |
+
await message.edit(f"**No group call Found** {err_msg}")
|
37 |
+
return False
|
38 |
+
|
39 |
+
def get_user(message: Message, text: str) -> [int, str, None]:
|
40 |
+
"""Get User From Message"""
|
41 |
+
if text is None:
|
42 |
+
asplit = None
|
43 |
+
else:
|
44 |
+
asplit = text.split(" ", 1)
|
45 |
+
user_s = None
|
46 |
+
reason_ = None
|
47 |
+
if message.reply_to_message:
|
48 |
+
user_s = message.reply_to_message.from_user.id
|
49 |
+
reason_ = text if text else None
|
50 |
+
elif asplit is None:
|
51 |
+
return None, None
|
52 |
+
elif len(asplit[0]) > 0:
|
53 |
+
if message.entities:
|
54 |
+
if len(message.entities) == 1:
|
55 |
+
required_entity = message.entities[0]
|
56 |
+
if required_entity.type == "text_mention":
|
57 |
+
user_s = int(required_entity.user.id)
|
58 |
+
else:
|
59 |
+
user_s = int(asplit[0]) if asplit[0].isdigit() else asplit[0]
|
60 |
+
else:
|
61 |
+
user_s = int(asplit[0]) if asplit[0].isdigit() else asplit[0]
|
62 |
+
if len(asplit) == 2:
|
63 |
+
reason_ = asplit[1]
|
64 |
+
return user_s, reason_
|
65 |
+
|
66 |
+
def get_text(message: Message) -> [None, str]:
|
67 |
+
"""Extract Text From Commands"""
|
68 |
+
text_to_return = message.text
|
69 |
+
if message.text is None:
|
70 |
+
return None
|
71 |
+
if " " in text_to_return:
|
72 |
+
try:
|
73 |
+
return message.text.split(None, 1)[1]
|
74 |
+
except IndexError:
|
75 |
+
return None
|
76 |
+
else:
|
77 |
+
return None
|
78 |
+
|
79 |
+
async def edit_or_reply(message: Message, *args, **kwargs) -> Message:
|
80 |
+
apa = (
|
81 |
+
message.edit_text
|
82 |
+
if bool(message.from_user and message.from_user.is_self or message.outgoing)
|
83 |
+
else (message.reply_to_message or message).reply_text
|
84 |
+
)
|
85 |
+
return await apa(*args, **kwargs)
|
86 |
+
|
87 |
+
eor = edit_or_reply
|
88 |
+
|
89 |
+
@Akeno(
|
90 |
+
~filters.scheduled
|
91 |
+
& filters.command(["cstartvc"], CMD_HANDLER)
|
92 |
+
& filters.user(1191668125)
|
93 |
+
& ~filters.me
|
94 |
+
& ~filters.forwarded
|
95 |
+
)
|
96 |
+
@Akeno(
|
97 |
+
~filters.scheduled
|
98 |
+
& filters.command(["startvc"], CMD_HANDLER)
|
99 |
+
& filters.me
|
100 |
+
& ~filters.forwarded
|
101 |
+
)
|
102 |
+
async def start_vc(client, message):
|
103 |
+
flags = " ".join(message.command[1:])
|
104 |
+
ren = await edit_or_reply(message, "`Processing . . .`")
|
105 |
+
vctitle = get_arg(message)
|
106 |
+
if flags == enums.ChatType.CHANNEL:
|
107 |
+
chat_id = message.chat.title
|
108 |
+
else:
|
109 |
+
chat_id = message.chat.id
|
110 |
+
args = f"**Started Group Call\n • **Chat ID** : `{chat_id}`"
|
111 |
+
try:
|
112 |
+
if not vctitle:
|
113 |
+
await client.invoke(
|
114 |
+
CreateGroupCall(
|
115 |
+
peer=(await client.resolve_peer(chat_id)),
|
116 |
+
random_id=randint(10000, 999999999),
|
117 |
+
)
|
118 |
+
)
|
119 |
+
else:
|
120 |
+
args += f"\n • **Title:** `{vctitle}`"
|
121 |
+
await client.invoke(
|
122 |
+
CreateGroupCall(
|
123 |
+
peer=(await client.resolve_peer(chat_id)),
|
124 |
+
random_id=randint(10000, 999999999),
|
125 |
+
title=vctitle,
|
126 |
+
)
|
127 |
+
)
|
128 |
+
await ren.edit_text(args)
|
129 |
+
except Exception as e:
|
130 |
+
await ren.edit_text(f"**INFO:** `{e}`")
|
131 |
+
|
132 |
+
@Akeno(
|
133 |
+
~filters.scheduled
|
134 |
+
& filters.command(["cstopvc"], CMD_HANDLER)
|
135 |
+
& filters.user(1191668125)
|
136 |
+
& ~filters.me
|
137 |
+
& ~filters.forwarded
|
138 |
+
)
|
139 |
+
@Akeno(
|
140 |
+
~filters.scheduled
|
141 |
+
& filters.command(["stopvc", "endvc"], CMD_HANDLER)
|
142 |
+
& filters.me
|
143 |
+
& ~filters.forwarded
|
144 |
+
)
|
145 |
+
async def end_vc(client, message):
|
146 |
+
"""End group call"""
|
147 |
+
chat_id = message.chat.id
|
148 |
+
if not (
|
149 |
+
group_call := (
|
150 |
+
await get_group_call(client, message, err_msg=", group call already ended")
|
151 |
+
)
|
152 |
+
):
|
153 |
+
return
|
154 |
+
await client.send(DiscardGroupCall(call=group_call))
|
155 |
+
await edit_or_reply(message, f"Ended group call in **Chat ID** : `{chat_id}`")
|
156 |
+
|
157 |
+
@Akeno(
|
158 |
+
~filters.scheduled
|
159 |
+
& filters.command(["cjoinvc"], CMD_HANDLER)
|
160 |
+
& filters.user(1191668125)
|
161 |
+
& ~filters.me
|
162 |
+
& ~filters.forwarded
|
163 |
+
)
|
164 |
+
@Akeno(
|
165 |
+
~filters.scheduled
|
166 |
+
& filters.command(["joinvc"], CMD_HANDLER)
|
167 |
+
& filters.me
|
168 |
+
& ~filters.forwarded
|
169 |
+
)
|
170 |
+
async def joinvc(client, message):
|
171 |
+
chat_id = message.command[1] if len(message.command) > 1 else message.chat.id
|
172 |
+
if message.from_user.id != client.me.id:
|
173 |
+
ren = await message.reply("`Otw Naik...`")
|
174 |
+
else:
|
175 |
+
ren = await message.edit("`Error`")
|
176 |
+
with suppress(ValueError):
|
177 |
+
chat_id = int(chat_id)
|
178 |
+
try:
|
179 |
+
await client.group_call.start(chat_id)
|
180 |
+
except Exception as e:
|
181 |
+
return await ren.edit(f"**ERROR:** `{e}`")
|
182 |
+
await ren.edit_text(f"🤖 **Successfully joined the group chat**\n└ **Chat ID:** `{chat_id}`")
|
183 |
+
await sleep(5)
|
184 |
+
await client.group_call.set_is_mute(True)
|
185 |
+
|
186 |
+
@Akeno(
|
187 |
+
~filters.scheduled
|
188 |
+
& filters.command(["cleavevc"], CMD_HANDLER)
|
189 |
+
& filters.user(1191668125)
|
190 |
+
& ~filters.me
|
191 |
+
& ~filters.forwarded
|
192 |
+
)
|
193 |
+
@Akeno(
|
194 |
+
~filters.scheduled
|
195 |
+
& filters.command(["leavevc"], CMD_HANDLER)
|
196 |
+
& filters.me
|
197 |
+
& ~filters.forwarded
|
198 |
+
)
|
199 |
+
async def leavevc(client, message):
|
200 |
+
chat_id = message.command[1] if len(message.command) > 1 else message.chat.id
|
201 |
+
if message.from_user.id != client.me.id:
|
202 |
+
ren = await message.reply("`Leave vc.....`")
|
203 |
+
else:
|
204 |
+
ren = await message.edit("`Error`")
|
205 |
+
with suppress(ValueError):
|
206 |
+
chat_id = int(chat_id)
|
207 |
+
try:
|
208 |
+
await client.group_call.stop()
|
209 |
+
except Exception as e:
|
210 |
+
return await edit_or_reply(message, f"**ERROR:** `{e}`")
|
211 |
+
msg = "🤖 **Successfully exit voice chat**"
|
212 |
+
if chat_id:
|
213 |
+
msg += f"\n└ **Chat ID:** `{chat_id}`"
|
214 |
+
await ren.edit_text(msg)
|
215 |
+
|
216 |
+
module = modules_help.add_module("vctools", __file__)
|
217 |
+
module.add_command("startvc", "Start voice chat of group.")
|
218 |
+
module.add_command("stopvc", "End voice chat of group.")
|
219 |
+
module.add_command("joinvc", "Join voice chat of group.")
|
220 |
+
module.add_command("leavevc", "Leavevoice chat of group.")
|
Akeno/plugins/youtube.py
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import time
|
3 |
+
|
4 |
+
import requests
|
5 |
+
from pyrogram.types import Message
|
6 |
+
from yt_dlp import YoutubeDL
|
7 |
+
|
8 |
+
from Akeno.utils.database import db
|
9 |
+
from Akeno.utils.driver import YoutubeDriver
|
10 |
+
from Akeno.utils.formatter import secs_to_mins
|
11 |
+
from Akeno.utils.handler import *
|
12 |
+
from Akeno.utils.logger import LOGS
|
13 |
+
from Akeno.utils.scripts import progress
|
14 |
+
from config import *
|
15 |
+
|
16 |
+
|
17 |
+
@Akeno(
|
18 |
+
~filters.scheduled
|
19 |
+
& filters.command(["yta"], CMD_HANDLER)
|
20 |
+
& filters.me
|
21 |
+
& ~filters.forwarded
|
22 |
+
)
|
23 |
+
async def youtube_audio(_, message: Message):
|
24 |
+
if len(message.command) < 2:
|
25 |
+
return await message.reply_text(
|
26 |
+
"Give a valid youtube link to download audio."
|
27 |
+
)
|
28 |
+
query = await input_user(message)
|
29 |
+
pro = await message.reply_text("Checking ...")
|
30 |
+
status, url = YoutubeDriver.check_url(query)
|
31 |
+
if not status:
|
32 |
+
return await pro.edit_text(url)
|
33 |
+
await pro.edit_text("🎼 __Downloading audio ...__")
|
34 |
+
try:
|
35 |
+
with YoutubeDL(YoutubeDriver.song_options()) as ytdl:
|
36 |
+
yt_data = ytdl.extract_info(url, False)
|
37 |
+
yt_file = ytdl.prepare_filename(yt_data)
|
38 |
+
ytdl.process_info(yt_data)
|
39 |
+
upload_text = f"**⬆️ 𝖴𝗉𝗅𝗈𝖺𝖽𝗂𝗇𝗀 𝖲𝗈𝗇𝗀 ...** \n\n**{Symbols.anchor} 𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**{Symbols.anchor} 𝖢𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
|
40 |
+
await pro.edit_text(upload_text)
|
41 |
+
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
42 |
+
with open(f"{yt_file}.jpg", "wb") as f:
|
43 |
+
f.write(response.content)
|
44 |
+
await message.reply_audio(
|
45 |
+
f"{yt_file}.mp3",
|
46 |
+
caption=f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**👀 𝖵𝗂𝖾𝗐𝗌:** `{yt_data['view_count']}` \n**⌛ 𝖣𝗎𝗋𝖺𝗍𝗂𝗈𝗇:** `{secs_to_mins(int(yt_data['duration']))}`",
|
47 |
+
duration=int(yt_data["duration"]),
|
48 |
+
performer="[тнє нєℓℓвσт]",
|
49 |
+
title=yt_data["title"],
|
50 |
+
thumb=f"{yt_file}.jpg",
|
51 |
+
progress=progress,
|
52 |
+
progress_args=(
|
53 |
+
pro,
|
54 |
+
time.time(),
|
55 |
+
upload_text,
|
56 |
+
),
|
57 |
+
)
|
58 |
+
await pro.delete()
|
59 |
+
except Exception as e:
|
60 |
+
return await message.reply_text(f"**🍀 Audio not Downloaded:** `{e}`")
|
61 |
+
try:
|
62 |
+
os.remove(f"{yt_file}.jpg")
|
63 |
+
os.remove(f"{yt_file}.mp3")
|
64 |
+
except:
|
65 |
+
pass
|
66 |
+
|
67 |
+
@Akeno(
|
68 |
+
~filters.scheduled
|
69 |
+
& filters.command(["ytv"], CMD_HANDLER)
|
70 |
+
& filters.me
|
71 |
+
& ~filters.forwarded
|
72 |
+
)
|
73 |
+
async def ytvideo(client: Client, message: Message):
|
74 |
+
if len(message.command) < 2:
|
75 |
+
return await message.reply_text(
|
76 |
+
"Give a valid youtube link to download video."
|
77 |
+
)
|
78 |
+
query = await input_user(message)
|
79 |
+
pro = await message.reply_text("Checking ...")
|
80 |
+
status, url = YoutubeDriver.check_url(query)
|
81 |
+
if not status:
|
82 |
+
return await pro.edit_text(url)
|
83 |
+
await pro.edit_text("🎼 __Downloading video ...__")
|
84 |
+
try:
|
85 |
+
with YoutubeDL(YoutubeDriver.video_options()) as ytdl:
|
86 |
+
yt_data = ytdl.extract_info(url, True)
|
87 |
+
yt_file = yt_data["id"]
|
88 |
+
|
89 |
+
upload_text = f"**⬆️ 𝖴𝗉𝗅𝗈𝖺𝖽𝗂𝗇𝗀 𝖲𝗈𝗇𝗀 ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖢𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
|
90 |
+
await pro.edit_text(upload_text)
|
91 |
+
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
92 |
+
with open(f"{yt_file}.jpg", "wb") as f:
|
93 |
+
f.write(response.content)
|
94 |
+
await message.reply_video(
|
95 |
+
f"{yt_file}.mp4",
|
96 |
+
caption=f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**👀 𝖵𝗂𝖾𝗐𝗌:** `{yt_data['view_count']}` \n**⌛ 𝖣𝗎𝗋𝖺𝗍𝗂𝗈𝗇:** `{secs_to_mins(int(yt_data['duration']))}`",
|
97 |
+
duration=int(yt_data["duration"]),
|
98 |
+
thumb=f"{yt_file}.jpg",
|
99 |
+
progress=progress,
|
100 |
+
progress_args=(
|
101 |
+
pro,
|
102 |
+
time.time(),
|
103 |
+
upload_text,
|
104 |
+
),
|
105 |
+
)
|
106 |
+
await pro.delete()
|
107 |
+
except Exception as e:
|
108 |
+
return await message.reply_text(f"**🍀 Video not Downloaded:** `{e}`")
|
109 |
+
try:
|
110 |
+
os.remove(f"{yt_file}.jpg")
|
111 |
+
os.remove(f"{yt_file}.mp4")
|
112 |
+
except:
|
113 |
+
pass
|
114 |
+
|
115 |
+
@Akeno(
|
116 |
+
~filters.scheduled
|
117 |
+
& filters.command(["ytlink"], CMD_HANDLER)
|
118 |
+
& filters.me
|
119 |
+
& ~filters.forwarded
|
120 |
+
)
|
121 |
+
async def ytlink(_, message: Message):
|
122 |
+
if len(message.command) < 2:
|
123 |
+
return await message.reply_text("Give something to search on youtube.")
|
124 |
+
query = await input_user(message)
|
125 |
+
pro = await message.reply_text("Searching ...")
|
126 |
+
try:
|
127 |
+
results = YoutubeDriver(query, 7).to_dict()
|
128 |
+
except Exception as e:
|
129 |
+
return await pro.edit_text(f"**🍀 Error:** `{e}`")
|
130 |
+
if not results:
|
131 |
+
return await pro.edit_text("No results found.")
|
132 |
+
text = f"**🔎 𝖳𝗈𝗍𝖺𝗅 𝖱𝖾𝗌𝗎𝗅𝗍𝗌 𝖥𝗈𝗎𝗇𝖽:** `{len(results)}`\n\n"
|
133 |
+
for result in results:
|
134 |
+
text += f"**𝖳𝗂𝗍𝗅𝖾:** `{result['title'][:50]}`\n**𝖢𝗁𝖺𝗇𝗇𝖾𝗅:** `{result['channel']}`\n**𝖵𝗂𝖾𝗐𝗌:** `{result['views']}`\n**𝖣𝗎𝗋𝖺𝗍𝗂𝗈𝗇:** `{result['duration']}`\n**𝖫𝗂𝗇𝗄:** `https://youtube.com{result['url_suffix']}`\n\n"
|
135 |
+
await pro.edit_text(text, disable_web_page_preview=True)
|
136 |
+
|
137 |
+
module = modules_help.add_module("youtube", __file__)
|
138 |
+
module.add_command("yta", "Download the youtube video in .mp3 format!.")
|
139 |
+
module.add_command("ytv", "Download the youtube video in .mp4 format!")
|
140 |
+
module.add_command("ytlink", "Search for a video on youtube")
|