Advertisement
HR16G5978

rajput.py

Jun 29th, 2024
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. import requests
  2. import asyncio
  3. from telegram import Bot
  4.  
  5. # Credentials
  6. login_url = 'https://wingoxd.in/api/webapi/login'
  7. username = '7777777777'
  8. password = '7777777777'
  9. telegram_token = '7115429644:AAEj6kHov3nGO5L9EdBzPbWXx-6zdw-IBSo'
  10. telegram_chat_id = '-1002030982037'
  11.  
  12. # Initialize Telegram bot
  13. bot = Bot(token=telegram_token)
  14.  
  15. # Function to handle login and send notification
  16. async def login_and_notify():
  17.     for attempt in range(3):  # Retry login up to 3 times
  18.         try:
  19.             session = requests.Session()
  20.             session.headers.update({'User-Agent': 'Mozilla/5.0'})
  21.             login_data = {'username': username, 'pwd': password}
  22.             response = session.post(login_url, data=login_data)
  23.  
  24.             if response.status_code == 200 and response.json().get('status') is True:
  25.                 await bot.send_message(chat_id=telegram_chat_id, text="✅ Login Successful! ✅")
  26.                 return  # Exit function if login is successful
  27.             else:
  28.                 await bot.send_message(chat_id=telegram_chat_id, text="❌ Login failed. Retrying... ❌")
  29.  
  30.         except Exception as e:
  31.             print(f"Login attempt {attempt + 1} failed: {e}")
  32.             await asyncio.sleep(5)  # Wait before retrying
  33.  
  34.     # If all attempts fail
  35.     await bot.send_message(chat_id=telegram_chat_id, text="❌ Login failed after multiple attempts. ❌")
  36.  
  37. # Run the login and notification process
  38. if __name__ == "__main__":
  39.     asyncio.run(login_and_notify())
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement