Captain Ezio commited on
Commit
3fb2204
·
1 Parent(s): 88e4964

few updates

Browse files
Files changed (1) hide show
  1. Powers/plugins/info.py +49 -32
Powers/plugins/info.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  from traceback import format_exc
 
3
 
4
  from pyrogram import filters
5
  from pyrogram.types import Message
@@ -58,11 +59,29 @@ async def user_info(user, already=False):
58
  omp = "Hmmm.......Who is that again?"
59
  is_bot = user.is_bot
60
  is_fake = user.is_fake
 
61
  status = user.status
62
- if status == "offline":
63
- last_date = user.last_online_date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  else:
65
  last_date = "User is currently online"
 
66
  body = {
67
  "ID": user_id,
68
  "DC": dc_id,
@@ -73,12 +92,39 @@ async def user_info(user, already=False):
73
  "Support user type": [omp],
74
  "Bot" : is_bot,
75
  "Fake" : is_fake,
76
- "Status" : status,
77
  "Last seen" : [last_date],
78
  }
79
  caption = change("User info", body)
80
  return [caption, photo_id]
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  async def chat_info(chat, already=False):
84
  if not already:
@@ -115,35 +161,6 @@ async def chat_info(chat, already=False):
115
 
116
 
117
 
118
- @Gojo.on_message(command("info") & ~filters.edited)
119
- async def info_func(_, message: Message):
120
- if message.reply_to_message:
121
- user = message.reply_to_message.from_user.id
122
- elif not message.reply_to_message and len(message.command) == 1:
123
- user = message.from_user.id
124
- elif not message.reply_to_message and len(message.command) != 1:
125
- user = message.text.split(None, 1)[1]
126
-
127
- m = await message.reply_text(f"Fetching user info of user {user}...")
128
-
129
- try:
130
- info_caption, photo_id = await user_info(user)
131
- LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {user} in {m.chat.id}")
132
- except Exception as e:
133
- LOGGER.error(e)
134
- LOGGER.error(format_exc())
135
- return await m.edit(str(e))
136
-
137
- if not photo_id:
138
- return await m.edit(info_caption, disable_web_page_preview=True)
139
- photo = await Gojo.download_media(photo_id)
140
-
141
- await message.reply_photo(photo, caption=info_caption, quote=False)
142
- await m.delete()
143
- os.remove(photo)
144
- LOGGER.info(f"{message.from_user.id} fetched user info of user {user} in {m.chat.id}")
145
-
146
-
147
  @Gojo.on_message(command("chinfo") & ~filters.edited)
148
  async def chat_info_func(_, message: Message):
149
  try:
 
1
  import os
2
  from traceback import format_exc
3
+ from datetime import datetime
4
 
5
  from pyrogram import filters
6
  from pyrogram.types import Message
 
59
  omp = "Hmmm.......Who is that again?"
60
  is_bot = user.is_bot
61
  is_fake = user.is_fake
62
+
63
  status = user.status
64
+
65
+
66
+ if is_bot is True:
67
+ last_date = "Targeted user is a bot"
68
+ elif status == "recently":
69
+ last_date = "Recently"
70
+ elif status == "within_week":
71
+ last_date = "Within the last week"
72
+ elif status == "within_month":
73
+ last_date = "Within the last month"
74
+ elif status == "long_time_ago":
75
+ last_date = "A long time ago or may be I am blocked by the user :("
76
+ elif status == "online":
77
+ last_date = "Currently Online"
78
+ elif status == "offline":
79
+ last_date = datetime.fromtimestamp(user.status.date).strftime(
80
+ "%a, %d %b %Y, %H:%M:%S"
81
+ )
82
  else:
83
  last_date = "User is currently online"
84
+
85
  body = {
86
  "ID": user_id,
87
  "DC": dc_id,
 
92
  "Support user type": [omp],
93
  "Bot" : is_bot,
94
  "Fake" : is_fake,
 
95
  "Last seen" : [last_date],
96
  }
97
  caption = change("User info", body)
98
  return [caption, photo_id]
99
 
100
+ @Gojo.on_message(command("info") & ~filters.edited)
101
+ async def info_func(_, message: Message):
102
+ if message.reply_to_message:
103
+ user = message.reply_to_message.from_user.id
104
+ elif not message.reply_to_message and len(message.command) == 1:
105
+ user = message.from_user.id
106
+ elif not message.reply_to_message and len(message.command) != 1:
107
+ user = message.text.split(None, 1)[1]
108
+
109
+ m = await message.reply_text(f"Fetching user info of user {user}...")
110
+
111
+ try:
112
+ info_caption, photo_id = await user_info(user)
113
+ LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {user} in {m.chat.id}")
114
+ except Exception as e:
115
+ LOGGER.error(e)
116
+ LOGGER.error(format_exc())
117
+ return await m.edit(str(e))
118
+
119
+ if not photo_id:
120
+ return await m.edit(info_caption, disable_web_page_preview=True)
121
+ photo = await Gojo.download_media(photo_id)
122
+
123
+ await message.reply_photo(photo, caption=info_caption, quote=False)
124
+ await m.delete()
125
+ os.remove(photo)
126
+ LOGGER.info(f"{message.from_user.id} fetched user info of user {user} in {m.chat.id}")
127
+
128
 
129
  async def chat_info(chat, already=False):
130
  if not already:
 
161
 
162
 
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  @Gojo.on_message(command("chinfo") & ~filters.edited)
165
  async def chat_info_func(_, message: Message):
166
  try: