Thaimozhi commited on
Commit
fa83ee0
·
verified ·
1 Parent(s): e93e5ca

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +41 -20
bot.py CHANGED
@@ -1,5 +1,10 @@
1
- import time, urllib.request, email.utils
2
- import aiohttp, asyncio, warnings, pytz
 
 
 
 
 
3
 
4
  try:
5
  req = urllib.request.urlopen("https://google.com", timeout=3)
@@ -21,11 +26,10 @@ import pyrogram.utils
21
  import pyromod
22
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
23
  import os
24
- import time
25
 
26
  pyrogram.utils.MIN_CHANNEL_ID = -1009147483647
27
 
28
- # Setting SUPPORT_CHAT directly here
29
  SUPPORT_CHAT = int(os.environ.get("SUPPORT_CHAT", "-1001953724858"))
30
 
31
  PORT = Config.PORT
@@ -49,42 +53,59 @@ class Bot(Client):
49
  await super().start(*args, **kwargs)
50
  me = await self.get_me()
51
  self.mention = me.mention
52
- self.username = me.username
53
- self.uptime = Config.BOT_UPTIME
 
54
  if Config.WEBHOOK:
55
  app = web.AppRunner(await web_server())
56
- await app.setup()
57
- await web.TCPSite(app, "0.0.0.0", PORT).start()
 
58
  print(f"{me.first_name} Is Started.....✨️")
59
 
60
- # Calculate uptime using timedelta
61
  uptime_seconds = int(time.time() - self.start_time)
62
  uptime_string = str(timedelta(seconds=uptime_seconds))
63
 
 
 
 
 
 
 
 
 
64
  for chat_id in [Config.LOG_CHANNEL, SUPPORT_CHAT]:
65
  try:
66
- curr = datetime.now(timezone("Asia/Kolkata"))
67
- date = curr.strftime('%d %B, %Y')
68
- time_str = curr.strftime('%I:%M:%S %p')
69
-
70
- # Send the message with the photo
71
  await self.send_photo(
72
  chat_id=chat_id,
73
  photo=Config.START_PIC,
74
- caption=(
75
- "**ᴀɴʏᴀ ɪs ʀᴇsᴛᴀʀᴛᴇᴅ ᴀɢᴀɪɴ !**\n\n"
76
- f"ɪ ᴅɪᴅɴ'ᴛ sʟᴇᴘᴛ sɪɴᴄᴇ​: `{uptime_string}`"
77
- ),
78
  reply_markup=InlineKeyboardMarkup(
79
  [[
80
  InlineKeyboardButton("ᴜᴘᴅᴀᴛᴇs", url="https://t.me/codeflix_bots")
81
  ]]
82
  )
83
  )
84
-
85
  except Exception as e:
86
  print(f"Failed to send message in chat {chat_id}: {e}")
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  async def stop(self, *args, **kwargs):
89
  await super().stop(*args, **kwargs)
90
  print("Bot is gracefully shutting down...")
@@ -93,4 +114,4 @@ if __name__ == "__main__":
93
  try:
94
  Bot().run()
95
  except Exception as e:
96
- print(f"Stopped: {e}")
 
1
+ import time
2
+ import urllib.request
3
+ import email.utils
4
+ import aiohttp
5
+ import asyncio
6
+ import warnings
7
+ import pytz
8
 
9
  try:
10
  req = urllib.request.urlopen("https://google.com", timeout=3)
 
26
  import pyromod
27
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
28
  import os
 
29
 
30
  pyrogram.utils.MIN_CHANNEL_ID = -1009147483647
31
 
32
+ # Setting SUPPORT_CHAT
33
  SUPPORT_CHAT = int(os.environ.get("SUPPORT_CHAT", "-1001953724858"))
34
 
35
  PORT = Config.PORT
 
53
  await super().start(*args, **kwargs)
54
  me = await self.get_me()
55
  self.mention = me.mention
56
+ self.username = me.username
57
+ self.uptime = Config.BOT_UPTIME
58
+
59
  if Config.WEBHOOK:
60
  app = web.AppRunner(await web_server())
61
+ await app.setup()
62
+ await web.TCPSite(app, "0.0.0.0", PORT).start()
63
+
64
  print(f"{me.first_name} Is Started.....✨️")
65
 
66
+ # Calculate uptime
67
  uptime_seconds = int(time.time() - self.start_time)
68
  uptime_string = str(timedelta(seconds=uptime_seconds))
69
 
70
+ # Message content
71
+ caption = (
72
+ "›› ʜᴇʏ sᴇɴᴘᴀɪ!!\n"
73
+ "ɪ'ᴍ ᴀʟɪᴠᴇ ɴᴏᴡ 🍃...\n\n"
74
+ f"ɪ ᴅɪᴅɴ'ᴛ sʟᴇᴘᴛ sɪɴᴄᴇ​: `{uptime_string}`"
75
+ )
76
+
77
+ # Send to LOG_CHANNEL & SUPPORT_CHAT
78
  for chat_id in [Config.LOG_CHANNEL, SUPPORT_CHAT]:
79
  try:
 
 
 
 
 
80
  await self.send_photo(
81
  chat_id=chat_id,
82
  photo=Config.START_PIC,
83
+ caption=caption,
 
 
 
84
  reply_markup=InlineKeyboardMarkup(
85
  [[
86
  InlineKeyboardButton("ᴜᴘᴅᴀᴛᴇs", url="https://t.me/codeflix_bots")
87
  ]]
88
  )
89
  )
 
90
  except Exception as e:
91
  print(f"Failed to send message in chat {chat_id}: {e}")
92
 
93
+ # 🔥 Send to Bot Owner as Private Message (DM)
94
+ try:
95
+ await self.send_photo(
96
+ chat_id=Config.OWNER_ID, # Owner ku DM la varum
97
+ photo=Config.START_PIC,
98
+ caption=caption,
99
+ reply_markup=InlineKeyboardMarkup(
100
+ [[
101
+ InlineKeyboardButton("ᴜᴘᴅᴀᴛᴇs", url="https://t.me/codeflix_bots")
102
+ ]]
103
+ )
104
+ )
105
+ print("✅ Startup message sent to Owner DM successfully!")
106
+ except Exception as e:
107
+ print(f"Failed to send message to Owner DM: {e}")
108
+
109
  async def stop(self, *args, **kwargs):
110
  await super().stop(*args, **kwargs)
111
  print("Bot is gracefully shutting down...")
 
114
  try:
115
  Bot().run()
116
  except Exception as e:
117
+ print(f"Stopped: {e}")