User-vex commited on
Commit
bf3b6e4
Β·
verified Β·
1 Parent(s): 494e0ae

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +7 -12
bot.py CHANGED
@@ -9,18 +9,13 @@ from aiogram.types import (
9
  CallbackQuery
10
  )
11
  from aiogram.client.session.aiohttp import AiohttpSession
12
- from aiohttp import ClientTimeout
13
  import asyncio
14
 
15
  # πŸ€– Aktiv tokeningiz
16
  BOT_TOKEN = "8985882342:AAEu4YPcjV-roqGNOm0Hqkx-5A6XDxGOD9Q"
17
 
18
- # πŸ”₯ HF serverlaridagi SSL va Timeout xatolarini tuzatish uchun maxsus sessiya sozlamasi
19
- # Ulanish vaqtini 120 soniyagacha uzaytiramiz va SSL tekshiruvini erkinlashtiramiz
20
- session_timeout = ClientTimeout(total=120, connect=60, sock_connect=60, sock_read=60)
21
- session = AiohttpSession(timeout=session_timeout)
22
-
23
- # Botni yangi sessiya bilan yaratamiz
24
  bot = Bot(token=BOT_TOKEN, session=session)
25
  dp = Dispatcher()
26
 
@@ -110,13 +105,11 @@ async def open_secret_msg(callback: CallbackQuery):
110
 
111
  # Foydalanuvchi usernamesini solishtiramiz
112
  if user_username.lower() == data["target"]:
113
- # show_alert=True faqat o'sha odamning ekranida modal oyna ochadi
114
  await callback.answer(
115
  text=f"πŸ”’ Sizga kelgan maxfiy xabar:\n\n{data['text']}",
116
  show_alert=True
117
  )
118
  else:
119
- # Boshqa odam bossa chiqadigan ogohlantirish
120
  await callback.answer(
121
  text=f"❌ Bu xabar siz uchun emas!\nU faqat @{data['target']} uchun yuborilgan.",
122
  show_alert=True
@@ -126,11 +119,13 @@ async def open_secret_msg(callback: CallbackQuery):
126
  async def main():
127
  print("πŸš€ @ShdwTextBot guruh rejimida muvaffaqiyatli ishga tushdi!")
128
  try:
129
- # Eski vebhuklarni o'chirib pollingni toza ishga tushiramiz
130
  await bot.delete_webhook(drop_pending_updates=True)
131
- await dp.start_polling(bot)
 
 
 
132
  finally:
133
- # Bot to'xtaganda tarmoq sessiyasini xavfsiz yopamiz
134
  await bot.session.close()
135
 
136
  if __name__ == "__main__":
 
9
  CallbackQuery
10
  )
11
  from aiogram.client.session.aiohttp import AiohttpSession
 
12
  import asyncio
13
 
14
  # πŸ€– Aktiv tokeningiz
15
  BOT_TOKEN = "8985882342:AAEu4YPcjV-roqGNOm0Hqkx-5A6XDxGOD9Q"
16
 
17
+ # Sessiyani qo'shimcha murakkab obyektlarsiz, oddiy va toza holatda yaratamiz
18
+ session = AiohttpSession()
 
 
 
 
19
  bot = Bot(token=BOT_TOKEN, session=session)
20
  dp = Dispatcher()
21
 
 
105
 
106
  # Foydalanuvchi usernamesini solishtiramiz
107
  if user_username.lower() == data["target"]:
 
108
  await callback.answer(
109
  text=f"πŸ”’ Sizga kelgan maxfiy xabar:\n\n{data['text']}",
110
  show_alert=True
111
  )
112
  else:
 
113
  await callback.answer(
114
  text=f"❌ Bu xabar siz uchun emas!\nU faqat @{data['target']} uchun yuborilgan.",
115
  show_alert=True
 
119
  async def main():
120
  print("πŸš€ @ShdwTextBot guruh rejimida muvaffaqiyatli ishga tushdi!")
121
  try:
122
+ # Eski vebhuklarni tozalash
123
  await bot.delete_webhook(drop_pending_updates=True)
124
+
125
+ # πŸ”₯ Polling kutish vaqtini (timeout) shu yerda to'g'ri raqam ko'rinishida beramiz
126
+ # Bu HF serveridagi uzilishlarni va koddagi TypeError xatosini birdek tuzatadi
127
+ await dp.start_polling(bot, polling_timeout=60)
128
  finally:
 
129
  await bot.session.close()
130
 
131
  if __name__ == "__main__":