Spaces:
Running
Running
taslim19
commited on
Commit
·
30a00bc
1
Parent(s):
4f7440f
feat: implement join requests and restructure plugins
Browse files- DragMusic/plugins/bot/approve.text +0 -28
- DragMusic/plugins/bot/fakeinfo.py +0 -47
- DragMusic/plugins/bot/join_requests.py +103 -0
- DragMusic/plugins/bot/mustjoin.py +1 -23
- DragMusic/plugins/bot/start.py +99 -118
- DragMusic/plugins/{misc → games}/love.py +0 -0
- DragMusic/plugins/{misc → games}/truth_dare.py +0 -0
- DragMusic/plugins/plugins/Gemini.txt +0 -35
- DragMusic/plugins/plugins/ask.py +0 -34
- DragMusic/plugins/plugins/brave.py +0 -42
- DragMusic/plugins/plugins/getimg.py +0 -59
- DragMusic/plugins/plugins/gpt.py +0 -74
DragMusic/plugins/bot/approve.text
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
from DragMusic import app
|
2 |
-
from os import environ
|
3 |
-
from pyrogram import Client, filters
|
4 |
-
from pyrogram.types import ChatJoinRequest
|
5 |
-
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
6 |
-
|
7 |
-
EVAA = [
|
8 |
-
[
|
9 |
-
InlineKeyboardButton(text="ᴀᴅᴅ ᴍᴇ ʙᴀʙʏ", url=f"https://t.me/DragMusicBot?startgroup=true"),
|
10 |
-
],
|
11 |
-
]
|
12 |
-
|
13 |
-
# Extract environment variables or provide default values
|
14 |
-
chat_id_env = environ.get("CHAT_ID")
|
15 |
-
CHAT_ID = [int(app) for app in chat_id_env.split(",")] if chat_id_env else []
|
16 |
-
|
17 |
-
TEXT = environ.get("APPROVED_WELCOME_TEXT", "❅ ʜᴇʟʟᴏ ʙᴀʙʏ {mention}\n\n❅ ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ {title}\n\n")
|
18 |
-
APPROVED = environ.get("APPROVED_WELCOME", "on").lower()
|
19 |
-
|
20 |
-
# Define an event handler for chat join requests
|
21 |
-
@app.on_chat_join_request((filters.group | filters.channel) & filters.chat(CHAT_ID) if CHAT_ID else (filters.group | filters.channel))
|
22 |
-
async def autoapprove(client: app, message: ChatJoinRequest):
|
23 |
-
chat = message.chat # Chat
|
24 |
-
user = message.from_user # User
|
25 |
-
print(f"๏ {user.first_name} ᴊᴏɪɴᴇᴅ 🤝") # Logs
|
26 |
-
await client.approve_chat_join_request(chat_id=chat.id, user_id=user.id)
|
27 |
-
if APPROVED == "on":
|
28 |
-
await client.send_message(chat_id=chat.id, text=TEXT.format(mention=user.mention, title=chat.title),reply_markup=InlineKeyboardMarkup(EVAA),)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/bot/fakeinfo.py
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
from DragMusic import app as Checker
|
3 |
-
from pyrogram import filters
|
4 |
-
|
5 |
-
|
6 |
-
@Checker.on_message(filters.command("fake"))
|
7 |
-
async def address(_, message):
|
8 |
-
message_text = message.text.strip()
|
9 |
-
words = message_text.split()
|
10 |
-
|
11 |
-
if len(words) > 1:
|
12 |
-
query = words[1].strip()
|
13 |
-
url = f"https://randomuser.me/api/?nat={query}"
|
14 |
-
response = requests.get(url)
|
15 |
-
data = response.json()
|
16 |
-
|
17 |
-
if "results" in data:
|
18 |
-
user_data = data["results"][0]
|
19 |
-
|
20 |
-
|
21 |
-
name = f"{user_data['name']['title']} {user_data['name']['first']} {user_data['name']['last']}"
|
22 |
-
address = f"{user_data['location']['street']['number']} {user_data['location']['street']['name']}"
|
23 |
-
city = user_data['location']['city']
|
24 |
-
state = user_data['location']['state']
|
25 |
-
country = user_data['location']['country']
|
26 |
-
postal = user_data['location']['postcode']
|
27 |
-
email = user_data['email']
|
28 |
-
phone = user_data['phone']
|
29 |
-
picture_url = user_data['picture']['large']
|
30 |
-
|
31 |
-
|
32 |
-
caption = f"""
|
33 |
-
﹝⌬﹞**ɴᴀᴍᴇ** ⇢ {name}
|
34 |
-
﹝⌬﹞**ᴀᴅᴅʀᴇss** ⇢ {address}
|
35 |
-
﹝⌬﹞**ᴄᴏᴜɴᴛʀʏ** ⇢ {country}
|
36 |
-
﹝⌬﹞**ᴄɪᴛʏ** ⇢ {city}
|
37 |
-
﹝⌬﹞**sᴛᴀᴛᴇ** ⇢ {state}
|
38 |
-
﹝⌬﹞**ᴘᴏsᴛᴀʟ** ⇢ {postal}
|
39 |
-
﹝⌬﹞**ᴇᴍᴀɪʟ** ⇢ {email}
|
40 |
-
﹝⌬﹞**ᴘʜᴏɴᴇ** ⇢ {phone}
|
41 |
-
|
42 |
-
"""
|
43 |
-
|
44 |
-
|
45 |
-
await message.reply_photo(photo=picture_url, caption=caption)
|
46 |
-
else:
|
47 |
-
await message.reply_text("ᴏᴏᴘs ɴᴏᴛ ғᴏᴜɴᴅ ᴀɴʏ ᴀᴅᴅʀᴇss.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/bot/join_requests.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from DragMusic import app
|
2 |
+
from pyrogram import filters
|
3 |
+
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, ChatPermissions
|
4 |
+
|
5 |
+
# A dictionary to store the message ID of the join request notification
|
6 |
+
join_request_message = {}
|
7 |
+
|
8 |
+
@app.on_chat_join_request()
|
9 |
+
async def D_A_X_X(_, message):
|
10 |
+
try:
|
11 |
+
chat = message.chat
|
12 |
+
user = message.from_user
|
13 |
+
|
14 |
+
# Check if the bot is an admin in the chat
|
15 |
+
bot_member = await app.get_chat_member(chat.id, (await app.get_me()).id)
|
16 |
+
if not bot_member.privileges.can_invite_users:
|
17 |
+
# Silently ignore if the bot can't manage join requests
|
18 |
+
return
|
19 |
+
|
20 |
+
# Send join request notification to the group
|
21 |
+
msg = await app.send_message(
|
22 |
+
chat.id,
|
23 |
+
f"""
|
24 |
+
ɴᴇᴡ ᴊᴏɪɴ ʀᴇǫᴜᴇsᴛ
|
25 |
+
|
26 |
+
ᴜsᴇʀ : {user.mention}
|
27 |
+
ᴜsᴇʀɴᴀᴍᴇ : @{user.username}
|
28 |
+
ᴜsᴇʀ ɪᴅ : {user.id}
|
29 |
+
""",
|
30 |
+
reply_markup=InlineKeyboardMarkup(
|
31 |
+
[
|
32 |
+
[
|
33 |
+
InlineKeyboardButton(
|
34 |
+
"ᴀᴘᴘʀᴏᴠᴇ", callback_data=f"j_approve_{chat.id}_{user.id}"
|
35 |
+
),
|
36 |
+
InlineKeyboardButton(
|
37 |
+
"ʀᴇᴊᴇᴄᴛ", callback_data=f"j_reject_{chat.id}_{user.id}"
|
38 |
+
),
|
39 |
+
]
|
40 |
+
]
|
41 |
+
),
|
42 |
+
)
|
43 |
+
join_request_message[user.id] = msg.id
|
44 |
+
|
45 |
+
except Exception as e:
|
46 |
+
print(f"Error in chat_join_request handler: {e}")
|
47 |
+
|
48 |
+
async def is_admin(chat_id, user_id):
|
49 |
+
try:
|
50 |
+
member = await app.get_chat_member(chat_id, user_id)
|
51 |
+
return member.privileges is not None
|
52 |
+
except Exception:
|
53 |
+
return False
|
54 |
+
|
55 |
+
@app.on_callback_query(filters.regex("j_approve_(.*)"))
|
56 |
+
async def approve_request(_, query):
|
57 |
+
try:
|
58 |
+
chat_id, user_id = query.data.split("_")[2:]
|
59 |
+
chat_id = int(chat_id)
|
60 |
+
user_id = int(user_id)
|
61 |
+
|
62 |
+
user_who_pressed = query.from_user
|
63 |
+
|
64 |
+
if not await is_admin(chat_id, user_who_pressed.id):
|
65 |
+
await query.answer("ᴛʜɪs ɪs ɴᴏᴛ ғᴏʀ ʏᴏᴜ.", show_alert=True)
|
66 |
+
return
|
67 |
+
|
68 |
+
await app.approve_chat_join_request(chat_id, user_id)
|
69 |
+
|
70 |
+
original_message_id = join_request_message.pop(user_id, None)
|
71 |
+
if original_message_id:
|
72 |
+
original_message = await app.get_messages(chat_id, original_message_id)
|
73 |
+
await original_message.edit_text(
|
74 |
+
f"{original_message.text}\n\n**sᴛᴀᴛᴜs :** ᴀᴘᴘʀᴏᴠᴇᴅ ✅\n**ʙʏ :** {user_who_pressed.mention}"
|
75 |
+
)
|
76 |
+
except Exception as e:
|
77 |
+
await query.answer(f"An error occurred: {e}", show_alert=True)
|
78 |
+
print(f"Error in approve_request handler: {e}")
|
79 |
+
|
80 |
+
@app.on_callback_query(filters.regex("j_reject_(.*)"))
|
81 |
+
async def reject_request(_, query):
|
82 |
+
try:
|
83 |
+
chat_id, user_id = query.data.split("_")[2:]
|
84 |
+
chat_id = int(chat_id)
|
85 |
+
user_id = int(user_id)
|
86 |
+
|
87 |
+
user_who_pressed = query.from_user
|
88 |
+
|
89 |
+
if not await is_admin(chat_id, user_who_pressed.id):
|
90 |
+
await query.answer("ᴛʜɪs ɪs ɴᴏᴛ ғᴏʀ ʏᴏᴜ.", show_alert=True)
|
91 |
+
return
|
92 |
+
|
93 |
+
await app.decline_chat_join_request(chat_id, user_id)
|
94 |
+
|
95 |
+
original_message_id = join_request_message.pop(user_id, None)
|
96 |
+
if original_message_id:
|
97 |
+
original_message = await app.get_messages(chat_id, original_message_id)
|
98 |
+
await original_message.edit_text(
|
99 |
+
f"{original_message.text}\n\n**sᴛᴀᴛᴜs :** ʀᴇᴊᴇᴄᴛᴇᴅ ❌\n**ʙʏ :** {user_who_pressed.mention}"
|
100 |
+
)
|
101 |
+
except Exception as e:
|
102 |
+
await query.answer(f"An error occurred: {e}", show_alert=True)
|
103 |
+
print(f"Error in reject_request handler: {e}")
|
DragMusic/plugins/bot/mustjoin.py
CHANGED
@@ -1,30 +1,8 @@
|
|
1 |
-
import random
|
2 |
from pyrogram import Client, filters
|
3 |
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
4 |
from pyrogram.errors import ChatAdminRequired, UserNotParticipant, ChatWriteForbidden
|
5 |
from DragMusic import app
|
6 |
|
7 |
-
MISHI = [
|
8 |
-
"https://graph.org/file/f86b71018196c5cfe7344.jpg",
|
9 |
-
"https://graph.org/file/a3db9af88f25bb1b99325.jpg",
|
10 |
-
"https://graph.org/file/5b344a55f3d5199b63fa5.jpg",
|
11 |
-
"https://graph.org/file/84de4b440300297a8ecb3.jpg",
|
12 |
-
"https://graph.org/file/84e84ff778b045879d24f.jpg",
|
13 |
-
"https://graph.org/file/a4a8f0e5c0e6b18249ffc.jpg",
|
14 |
-
"https://graph.org/file/ed92cada78099c9c3a4f7.jpg",
|
15 |
-
"https://graph.org/file/d6360613d0fa7a9d2f90b.jpg"
|
16 |
-
"https://graph.org/file/37248e7bdff70c662a702.jpg",
|
17 |
-
"https://graph.org/file/0bfe29d15e918917d1305.jpg",
|
18 |
-
"https://graph.org/file/16b1a2828cc507f8048bd.jpg",
|
19 |
-
"https://graph.org/file/e6b01f23f2871e128dad8.jpg",
|
20 |
-
"https://graph.org/file/cacbdddee77784d9ed2b7.jpg",
|
21 |
-
"https://graph.org/file/ddc5d6ec1c33276507b19.jpg",
|
22 |
-
"https://graph.org/file/39d7277189360d2c85b62.jpg",
|
23 |
-
"https://graph.org/file/5846b9214eaf12c3ed100.jpg",
|
24 |
-
"https://graph.org/file/ad4f9beb4d526e6615e18.jpg",
|
25 |
-
"https://graph.org/file/3514efaabe774e4f181f2.jpg",
|
26 |
-
]
|
27 |
-
|
28 |
#--------------------------
|
29 |
|
30 |
MUST_JOIN = "ERROR_RESPON_TIMEOUT"
|
@@ -43,7 +21,7 @@ async def must_join_channel(app: Client, msg: Message):
|
|
43 |
chat_info = await app.get_chat(MUST_JOIN)
|
44 |
link = chat_info.invite_link
|
45 |
try:
|
46 |
-
await msg.
|
47 |
reply_markup=InlineKeyboardMarkup(
|
48 |
[
|
49 |
[
|
|
|
|
|
1 |
from pyrogram import Client, filters
|
2 |
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
3 |
from pyrogram.errors import ChatAdminRequired, UserNotParticipant, ChatWriteForbidden
|
4 |
from DragMusic import app
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
#--------------------------
|
7 |
|
8 |
MUST_JOIN = "ERROR_RESPON_TIMEOUT"
|
|
|
21 |
chat_info = await app.get_chat(MUST_JOIN)
|
22 |
link = chat_info.invite_link
|
23 |
try:
|
24 |
+
await msg.reply_text(f"❅ ʜᴇʏ ᴛʜᴇʀᴇ, ɴɪᴄᴇ ᴛᴏ ᴍᴇᴇᴛ ᴜʜʜ !\n\n❅ ɪғ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴜsᴇ ˹ʙᴜɢ ✘ ϻʊsɪx ˼, ᴛʜᴇɴ ᴄʟɪᴄᴋ ᴏɴ ᴛʜᴇ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ ᴀɴᴅ ʏᴏᴜ ᴊᴏɪɴᴇᴅ, ᴛʜᴇɴ ʏᴏᴜ ᴄᴀɴ ᴜsᴇ ᴀʟʟ ᴍʏ ᴄᴏᴍᴍᴀɴᴅs ",
|
25 |
reply_markup=InlineKeyboardMarkup(
|
26 |
[
|
27 |
[
|
DragMusic/plugins/bot/start.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import time
|
2 |
from pyrogram import filters
|
3 |
from pyrogram.enums import ChatType
|
@@ -16,154 +17,134 @@ from DragMusic.utils.database import (
|
|
16 |
is_banned_user,
|
17 |
is_on_off,
|
18 |
)
|
|
|
19 |
from DragMusic.utils.formatters import get_readable_time
|
20 |
from DragMusic.utils.inline import help_pannel, private_panel, start_panel
|
21 |
-
from config import BANNED_USERS,
|
22 |
-
from strings import get_string
|
|
|
23 |
|
24 |
@app.on_message(filters.command(["start"]) & filters.private & ~BANNED_USERS)
|
25 |
-
|
|
|
26 |
await add_served_user(message.from_user.id)
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
if len(message.text.split()) > 1:
|
32 |
name = message.text.split(None, 1)[1]
|
33 |
-
if name
|
34 |
keyboard = help_pannel(_)
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
reply_markup=keyboard,
|
40 |
)
|
41 |
-
|
42 |
await sudoers_list(client=client, message=message, _=_)
|
43 |
if await is_on_off(2):
|
44 |
await app.send_message(
|
45 |
-
chat_id=LOGGER_ID,
|
46 |
-
text=f"{message.from_user.mention}
|
47 |
-
|
|
|
48 |
)
|
49 |
return
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
query = f"https://www.youtube.com/watch?v={query}"
|
54 |
results = VideosSearch(query, limit=1)
|
55 |
-
for result in (await results.next())["result"]:
|
56 |
-
title = result["title"]
|
57 |
-
duration = result["duration"]
|
58 |
-
views = result["viewCount"]["short"]
|
59 |
-
thumbnail = result["thumbnails"][0]["url"].split("?")[0]
|
60 |
-
channellink = result["channel"]["link"]
|
61 |
-
channel = result["channel"]["name"]
|
62 |
-
link = result["link"]
|
63 |
-
published = result["publishedTime"]
|
64 |
-
searched_text = _["start_6"].format(
|
65 |
-
title, duration, views, published, channellink, channel, app.mention
|
66 |
-
)
|
67 |
-
key = InlineKeyboardMarkup(
|
68 |
-
[
|
69 |
-
[
|
70 |
-
InlineKeyboardButton(text=_["S_B_8"], url=link),
|
71 |
-
InlineKeyboardButton(text=_["S_B_9"], url=config.SUPPORT_CHAT),
|
72 |
-
],
|
73 |
-
]
|
74 |
-
)
|
75 |
-
await m.delete()
|
76 |
-
await app.send_photo(
|
77 |
-
chat_id=message.chat.id,
|
78 |
-
photo=thumbnail,
|
79 |
-
caption=searched_text,
|
80 |
-
reply_markup=key,
|
81 |
-
)
|
82 |
-
if await is_on_off(2):
|
83 |
-
await app.send_message(
|
84 |
-
chat_id=LOGGER_ID,
|
85 |
-
text=f"{message.from_user.mention} ᴊᴜsᴛ sᴛᴀʀᴛᴇᴅ ᴛʜᴇ ʙᴏᴛ ᴛᴏ ᴄʜᴇᴄᴋ <b>ᴛʀᴀᴄᴋ ɪɴғᴏʀᴍᴀᴛɪᴏɴ</b>.\n\n<b>ᴜsᴇʀ ɪᴅ :</b> <code>{message.from_user.id}</code>\n<b>ᴜsᴇʀɴᴀᴍᴇ :</b> @{message.from_user.username}",
|
86 |
-
message_thread_id=12327 # Send to the specific thread
|
87 |
-
)
|
88 |
-
return
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
else:
|
91 |
out = private_panel(_)
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
reply_markup=InlineKeyboardMarkup(out),
|
97 |
)
|
98 |
if await is_on_off(2):
|
99 |
await app.send_message(
|
100 |
-
chat_id=LOGGER_ID,
|
101 |
-
text=f"{message.from_user.mention}
|
102 |
-
|
|
|
103 |
)
|
104 |
|
105 |
-
@app.on_message(filters.command(["start"]) & filters.group & ~BANNED_USERS)
|
106 |
-
async def start_gp(client, message: Message):
|
107 |
-
language = await get_lang(message.chat.id) # Get language inside the function
|
108 |
-
_ = get_string(language) # Get the translation object
|
109 |
|
|
|
|
|
|
|
110 |
out = start_panel(_)
|
111 |
uptime = int(time.time() - _boot_)
|
112 |
-
await message.
|
113 |
-
|
114 |
-
caption=_["start_1"].format(app.mention, get_readable_time(uptime)),
|
115 |
reply_markup=InlineKeyboardMarkup(out),
|
116 |
)
|
117 |
-
await add_served_chat(message.chat.id)
|
118 |
-
if await is_on_off(2):
|
119 |
-
await app.send_message(
|
120 |
-
chat_id=LOGGER_ID,
|
121 |
-
text=f"{message.from_user.mention} ᴊᴜsᴛ sᴛᴀʀᴛᴇᴅ ᴛʜᴇ ʙᴏᴛ ɪɴ ᴀ ɢʀᴏᴜᴘ.\n\n<b>ᴜsᴇʀ ɪᴅ :</b> <code>{message.from_user.id}</code>\n<b>ᴜsᴇʀɴᴀᴍᴇ :</b> @{message.from_user.username}",
|
122 |
-
message_thread_id=12327 # Send to the specific thread
|
123 |
-
)
|
124 |
-
|
125 |
-
@app.on_message(filters.new_chat_members, group=-1)
|
126 |
-
async def welcome(client, message: Message):
|
127 |
-
for member in message.new_chat_members:
|
128 |
-
try:
|
129 |
-
language = await get_lang(message.chat.id)
|
130 |
-
_ = get_string(language)
|
131 |
-
if await is_banned_user(member.id):
|
132 |
-
await message.chat.ban_member(member.id)
|
133 |
-
continue
|
134 |
-
if member.id == app.id:
|
135 |
-
if message.chat.type != ChatType.SUPERGROUP:
|
136 |
-
await message.reply_text(_["start_4"])
|
137 |
-
return await app.leave_chat(message.chat.id)
|
138 |
-
if message.chat.id in await blacklisted_chats():
|
139 |
-
await message.reply_text(
|
140 |
-
_["start_5"].format(
|
141 |
-
app.mention,
|
142 |
-
f"https://t.me/{app.username}?start=sudolist",
|
143 |
-
config.SUPPORT_CHAT,
|
144 |
-
),
|
145 |
-
disable_web_page_preview=True,
|
146 |
-
)
|
147 |
-
return await app.leave_chat(message.chat.id)
|
148 |
-
|
149 |
-
out = start_panel(_)
|
150 |
-
await message.reply_video(
|
151 |
-
video="https://telegra.ph/file/d2532972423ce5c4b632e.mp4",
|
152 |
-
caption=_["start_3"].format(
|
153 |
-
message.from_user.first_name,
|
154 |
-
app.mention,
|
155 |
-
message.chat.title,
|
156 |
-
app.mention,
|
157 |
-
),
|
158 |
-
reply_markup=InlineKeyboardMarkup(out),
|
159 |
-
)
|
160 |
-
await add_served_chat(message.chat.id)
|
161 |
-
if await is_on_off(2):
|
162 |
-
await app.send_message(
|
163 |
-
chat_id=LOGGER_ID,
|
164 |
-
text=f"{member.mention} ᴊᴜsᴛ ᴊᴏɪɴᴇᴅ ᴛʜᴇ ᴄʜᴀᴛ.\n\n<b>ᴜsᴇʀ ɪᴅ :</b> <code>{member.id}</code>\n<b>ᴜsᴇʀɴᴀᴍᴇ :</b> @{member.username}",
|
165 |
-
message_thread_id=12327 # Send to the specific thread
|
166 |
-
)
|
167 |
-
await message.stop_propagation()
|
168 |
-
except Exception as ex:
|
169 |
-
print(ex)
|
|
|
1 |
+
import asyncio
|
2 |
import time
|
3 |
from pyrogram import filters
|
4 |
from pyrogram.enums import ChatType
|
|
|
17 |
is_banned_user,
|
18 |
is_on_off,
|
19 |
)
|
20 |
+
from DragMusic.utils.decorators.language import LanguageStart
|
21 |
from DragMusic.utils.formatters import get_readable_time
|
22 |
from DragMusic.utils.inline import help_pannel, private_panel, start_panel
|
23 |
+
from config import BANNED_USERS, OWNER_ID, OWNERR_ID
|
24 |
+
from strings import get_string
|
25 |
+
|
26 |
|
27 |
@app.on_message(filters.command(["start"]) & filters.private & ~BANNED_USERS)
|
28 |
+
@LanguageStart
|
29 |
+
async def start_pm(client, message: Message, _):
|
30 |
await add_served_user(message.from_user.id)
|
31 |
|
32 |
+
loading_1 = await message.reply_text("🔥")
|
33 |
+
await asyncio.sleep(0.3)
|
34 |
+
|
35 |
+
await loading_1.edit_text("<b>ʟᴏᴀᴅɪɴɢ</b>")
|
36 |
+
await asyncio.sleep(0.2)
|
37 |
+
await loading_1.edit_text("<b>ʟᴏᴀᴅɪɴɢ.</b>")
|
38 |
+
await asyncio.sleep(0.1)
|
39 |
+
await loading_1.edit_text("<b>ʟᴏᴀᴅɪɴɢ..</b>")
|
40 |
+
await asyncio.sleep(0.1)
|
41 |
+
await loading_1.edit_text("<b>ʟᴏᴀᴅɪɴɢ...</b>")
|
42 |
+
await asyncio.sleep(0.1)
|
43 |
+
await loading_1.delete()
|
44 |
+
|
45 |
+
started_msg = await message.reply_text(text="<b>sᴛᴀʀᴛᴇᴅ...</b>")
|
46 |
+
await asyncio.sleep(0.2)
|
47 |
+
await started_msg.delete()
|
48 |
|
49 |
if len(message.text.split()) > 1:
|
50 |
name = message.text.split(None, 1)[1]
|
51 |
+
if name.startswith("help"):
|
52 |
keyboard = help_pannel(_)
|
53 |
+
keyboard.inline_keyboard.append([
|
54 |
+
InlineKeyboardButton("👑 Owner", url=f"tg://user?id={OWNERR_ID}")
|
55 |
+
])
|
56 |
+
await message.reply_text(
|
57 |
+
text=(
|
58 |
+
f"<b>ʏᴏᴏ {message.from_user.mention}, <a href='https://files.catbox.moe/w8m75t.jpg' target='_blank'>🫧</a></b>\n\n"
|
59 |
+
f"<b>ɪ'ᴍ {app.mention}</b>\n"
|
60 |
+
f"<b>ɪ ᴄᴀɴ sᴛʀᴇᴀᴍ ʜɪɢʜ-ǫᴜᴀʟɪᴛʏ ᴍᴜsɪᴄ ᴀɴᴅ ᴠɪᴅᴇᴏs ᴇғғᴏʀᴛʟᴇssʟʏ ᴡɪᴛʜ ᴛʜɪs ᴀᴅᴠᴀɴᴄᴇᴅ ᴛᴇʟᴇɢʀᴀᴍ ʙᴏᴛ.</b>\n\n"
|
61 |
+
f"<b>sʜᴀʀᴇ ᴛʀᴀᴄᴋs ᴀɴᴅ ᴄʀᴇᴀᴛᴇ ᴛʜᴇ ᴘᴇʀғᴇᴄᴛ ᴀᴛᴍᴏsᴘʜᴇʀᴇ ғᴏʀ ᴇᴠᴇʀʏ ᴄʜᴀᴛ.</b>"
|
62 |
+
),
|
63 |
reply_markup=keyboard,
|
64 |
)
|
65 |
+
if name.startswith("sud"):
|
66 |
await sudoers_list(client=client, message=message, _=_)
|
67 |
if await is_on_off(2):
|
68 |
await app.send_message(
|
69 |
+
chat_id=config.LOGGER_ID,
|
70 |
+
text=f"{message.from_user.mention} ᴄʜᴇᴄᴋᴇᴅ <b>sᴜᴅᴏʟɪsᴛ</b>.\n\n"
|
71 |
+
f"<b>• ɪᴅᴇɴᴛɪғɪᴇʀ ⌯</b> <code>{message.from_user.id}</code>\n"
|
72 |
+
f"<b>• ʜᴀɴᴅʟᴇ ⌯</b> @{message.from_user.username}",
|
73 |
)
|
74 |
return
|
75 |
+
|
76 |
+
if name.startswith("inf"):
|
77 |
+
m = await message.reply_text("⚡️")
|
78 |
+
query = name.replace("info_", "", 1)
|
79 |
query = f"https://www.youtube.com/watch?v={query}"
|
80 |
results = VideosSearch(query, limit=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
next_result = await results.next()
|
83 |
+
|
84 |
+
if isinstance(next_result, dict) and "result" in next_result:
|
85 |
+
for result in next_result["result"]:
|
86 |
+
title = result["title"]
|
87 |
+
duration = result["duration"]
|
88 |
+
views = result["viewCount"]["short"]
|
89 |
+
thumbnail = result["thumbnails"][0]["url"].split("?")[0]
|
90 |
+
channellink = result["channel"]["link"]
|
91 |
+
channel = result["channel"]["name"]
|
92 |
+
link = result["link"]
|
93 |
+
published = result["publishedTime"]
|
94 |
+
searched_text = _["start_6"].format(
|
95 |
+
title, duration, views, published, channellink, channel
|
96 |
+
)
|
97 |
+
key = InlineKeyboardMarkup(
|
98 |
+
[[InlineKeyboardButton(text="ʏᴏᴜᴛᴜʙᴇ", url=link)]]
|
99 |
+
)
|
100 |
+
await m.delete()
|
101 |
+
|
102 |
+
await app.send_photo(
|
103 |
+
chat_id=message.chat.id,
|
104 |
+
photo=thumbnail,
|
105 |
+
caption=searched_text,
|
106 |
+
reply_markup=key,
|
107 |
+
)
|
108 |
+
if await is_on_off(2):
|
109 |
+
await app.send_message(
|
110 |
+
chat_id=config.LOGGER_ID,
|
111 |
+
text=f"<b>{message.from_user.mention} ᴄʜᴇᴄᴋᴇᴅ ᴛʀᴀᴄᴋ ɪɴғᴏ.</b>\n\n"
|
112 |
+
f"<b>• ɪᴅᴇɴᴛɪғɪᴇʀ ⌯</b> <code>{message.from_user.id}</code>\n"
|
113 |
+
f"<b>• ʜᴀɴᴅʟᴇ ⌯</b> @{message.from_user.username}",
|
114 |
+
)
|
115 |
+
else:
|
116 |
+
await m.edit_text("ғᴀɪʟᴇᴅ ᴛᴏ ʀᴇᴛʀɪᴇᴠᴇ ɪɴғᴏʀᴍᴀᴛɪᴏɴ.")
|
117 |
+
return
|
118 |
else:
|
119 |
out = private_panel(_)
|
120 |
+
out.append([
|
121 |
+
InlineKeyboardButton("👑 Owner", url=f"tg://user?id={OWNERR_ID}")
|
122 |
+
])
|
123 |
+
await message.reply_text(
|
124 |
+
text=(
|
125 |
+
f"<b>ʏᴏᴏ {message.from_user.mention}, <a href='https://files.catbox.moe/w8m75t.jpg' target='_blank'>🫧</a></b>\n\n"
|
126 |
+
f"<b>ɪ'ᴍ {app.mention}</b>\n"
|
127 |
+
f"<b>ɪ ᴄᴀɴ sᴛʀᴇᴀᴍ ʜɪɢʜ-ǫᴜᴀʟɪᴛʏ ᴍᴜsɪᴄ ᴀɴᴅ ᴠɪᴅᴇᴏs ᴇғғᴏʀᴛʟᴇssʟʏ ᴡɪᴛʜ ᴛʜɪs ᴀᴅᴠᴀɴᴄᴇᴅ ᴛᴇʟᴇɢʀᴀᴍ ʙᴏᴛ.</b>\n\n"
|
128 |
+
f"<b>sʜᴀʀᴇ ᴛʀᴀᴄᴋs ᴀɴᴅ ᴄʀᴇᴀᴛᴇ ᴛʜᴇ ᴘᴇʀғᴇᴄᴛ ᴀᴛᴍᴏsᴘʜᴇʀᴇ ғᴏʀ ᴇᴠᴇʀʏ ᴄʜᴀᴛ.</b>"
|
129 |
+
),
|
130 |
reply_markup=InlineKeyboardMarkup(out),
|
131 |
)
|
132 |
if await is_on_off(2):
|
133 |
await app.send_message(
|
134 |
+
chat_id=config.LOGGER_ID,
|
135 |
+
text=f"<b>{message.from_user.mention} sᴛᴀʀᴛᴇᴅ ᴛʜᴇ ʙᴏᴛ.</b>\n\n"
|
136 |
+
f"<b>• ɪᴅᴇɴᴛɪғɪᴇʀ ⌯</b> <code>{message.from_user.id}</code>\n"
|
137 |
+
f"<b>• ʜᴀɴᴅʟᴇ ⌯</b> @{message.from_user.username}",
|
138 |
)
|
139 |
|
|
|
|
|
|
|
|
|
140 |
|
141 |
+
@app.on_message(filters.command(["start"]) & filters.group & ~BANNED_USERS)
|
142 |
+
@LanguageStart
|
143 |
+
async def start_gp(client, message: Message, _):
|
144 |
out = start_panel(_)
|
145 |
uptime = int(time.time() - _boot_)
|
146 |
+
await message.reply_text(
|
147 |
+
text=_["start_1"].format(app.mention, get_readable_time(uptime)),
|
|
|
148 |
reply_markup=InlineKeyboardMarkup(out),
|
149 |
)
|
150 |
+
await add_served_chat(message.chat.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/{misc → games}/love.py
RENAMED
File without changes
|
DragMusic/plugins/{misc → games}/truth_dare.py
RENAMED
File without changes
|
DragMusic/plugins/plugins/Gemini.txt
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
from MukeshAPI import api
|
3 |
-
from pyrogram import filters
|
4 |
-
from pyrogram.enums import ChatAction
|
5 |
-
from DragMusic import app
|
6 |
-
|
7 |
-
|
8 |
-
@app.on_message(filters.command(["gemini"]))
|
9 |
-
async def gemini_handler(client, message):
|
10 |
-
await app.send_chat_action(message.chat.id, ChatAction.TYPING)
|
11 |
-
if (
|
12 |
-
message.text.startswith(f"/gemini@{app.username}")
|
13 |
-
and len(message.text.split(" ", 1)) > 1
|
14 |
-
):
|
15 |
-
user_input = message.text.split(" ", 1)[1]
|
16 |
-
elif message.reply_to_message and message.reply_to_message.text:
|
17 |
-
user_input = message.reply_to_message.text
|
18 |
-
else:
|
19 |
-
if len(message.command) > 1:
|
20 |
-
user_input = " ".join(message.command[1:])
|
21 |
-
else:
|
22 |
-
await message.reply_text("ᴇxᴀᴍᴘʟᴇ :- `/gemini hi?`")
|
23 |
-
return
|
24 |
-
|
25 |
-
try:
|
26 |
-
response = api.gemini(user_input)
|
27 |
-
await app.send_chat_action(message.chat.id, ChatAction.TYPING)
|
28 |
-
x = response["results"]
|
29 |
-
if x:
|
30 |
-
await message.reply_text(x, quote=True)
|
31 |
-
else:
|
32 |
-
await message.reply_text("sᴏʀʀʏ sɪʀ! ᴘʟᴇᴀsᴇ Tʀʏ ᴀɢᴀɪɴ")
|
33 |
-
except requests.exceptions.RequestException as e:
|
34 |
-
pass
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/plugins/ask.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
from pyrogram import filters
|
2 |
-
from pyrogram.enums import ChatAction, ParseMode
|
3 |
-
from DragMusic import app
|
4 |
-
import aiohttp
|
5 |
-
|
6 |
-
# Function to fetch data from Akeno API
|
7 |
-
async def fetch_data_from_akeno(question):
|
8 |
-
url = "https://web-3ypd.onrender.com/api/cohere" # API endpoint
|
9 |
-
params = {"query": question} # Pass query as a parameter
|
10 |
-
|
11 |
-
async with aiohttp.ClientSession() as session:
|
12 |
-
async with session.get(url, params=params) as response:
|
13 |
-
data = await response.json()
|
14 |
-
return data.get("results", "No response received.") # Extract the answer
|
15 |
-
|
16 |
-
# Command handler for /ask
|
17 |
-
@app.on_message(filters.command("ask"))
|
18 |
-
async def ask_command(client, message):
|
19 |
-
chat_id = message.chat.id
|
20 |
-
user_id = message.from_user.id
|
21 |
-
|
22 |
-
# Indicate typing action
|
23 |
-
await app.send_chat_action(chat_id, ChatAction.TYPING)
|
24 |
-
|
25 |
-
if len(message.command) < 2:
|
26 |
-
await message.reply_text("Exᴀᴍᴘʟᴇ ᴜsᴀɢᴇ: /ask [your question]")
|
27 |
-
return
|
28 |
-
|
29 |
-
question = " ".join(message.command[1:]) # Get the question from command arguments
|
30 |
-
response = await fetch_data_from_akeno(question)
|
31 |
-
|
32 |
-
formatted_response = f"<blockquote>{response}</blockquote>"
|
33 |
-
|
34 |
-
await message.reply_text(formatted_response, parse_mode=ParseMode.HTML)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/plugins/brave.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
from pyrogram import filters
|
3 |
-
from pyrogram.enums import ChatAction
|
4 |
-
from DragMusic import app
|
5 |
-
|
6 |
-
# Add your Brave Search API key (if required)
|
7 |
-
BRAVE_SEARCH_API_KEY = "your_brave_api_key" # Leave empty if no key is needed
|
8 |
-
|
9 |
-
@app.on_message(filters.command(["search", "brave"]))
|
10 |
-
async def brave_search_handler(client, message):
|
11 |
-
chat_id = message.chat.id
|
12 |
-
|
13 |
-
# Indicate typing action
|
14 |
-
await app.send_chat_action(chat_id, ChatAction.TYPING)
|
15 |
-
|
16 |
-
# Retrieve the search query from the message
|
17 |
-
if len(message.command) > 1:
|
18 |
-
search_query = " ".join(message.command[1:])
|
19 |
-
else:
|
20 |
-
await message.reply_text("Exᴀᴍᴘʟᴇ ᴜsᴀɢᴇ: /sᴇᴀʀᴄʜ Qᴜᴇsᴛɪᴏɴ ᴏʀ Tᴏᴘɪᴄ.")
|
21 |
-
return
|
22 |
-
|
23 |
-
try:
|
24 |
-
# Brave Search API Endpoint
|
25 |
-
search_url = f"https://search.brave.com/api/v1/search?q={search_query}&source=web"
|
26 |
-
|
27 |
-
# Make the request to Brave's API
|
28 |
-
response = requests.get(search_url, headers={"Authorization": f"Bearer {BRAVE_SEARCH_API_KEY}"})
|
29 |
-
response.raise_for_status()
|
30 |
-
results = response.json()
|
31 |
-
|
32 |
-
# Extract and format the results
|
33 |
-
if "web" in results and len(results["web"]["results"]) > 0:
|
34 |
-
reply_text = "**Top Search Results:**\n"
|
35 |
-
for index, result in enumerate(results["web"]["results"][:5], 1): # Limit to 5 results
|
36 |
-
reply_text += f"{index}. [{result['title']}]({result['url']})\n"
|
37 |
-
await message.reply_text(reply_text, disable_web_page_preview=True)
|
38 |
-
else:
|
39 |
-
await message.reply_text("No results found for your query. Please try with a different keyword.")
|
40 |
-
|
41 |
-
except Exception as e:
|
42 |
-
await message.reply_text(f"» Error: {str(e)}. Please try again later.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/plugins/getimg.py
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
from pyrogram import filters
|
3 |
-
from pyrogram.enums import ChatAction
|
4 |
-
from DragMusic import app
|
5 |
-
|
6 |
-
# Getimg API key (replace with your actual key)
|
7 |
-
GETIMG_API_KEY = "key-ICLT6PNtwcDA5PKI7DmuKMXrueoKcDybWuHrXX1o9V8eszHCAOabBpvq2d7ZWewTa5A50ntiXEkDcMo1ewE5exp6LxuOAAr"
|
8 |
-
GETIMG_API_URL = "https://api.getimg.ai/v1/essential-v2/text-to-image"
|
9 |
-
|
10 |
-
# Function to generate an image using Getimg API
|
11 |
-
def generate_image(prompt):
|
12 |
-
headers = {
|
13 |
-
"Authorization": f"Bearer {GETIMG_API_KEY}",
|
14 |
-
"Content-Type": "application/json"
|
15 |
-
}
|
16 |
-
|
17 |
-
# Request payload to send to Getimg API
|
18 |
-
data = {
|
19 |
-
"prompt": prompt,
|
20 |
-
"style": "artistic", # You can change the style based on the available options
|
21 |
-
"width": 512,
|
22 |
-
"height": 512
|
23 |
-
}
|
24 |
-
|
25 |
-
# Make the API request
|
26 |
-
response = requests.post(GETIMG_API_URL, json=data, headers=headers)
|
27 |
-
|
28 |
-
if response.status_code == 200:
|
29 |
-
# Extract image URL from the response
|
30 |
-
image_url = response.json().get("image_url")
|
31 |
-
return image_url
|
32 |
-
else:
|
33 |
-
return None
|
34 |
-
|
35 |
-
# Command handler to generate an image
|
36 |
-
@app.on_message(filters.command("generate_image"))
|
37 |
-
async def generate_image_handler(client, message):
|
38 |
-
chat_id = message.chat.id
|
39 |
-
await app.send_chat_action(chat_id, ChatAction.TYPING)
|
40 |
-
|
41 |
-
# Get the prompt from the user input
|
42 |
-
if len(message.command) > 1:
|
43 |
-
prompt = " ".join(message.command[1:])
|
44 |
-
else:
|
45 |
-
await message.reply_text("Usage: /generate_image <your prompt>")
|
46 |
-
return
|
47 |
-
|
48 |
-
try:
|
49 |
-
# Call the function to generate the image via Getimg API
|
50 |
-
image_url = generate_image(prompt)
|
51 |
-
|
52 |
-
if image_url:
|
53 |
-
# Send the generated image URL back to the user
|
54 |
-
await message.reply_photo(photo=image_url, caption=f"Generated image for prompt: {prompt}")
|
55 |
-
else:
|
56 |
-
await message.reply_text("Sorry, I couldn't generate the image. Please try again later.")
|
57 |
-
except Exception as e:
|
58 |
-
await message.reply_text(f"Error: {str(e)}. Please try again later.")
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DragMusic/plugins/plugins/gpt.py
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
import openai
|
2 |
-
from pyrogram import filters
|
3 |
-
from pyrogram.enums import ChatAction
|
4 |
-
from DragMusic import app
|
5 |
-
|
6 |
-
# Set your OpenAI API key
|
7 |
-
openai.api_key = "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"
|
8 |
-
# To store conversations (per user basis, using a dictionary for simplicity)
|
9 |
-
user_conversations = {}
|
10 |
-
|
11 |
-
@app.on_message(filters.command(["chatgpt", "gpt"])) # Add support for "gpt"
|
12 |
-
async def ask_handler(client, message):
|
13 |
-
user_id = message.from_user.id
|
14 |
-
chat_id = message.chat.id
|
15 |
-
|
16 |
-
# Indicate typing action
|
17 |
-
await app.send_chat_action(chat_id, ChatAction.TYPING)
|
18 |
-
|
19 |
-
# Retrieve the user's input
|
20 |
-
if len(message.command) > 1:
|
21 |
-
user_input = " ".join(message.command[1:])
|
22 |
-
elif message.reply_to_message and message.reply_to_message.text:
|
23 |
-
user_input = message.reply_to_message.text
|
24 |
-
else:
|
25 |
-
await message.reply_text("Exᴀᴍᴘʟᴇ ᴜsᴀɢᴇ: /ᴄʜᴀᴛɢᴘᴛ Hᴏᴡ ᴅᴏᴇs ʀᴇᴄᴜʀsɪᴏɴ ᴡᴏʀᴋ?")
|
26 |
-
return
|
27 |
-
|
28 |
-
# Initialize the conversation history if it's a new user
|
29 |
-
if user_id not in user_conversations:
|
30 |
-
user_conversations[user_id] = [
|
31 |
-
{"role": "system", "content": "You are a helpful assistant who can answer any questions."}
|
32 |
-
]
|
33 |
-
|
34 |
-
# Append the user's input to the conversation
|
35 |
-
user_conversations[user_id].append({"role": "user", "content": user_input})
|
36 |
-
|
37 |
-
try:
|
38 |
-
# Call the OpenAI API with the full conversation history
|
39 |
-
response = openai.ChatCompletion.create(
|
40 |
-
model="gpt-3.5-turbo", # Use "gpt-4" if needed
|
41 |
-
messages=user_conversations[user_id]
|
42 |
-
)
|
43 |
-
|
44 |
-
# Get the assistant's response
|
45 |
-
assistant_response = response["choices"][0]["message"]["content"].strip()
|
46 |
-
|
47 |
-
# Append the assistant's response to the conversation history
|
48 |
-
user_conversations[user_id].append({"role": "assistant", "content": assistant_response})
|
49 |
-
|
50 |
-
# Send the assistant's response to the user
|
51 |
-
await message.reply_text(assistant_response, quote=True)
|
52 |
-
|
53 |
-
except Exception as e:
|
54 |
-
await message.reply_text(f"**» Error:** {str(e)}. Please try again later.")
|
55 |
-
|
56 |
-
@app.on_message(filters.command(["reset"]))
|
57 |
-
async def reset_handler(client, message):
|
58 |
-
user_id = message.from_user.id
|
59 |
-
if user_id in user_conversations:
|
60 |
-
user_conversations.pop(user_id)
|
61 |
-
await message.reply_text("Cᴏɴᴠᴇʀsᴀᴛɪᴏɴ ᴄᴏɴᴛᴇxᴛ ʜᴀs ʙᴇᴇɴ ʀᴇsᴇᴛ.")
|
62 |
-
|
63 |
-
@app.on_message(filters.command(["setrole"]))
|
64 |
-
async def set_role_handler(client, message):
|
65 |
-
user_id = message.from_user.id
|
66 |
-
if len(message.command) > 1:
|
67 |
-
role_content = " ".join(message.command[1:])
|
68 |
-
user_conversations[user_id] = [
|
69 |
-
{"role": "system", "content": role_content}
|
70 |
-
]
|
71 |
-
await message.reply_text(f"Sʏsᴛᴇᴍ ʀᴏʟᴇ sᴇᴛ ᴛᴏ: {role_content}")
|
72 |
-
else:
|
73 |
-
await message.reply_text("Exᴀᴍᴘʟᴇ ᴜsᴀɢᴇ: /sᴇᴛʀᴏʟᴇ Yᴏᴜ ᴀʀᴇ ᴀ ғʀɪᴇɴᴅʟʏ AI.")
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|