Agnivesh10M commited on
Commit
646e672
·
verified ·
1 Parent(s): 7c86d85

Upload generate.py

Browse files
Files changed (1) hide show
  1. TechVJ/generate.py +137 -0
TechVJ/generate.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import traceback
2
+ import asyncio
3
+ from pyrogram.types import Message
4
+ from pyrogram import Client, filters
5
+ from pyrogram.errors import (
6
+ PhoneNumberInvalid,
7
+ PhoneCodeInvalid,
8
+ PhoneCodeExpired,
9
+ SessionPasswordNeeded,
10
+ PasswordHashInvalid,
11
+ FloodWait
12
+ )
13
+ from config import API_ID, API_HASH
14
+ from db import db
15
+
16
+ SESSION_STRING_SIZE = 351
17
+
18
+ @Client.on_message(filters.private & ~filters.forwarded & filters.command(["logout"]))
19
+ async def logout(client, message):
20
+ user_data = db.get_session(message.from_user.id)
21
+ if user_data is None:
22
+ return await message.reply("❌ आप अभी लॉगिन नहीं हैं।")
23
+ db.remove_session(message.from_user.id)
24
+ await message.reply("✅ **सफलतापूर्वक लॉगआउट कर दिया गया है।**")
25
+
26
+ @Client.on_message(filters.private & ~filters.forwarded & filters.command(["login"]))
27
+ async def main(bot: Client, message: Message):
28
+ user_id = int(message.from_user.id)
29
+ user_data = db.get_session(user_id)
30
+ if user_data is not None:
31
+ await message.reply("⚠️ **आप पहले से लॉगिन हैं। नया अकाउंट जोड़ने से पहले /logout करें।**")
32
+ return
33
+
34
+ phone_number_msg = await bot.ask(
35
+ chat_id=user_id,
36
+ text="📱 **कंट्री कोड के साथ अपना फ़ोन नंबर भेजें:**\n(उदाहरण: `+919876543210`)\n\nरद्द करने के लिए /cancel लिखें।",
37
+ filters=filters.text,
38
+ timeout=300
39
+ )
40
+ if phone_number_msg.text == '/cancel':
41
+ return await phone_number_msg.reply("❌ प्रोसेस रद्द कर दिया गया।")
42
+
43
+ phone_number = phone_number_msg.text.strip()
44
+ api_id = API_ID
45
+ api_hash = API_HASH
46
+
47
+ # डिवाइस का नाम और जर्मन भाषा सेट (जर्मनी/यूरोप डिवाइस प्रोफ़ाइल)
48
+ client = Client(
49
+ ":memory:",
50
+ api_id=api_id,
51
+ api_hash=api_hash,
52
+ device_model="Samsung Galaxy S24 Ultra",
53
+ system_version="Android 14 (One UI 6.1)",
54
+ app_version="Telegram Android 10.9.1",
55
+ lang_code="de"
56
+ )
57
+
58
+ try:
59
+ await client.connect()
60
+ except Exception as e:
61
+ return await message.reply(f"❌ कनेक्शन एरर: `{e}`")
62
+
63
+ await phone_number_msg.reply("📩 OTP भेजा जा रहा है...")
64
+
65
+ try:
66
+ code = await client.send_code(phone_number)
67
+ except FloodWait as f:
68
+ await client.disconnect()
69
+ return await phone_number_msg.reply(
70
+ f"⏳ **टेलीग्राम FloodWait एरर!**\n\n"
71
+ f"आपने बहुत बार लगातार OTP माँगा है। टेलीग्राम ने आपको सुरक्षा कारणों से रोका है।\n"
72
+ f"कृपया **{f.value} सेकंड ({round(f.value / 60)} मिनट)** इंतज़ार करने के बाद ही दोबारा कोशिश करें।"
73
+ )
74
+ except PhoneNumberInvalid:
75
+ await client.disconnect()
76
+ return await phone_number_msg.reply("❌ अमान्य फ़ोन नंबर। कृपया सही नंबर डालकर दोबारा /login करें।")
77
+ except Exception as e:
78
+ await client.disconnect()
79
+ return await phone_number_msg.reply(f"❌ OTP भेजने में समस्या: `{e}`")
80
+
81
+ try:
82
+ phone_code_msg = await bot.ask(
83
+ user_id,
84
+ "📲 टेलीग्राम पर आया हुआ OTP यहाँ भेजें (अंकों के बीच स्पेस देकर, जैसे: `1 2 3 4 5`):\n\nरद्द करने के लिए /cancel लिखें।",
85
+ filters=filters.text,
86
+ timeout=600
87
+ )
88
+ except Exception:
89
+ await client.disconnect()
90
+ return
91
+
92
+ if phone_code_msg.text == '/cancel':
93
+ await client.disconnect()
94
+ return await phone_code_msg.reply("❌ प्रोसेस रद्द कर दिया गया।")
95
+
96
+ try:
97
+ phone_code = phone_code_msg.text.replace(" ", "").replace("-", "")
98
+ await client.sign_in(phone_number, code.phone_code_hash, phone_code)
99
+ except FloodWait as f:
100
+ await client.disconnect()
101
+ return await phone_code_msg.reply(f"⏳ कृपया {f.value} सेकंड इंतज़ार करें।")
102
+ except PhoneCodeInvalid:
103
+ await client.disconnect()
104
+ return await phone_code_msg.reply("❌ OTP गलत है।")
105
+ except PhoneCodeExpired:
106
+ await client.disconnect()
107
+ return await phone_code_msg.reply("❌ OTP एक्सपा���र हो चुका है।")
108
+ except SessionPasswordNeeded:
109
+ two_step_msg = await bot.ask(
110
+ user_id,
111
+ "🔐 आपके अकाउंट पर Two-Step Verification लगा है। अपना पासवर्ड भेजें:\n\nरद्द करने के लिए /cancel लिखें।",
112
+ filters=filters.text,
113
+ timeout=300
114
+ )
115
+ if two_step_msg.text == '/cancel':
116
+ await client.disconnect()
117
+ return await two_step_msg.reply("❌ प्रोसेस रद्द कर दिया गया।")
118
+ try:
119
+ await client.check_password(password=two_step_msg.text)
120
+ except PasswordHashInvalid:
121
+ await client.disconnect()
122
+ return await two_step_msg.reply("❌ गलत पासवर्ड दर्ज किया गया है।")
123
+ except FloodWait as f:
124
+ await client.disconnect()
125
+ return await two_step_msg.reply(f"⏳ कृपया {f.value} सेकंड इंतज़ार करें।")
126
+
127
+ string_session = await client.export_session_string()
128
+ await client.disconnect()
129
+
130
+ if len(string_session) < SESSION_STRING_SIZE:
131
+ return await message.reply("❌ सेशन स्ट्रिंग अमान्य है।")
132
+
133
+ db.set_session(user_id, session=string_session)
134
+ db.set_api_id(user_id, api_id=str(api_id))
135
+ db.set_api_hash(user_id, api_hash=str(api_hash))
136
+
137
+ await bot.send_message(user_id, "🎉 **अकाउंट सफलतापूर्वक लॉगिन हो गया है!**\nअब आप `/clone` कमांड से कंटेंट ट्रांसफर कर सकते हैं।")