taslim19 commited on
Commit
8a2b961
·
1 Parent(s): 28baa10

Add waifu_name.py: /waifus command to get waifu name from channel using userbot

Browse files
DragMusic/plugins/management/waifu_name.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyrogram import filters
2
+ from DragMusic import app
3
+ from DragMusic.core.userbot import Userbot
4
+
5
+ WAIFU_CHANNEL_ID = -1001898471378 # Your waifu database channel ID
6
+
7
+ async def get_waifu_name_by_file_id(file_id):
8
+ userbot = Userbot().one
9
+ async with userbot:
10
+ async for msg in userbot.get_chat_history(WAIFU_CHANNEL_ID):
11
+ if msg.photo and msg.photo.file_id == file_id:
12
+ return msg.caption # This is the waifu's name
13
+ return None
14
+
15
+ @app.on_message(filters.command("waifus") & filters.reply)
16
+ async def waifus_name(client, message):
17
+ if not message.reply_to_message or not message.reply_to_message.photo:
18
+ return await message.reply("Reply to a waifu image to get the name!")
19
+ file_id = message.reply_to_message.photo.file_id
20
+ waifu_name = await get_waifu_name_by_file_id(file_id)
21
+ if waifu_name:
22
+ await message.reply(f"The waifu's name is: {waifu_name}")
23
+ else:
24
+ await message.reply("Waifu not found in the database channel!")