-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
283 lines (228 loc) ยท 6.93 KB
/
Copy pathmain.py
File metadata and controls
283 lines (228 loc) ยท 6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
โถimport asyncio
from aiogram import Bot, Dispatcher
from aiogram.filters import Command
from aiogram.types import (
Message,
ReplyKeyboardMarkup,
KeyboardButton,
InlineKeyboardMarkup,
InlineKeyboardButton,
CallbackQuery,
)
import json
import os
TOKEN = "8714180608:AAFiKwNkGxVF3h1REnhSwXMEbOWARDIginA"
ADMIN_ID = 8568826078
CHANNEL_USERNAME = "@Valiant_Akkount_Savdo"
bot = Bot(TOKEN)
dp = Dispatcher()
user_data = {}
USERS_FILE = "users.json"
if os.path.exists(USERS_FILE):
with open(USERS_FILE, "r", encoding="utf-8") as f:
users = json.load(f)
if isinstance(users, list):
users = {}
else:
users = {}
def save_users():
with open(USERS_FILE, "w", encoding="utf-8") as f:
json.dump(users, f, ensure_ascii=False, indent=4)
menu = ReplyKeyboardMarkup(
keyboard=[
[KeyboardButton(text="๐ Donat olish")],
[KeyboardButton(text="๐ Admin")]
],
resize_keyboard=True
)
donat_menu = ReplyKeyboardMarkup(
keyboard=[
[KeyboardButton(text="๐105 Almaz")],
[KeyboardButton(text="๐341 Almaz")],
[KeyboardButton(text="๐572 Almaz")],
[KeyboardButton(text="๐ณ Kunlik")],
[KeyboardButton(text="๐ณ Haftalik")],
[KeyboardButton(text="๐ณ Oylik")],
[KeyboardButton(text="๐ Bosh menyu")]
],
resize_keyboard=True
)
confirm_menu = ReplyKeyboardMarkup(
keyboard=[
[KeyboardButton(text="โ
Tasdiqlash")],
[KeyboardButton(text="โ Orqaga")]
],
resize_keyboard=True
)
subscribe_menu = InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton(
text="๐ข Kanalga obuna bo'lish",
url="https://t.me/Valiant_Akkount_Savdo"
)
],
[
InlineKeyboardButton(
text="โ
Obunani tekshirish",
callback_data="check_sub"
)
]
]
)
async def check_sub(user_id):
member = await bot.get_chat_member(CHANNEL_USERNAME, user_id)
return member.status not in ["left", "kicked"]
@dp.message(Command("stats"))
async def stats(message: Message):
if message.from_user.id != ADMIN_ID:
return
await message.answer(
f"๐ Bot statistikasi\n\n"
f"๐ฅ Jami foydalanuvchilar: {len(users)} ta"
)
@dp.message(Command("users"))
async def users_list(message: Message):
if message.from_user.id != ADMIN_ID:
await message.answer("โ Sizda ruxsat yo'q")
return
text = "๐ฅ Foydalanuvchilar:\n\n"
for user in users.values():
text += f"๐ค {user['name']}\n"
text += f"๐ {user['id']}\n\n"
await message.answer(text)
@dp.message(Command("start"))
async def start(message: Message):
users[str(message.from_user.id)] = {
"name": message.from_user.full_name,
"username": message.from_user.username,
"id": message.from_user.id
}
save_users()
if not await check_sub(message.from_user.id):
await message.answer(
"โ Botdan foydalanish uchun avval kanalga obuna bo'ling.",
reply_markup=subscribe_menu
)
return
user_data[message.from_user.id] = {"step": None}
await message.answer(
"๐ฎ Free Fire Donat Bot\n\nXush kelibsiz!",
reply_markup=menu
)
@dp.callback_query(lambda c: c.data == "check_sub")
async def check_subscription(callback: CallbackQuery):
if await check_sub(callback.from_user.id):
user_data[callback.from_user.id] = {"step": None}
await callback.message.edit_text(
"โ
Obuna tasdiqlandi!"
)
await callback.message.answer(
"๐ฎ Xush kelibsiz!",
reply_markup=menu
)
else:
await callback.answer(
"โ Siz hali kanalga obuna bo'lmagansiz!",
show_alert=True
)
packages = {
"๐105 Almaz": "13 000 so'm",
"๐341 Almaz": "36 999 so'm",
"๐572 Almaz": "59 999 so'm",
"๐ณ Kunlik": "8 999 so'm",
"๐ณ Haftalik": "24 999 so'm",
"๐ณ Oylik": "85 999 so'm"
}
@dp.message()
async def handler(message: Message):
user_id = message.from_user.id
text = message.text or ""
# Majburiy obunani tekshirish
if not await check_sub(user_id):
await message.answer(
"โ Avval kanalga obuna bo'ling.",
reply_markup=subscribe_menu
)
return
if user_id not in user_data:
user_data[user_id] = {"step": None}
data = user_data[user_id]
if text == "๐ Donat olish":
await message.answer(
"Kerakli paketni tanlang:",
reply_markup=donat_menu
)
return
if text == "๐ Bosh menyu":
await message.answer(
"๐ Bosh menyu",
reply_markup=menu
)
return
if text == "๐ Admin":
await message.answer("@ValiantElite")
return
if text in packages:
data["package"] = text
data["price"] = packages[text]
await message.answer(
f"๐ฆ {text}\n"
f"๐ฐ {packages[text]}\n\n"
"Buyurtmani tasdiqlaysizmi?",
reply_markup=confirm_menu
)
return
if text == "โ Orqaga":
await message.answer(
"Kerakli paketni tanlang:",
reply_markup=donat_menu
)
return
if text == "โ
Tasdiqlash":
data["step"] = "id"
await message.answer(
"๐ณ To'lov kartasi:\n\n"
"KARTA RAQAMI\n"
"๐ค A/J\n\n"
"To'lov qilgach Free Fire ID yuboring:"
)
return
if data.get("step") == "id":
data["game_id"] = text
data["step"] = "nick"
await message.answer("๐ค Nick yuboring:")
return
if data.get("step") == "nick":
data["nick"] = text
data["step"] = "receipt"
await message.answer("๐ธ Endi chek rasmini yuboring:")
return
if data.get("step") == "receipt":
if not message.photo:
await message.answer("โ Iltimos, chek rasmini yuboring.")
return
caption = (
"๐ YANGI BUYURTMA\n\n"
f"๐ฆ Paket: {data['package']}\n"
f"๐ฐ Narx: {data['price']}\n\n"
f"๐ ID: {data['game_id']}\n"
f"๐ค Nick: {data['nick']}\n"
f"๐ค Username: @{message.from_user.username}\n"
f"๐ Telegram ID: {message.from_user.id}"
)
await bot.send_photo(
chat_id=ADMIN_ID,
photo=message.photo[-1].file_id,
caption=caption
)
await message.answer(
"โ
Buyurtmangiz muvaffaqiyatli qabul qilindi!\n\n"
"โณ Tez orada admin tomonidan ko'rib chiqiladi.",
reply_markup=menu
)
user_data[user_id] = {"step": None}
async def main():
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())