Spaces:
Runtime error
Runtime error
| import time | |
| import logging | |
| import datetime | |
| from supabase import create_client | |
| # --- কনফিগারেশন --- | |
| # আপনার মূল বটের সেই একই ক্রেডেনশিয়াল এখানে ব্যবহার করুন | |
| SUPABASE_URL = "https://niktqowydowzhbqwfpqc.supabase.co" | |
| SUPABASE_KEY = "sb_publishable_7ly8E7clFTvuyLIgnKbDmQ_gYRZMxD9" | |
| # নির্দিষ্ট ইউজার আইডি যার ডাটা প্রতি ৩ ঘণ্টা পরপর চেক হবে | |
| TARGET_USER_ID = 8553769697 | |
| # সুপাবেস ক্লায়েন্ট সেটআপ | |
| supabase = create_client(SUPABASE_URL, SUPABASE_KEY) | |
| # লগিং সেটআপ যাতে আপনি দেখতে পারেন রিকোয়েস্ট যাচ্ছে কি না | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(levelname)s - %(message)s' | |
| ) | |
| def keep_supabase_active(): | |
| logging.info("Supabase Keep-Alive service started...") | |
| while True: | |
| try: | |
| # নির্দিষ্ট ইউজারের ডাটা 'users' টেবিল থেকে চেক করার রিকোয়েস্ট | |
| response = supabase.table('users').select("*").eq('user_id', TARGET_USER_ID).execute() | |
| current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| if response.data: | |
| logging.info(f"[{current_time}] Success: Request sent for User {TARGET_USER_ID}. Data found.") | |
| else: | |
| logging.info(f"[{current_time}] Success: Request sent, but User {TARGET_USER_ID} not in DB yet.") | |
| except Exception as e: | |
| logging.error(f"Error occurred at {datetime.datetime.now()}: {e}") | |
| # ১০৮০০ সেকেন্ড = ৩ ঘণ্টা বিরতি | |
| logging.info("Waiting for 3 hours for the next ping...") | |
| time.sleep(10800) | |
| if __name__ == "__main__": | |
| keep_supabase_active() | |