├── README.md ├── config.py └── main.py /README.md: -------------------------------------------------------------------------------- 1 |

InfoBot Telegram Bot 🌌

2 | 3 |

4 | InfoBot: A powerful Telegram bot script for getting info about users, bots, channels, groups, and supergroups 5 |

6 | 7 |

8 | GitHub stars 9 | GitHub forks 10 | GitHub issues 11 | GitHub license 12 | GitHub pull requests 13 | PyPI - Python Version 14 | GitHub top language 15 |

16 | 17 |
18 | 19 | ## 🌟 Features 20 | 21 | - 📡 **Info About Channel** 22 | - 🤖 **Info About Bot** 23 | - 👥 **Info About Group** 24 | - 🏢 **Info About SuperGroup** 25 | - 👤 **Info About User** 26 | 27 | ## Requirements 28 | 29 | Before you begin, ensure you have met the following requirements: 30 | 31 | - 🐍 Python 3.9 or higher. 32 | - 📦 `pyrogram` library. 33 | - 🤖 A Telegram bot token (you can get one from [@BotFather](https://t.me/BotFather) on Telegram). 34 | - 🔑 API ID and Hash: You can get these by creating an application on [my.telegram.org](https://my.telegram.org). 35 | 36 | ## Installation 37 | 38 | To install `pyrogram` run the following command: 39 | 40 | ```bash 41 | pip install pyrogram 42 | ``` 43 | 44 | **Note: If you previously installed `pyrofork`, uninstall it before installing `pyrogram`.** 45 | 46 | ## Configuration 47 | 48 | 1. Open the `config.py` file in your favorite text editor. 49 | 2. Replace the placeholders for `API_ID`, `API_HASH`, and `BOT_TOKEN` with your actual values: 50 | - **`API_ID`**: Your API ID from [my.telegram.org](https://my.telegram.org). 51 | - **`API_HASH`**: Your API Hash from [my.telegram.org](https://my.telegram.org). 52 | - **`BOT_TOKEN`**: The token you obtained from [@BotFather](https://t.me/BotFather). 53 | 54 | ## Deploy the Bot 55 | 56 | ```sh 57 | git clone https://github.com/abirxdhack/InfoBot 58 | cd InfoBot 59 | python main.py 60 | ``` 61 | 62 | ## Usage 🛠️ 63 | 64 | The bot supports the following commands: 65 | 66 | - `/info `: Gives info based on a provided username. 67 | - `/info `: Gives info based on a provided userid. 68 | - `/info `: Gives info based on a provided username. 69 | - `/info `: Gives info based on a provided Chatid. 70 | - `/info `: Gives info based on a provided username. 71 | - `/info `: Gives info based on a provided chatid. 72 | - `/info `: Gives info based on a provided username. 73 | - `/info `: Gives info based on a provided Chatid. 74 | - `/info `: Gives info based on a provided username. 75 | - `/info `: Gives info based on a provided Chatid. 76 | - `.info `: Gives info based on a provided username. 77 | - `.info `: Gives info based on a provided userid. 78 | - `.info `: Gives info based on a provided username. 79 | - `.info `: Gives info based on a provided Chatid. 80 | - `.info `: Gives info based on a provided username. 81 | - `.info `: Gives info based on a provided chatid. 82 | - `.info `: Gives info based on a provided username. 83 | - `.info `: Gives info based on a provided Chatid. 84 | - `.info `: Gives info based on a provided username. 85 | - `.info `: Gives info based on a provided Chatid. 86 | 87 | ## Author 📝 88 | 89 | - Name: Abir Arafat Chawdhury 90 | - Telegram: [@abirxdhackz](https://t.me/abirxdhackz) 91 | 92 | ## Author 📝 93 | 94 | - Name: 404 Coder 95 | - Telegram: [@nkka404](https://t.me/nkka404) 96 | 97 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | # Replace these with your actual API details 2 | API_ID = "282xx710" # Replace with your API ID Get From my.telegram.org 3 | API_HASH = "7fc5b3ddghsdxxxb86481ab5eca3" # Replace with your API Hash Get From my.telegram.org 4 | BOT_TOKEN = "78249889xxxxffergipu88wmA9u1tOtq8qddzhyL0" # Replace with your Bot Token Get From @BotFather 5 | COMMAND_PREFIX = ["/", ".", "!", ","] #Used Just For Proffessionalism In Bot 6 | PROFILE_ERROR_URL = "https://t.me/BotsDevZone/243" #Replace With Your Desired One 7 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from datetime import datetime, timedelta 3 | from dateutil.relativedelta import relativedelta 4 | from pyrogram import filters, Client 5 | from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup 6 | from pyrogram.enums import ParseMode, ChatType, UserStatus 7 | from pyrogram.errors import PeerIdInvalid, UsernameNotOccupied, ChannelInvalid 8 | from config import COMMAND_PREFIX, PROFILE_ERROR_URL, API_ID, API_HASH, BOT_TOKEN 9 | 10 | # Set up logging 11 | logging.basicConfig(level=logging.INFO) 12 | logger = logging.getLogger(__name__) 13 | 14 | START_MESSAGE = """ 15 | Welcome to the Telegram Info Bot 🌟 16 | 17 | Get quick and detailed insights about any Telegram user or group. 18 | 19 | Features: 20 | 👤 Full Name 21 | 🆔 User ID 22 | 🔖 Username 23 | 💬 Chat ID 24 | 🌐 Data Center Location 25 | 💎 Premium Status 26 | 🛡 Verified Badge 27 | 🚩 Account Flags 28 | 🕒 Online Status 29 | 📅 Account Creation Date 30 | ⏳ Account Age 31 | 32 | Use /info or /id to get started! 🚀 33 | """ 34 | 35 | # Mapping of Data Center IDs to their locations 36 | DC_LOCATIONS = { 37 | 1: "MIA, Miami, USA, US", 38 | 2: "AMS, Amsterdam, Netherlands, NL", 39 | 3: "MBA, Mumbai, India, IN", 40 | 4: "STO, Stockholm, Sweden, SE", 41 | 5: "SIN, Singapore, SG", 42 | 6: "LHR, London, United Kingdom, GB", 43 | 7: "FRA, Frankfurt, Germany, DE", 44 | 8: "JFK, New York, USA, US", 45 | 9: "HKG, Hong Kong, HK", 46 | 10: "TYO, Tokyo, Japan, JP", 47 | 11: "SYD, Sydney, Australia, AU", 48 | 12: "GRU, São Paulo, Brazil, BR", 49 | 13: "DXB, Dubai, UAE, AE", 50 | 14: "CDG, Paris, France, FR", 51 | 15: "ICN, Seoul, South Korea, KR", 52 | } 53 | 54 | # Function to calculate account age accurately 55 | def calculate_account_age(creation_date): 56 | today = datetime.now() 57 | delta = relativedelta(today, creation_date) 58 | years = delta.years 59 | months = delta.months 60 | days = delta.days 61 | return f"{years} years, {months} months, {days} days" 62 | 63 | # Function to estimate account creation date based on user ID 64 | def estimate_account_creation_date(user_id): 65 | # Known reference points for user IDs and their creation dates 66 | reference_points = [ 67 | (100000000, datetime(2013, 8, 1)), # Telegram's launch date 68 | (1273841502, datetime(2020, 8, 13)), # Example reference point 69 | (1500000000, datetime(2021, 5, 1)), # Another reference point 70 | (2000000000, datetime(2022, 12, 1)), # Another reference point 71 | ] 72 | 73 | # Find the closest reference point 74 | closest_point = min(reference_points, key=lambda x: abs(x[0] - user_id)) 75 | closest_user_id, closest_date = closest_point 76 | 77 | # Calculate the difference in user IDs 78 | id_difference = user_id - closest_user_id 79 | 80 | # Estimate the creation date based on the difference 81 | # Assuming 250,000 user IDs are created per day (adjust as needed) 82 | days_difference = id_difference / 20000000 83 | creation_date = closest_date + timedelta(days=days_difference) 84 | 85 | return creation_date 86 | 87 | def setup_info_handler(app): 88 | @app.on_message(filters.command(["info", "id"], prefixes=COMMAND_PREFIX) & (filters.private | filters.group)) 89 | async def handle_info_command(client: Client, message: Message): 90 | logger.info("Received /info or /id command") 91 | try: 92 | progress_message = await client.send_message(message.chat.id, "**✨ Smart Tools Fetching Info From Database 💥**") 93 | try: 94 | if not message.command or (len(message.command) == 1 and not message.reply_to_message): 95 | logger.info("Fetching current user info") 96 | user = message.from_user 97 | chat = message.chat 98 | premium_status = "✅ Yes" if user.is_premium else "❌ No" 99 | dc_location = DC_LOCATIONS.get(user.dc_id, "Unknown") 100 | account_created = estimate_account_creation_date(user.id) 101 | account_created_str = account_created.strftime("%B %d, %Y") 102 | account_age = calculate_account_age(account_created) 103 | 104 | # Added verification and status 105 | verified_status = "✅ Yes" if getattr(user, 'is_verified', False) else "❌ No" 106 | 107 | status = "⚪️ Unknown" 108 | if user.status: 109 | if user.status == UserStatus.ONLINE: 110 | status = "✅ Online" 111 | elif user.status == UserStatus.OFFLINE: 112 | status = "❌ Offline" 113 | elif user.status == UserStatus.RECENTLY: 114 | status = "☑️ Recently online" 115 | elif user.status == UserStatus.LAST_WEEK: 116 | status = "✖️ Last seen within week" 117 | elif user.status == UserStatus.LAST_MONTH: 118 | status = "❎ Last seen within month" 119 | 120 | response = ( 121 | "🌟 **User Information** 🌟\n\n" 122 | f"👤 **Full Name:** {user.first_name} {user.last_name or ''}\n" 123 | f"🆔 **User ID:** `{user.id}`\n" 124 | f"🔖 **Username:** @{user.username}\n" 125 | f"💬 **Chat Id:** `{chat.id}`\n" 126 | f"🌐 **Data Center:** {user.dc_id} ({dc_location})\n" 127 | f"💎 **Premium User:** {premium_status}\n" 128 | f"🛡 **Verified:** {verified_status}\n" 129 | f"🚩 **Flags:** {'⚠️ Scam' if getattr(user, 'is_scam', False) else '⚠️ Fake' if getattr(user, 'is_fake', False) else '✅ Clean'}\n" 130 | f"🕒 **Status:** {status}\n" 131 | f"📅 **Account Created On:** {account_created_str}\n" 132 | f"⏳ **Account Age:** {account_age}" 133 | ) 134 | buttons = [ 135 | [InlineKeyboardButton("✨ Android Link", url=f"tg://openmessage?user_id={user.id}"), InlineKeyboardButton("⚡️ iOS Link", url=f"tg://user?id={user.id}")], 136 | [InlineKeyboardButton("💥 Permanent Link", user_id=user.id)], 137 | ] 138 | photo = await client.download_media(user.photo.big_file_id) if user.photo else PROFILE_ERROR_URL 139 | await client.send_photo(chat_id=message.chat.id, photo=photo, caption=response, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) 140 | logger.info("User info fetched successfully with buttons") 141 | elif message.reply_to_message: 142 | # Show info of the replied user or bot 143 | logger.info("Fetching info of the replied user or bot") 144 | user = message.reply_to_message.from_user 145 | chat = message.chat 146 | premium_status = "✅ Yes" if user.is_premium else "❌ No" 147 | dc_location = DC_LOCATIONS.get(user.dc_id, "Unknown") 148 | account_created = estimate_account_creation_date(user.id) 149 | account_created_str = account_created.strftime("%B %d, %Y") 150 | account_age = calculate_account_age(account_created) 151 | 152 | # Added verification and status 153 | verified_status = "✅ Yes" if getattr(user, 'is_verified', False) else "❌ No" 154 | 155 | status = "⚪️ Unknown" 156 | if user.status: 157 | if user.status == UserStatus.ONLINE: 158 | status = "🟢 Online" 159 | elif user.status == UserStatus.OFFLINE: 160 | status = "⚫️ Offline" 161 | elif user.status == UserStatus.RECENTLY: 162 | status = "🟡 Recently online" 163 | elif user.status == UserStatus.LAST_WEEK: 164 | status = "🟠 Last seen within week" 165 | elif user.status == UserStatus.LAST_MONTH: 166 | status = "🔴 Last seen within month" 167 | 168 | response = ( 169 | "🌟 **User Information** 🌟\n\n" 170 | f"👤 **Full Name:** {user.first_name} {user.last_name or ''}\n" 171 | f"🆔 **User ID:** `{user.id}`\n" 172 | f"🔖 **Username:** @{user.username}\n" 173 | f"💬 **Chat Id:** `{chat.id}`\n" 174 | f"🌐 **Data Center:** {user.dc_id} ({dc_location})\n" 175 | f"💎 **Premium User:** {premium_status}\n" 176 | f"🛡 **Verified:** {verified_status}\n" 177 | f"🚩 **Flags:** {'⚠️ Scam' if getattr(user, 'is_scam', False) else '⚠️ Fake' if getattr(user, 'is_fake', False) else '✅ Clean'}\n" 178 | f"🕒 **Status:** {status}\n" 179 | f"📅 **Account Created On:** {account_created_str}\n" 180 | f"⏳ **Account Age:** {account_age}" 181 | ) 182 | if user.is_bot: 183 | response = ( 184 | "🌟 **Bot Information** 🌟\n\n" 185 | f"🤖 **Bot Name:** {user.first_name} {user.last_name or ''}\n" 186 | f"🆔 **Bot ID:** `{user.id}`\n" 187 | f"🔖 **Username:** @{user.username}\n" 188 | f"🌐 **Data Center:** {user.dc_id} ({dc_location})\n" 189 | f"💎 **Premium User:** {premium_status}\n" 190 | f"🛡 **Verified:** {verified_status}\n" 191 | f"🚩 **Flags:** {'⚠️ Scam' if getattr(user, 'is_scam', False) else '⚠️ Fake' if getattr(user, 'is_fake', False) else '✅ Clean'}\n" 192 | f"📅 **Account Created On:** {account_created_str}\n" 193 | f"⏳ **Account Age:** {account_age}" 194 | ) 195 | buttons = [ 196 | [InlineKeyboardButton("✨ Android Link", url=f"tg://openmessage?user_id={user.id}"), InlineKeyboardButton("⚡️ iOS Link", url=f"tg://user?id={user.id}")], 197 | [InlineKeyboardButton("💥 Permanent Link", user_id=user.id)], 198 | ] 199 | photo = await client.download_media(user.photo.big_file_id) if user.photo else PROFILE_ERROR_URL 200 | await client.send_photo(chat_id=message.chat.id, photo=photo, caption=response, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) 201 | logger.info("Replied user info fetched successfully with buttons") 202 | elif len(message.command) > 1: 203 | # Extract username from the command 204 | logger.info("Extracting username from the command") 205 | username = message.command[1].strip('@').replace('https://', '').replace('http://', '').replace('t.me/', '').replace('/', '').replace(':', '') 206 | 207 | try: 208 | # First, attempt to get user or bot info 209 | logger.info(f"Fetching info for user or bot: {username}") 210 | user = await client.get_users(username) 211 | premium_status = "✅ Yes" if user.is_premium else "❌ No" 212 | dc_location = DC_LOCATIONS.get(user.dc_id, "Unknown") 213 | account_created = estimate_account_creation_date(user.id) 214 | account_created_str = account_created.strftime("%B %d, %Y") 215 | account_age = calculate_account_age(account_created) 216 | 217 | # Added verification and status 218 | verified_status = "✅ Yes" if getattr(user, 'is_verified', False) else "❌ No" 219 | 220 | status = "⚪️ Unknown" 221 | if user.status: 222 | if user.status == UserStatus.ONLINE: 223 | status = "🟢 Online" 224 | elif user.status == UserStatus.OFFLINE: 225 | status = "⚫️ Offline" 226 | elif user.status == UserStatus.RECENTLY: 227 | status = "🟡 Recently online" 228 | elif user.status == UserStatus.LAST_WEEK: 229 | status = "🟠 Last seen within week" 230 | elif user.status == UserStatus.LAST_MONTH: 231 | status = "🔴 Last seen within month" 232 | 233 | response = ( 234 | "🌟 **User Information** 🌟\n\n" 235 | f"👤 **Full Name:** {user.first_name} {user.last_name or ''}\n" 236 | f"🆔 **User ID:** `{user.id}`\n" 237 | f"🔖 **Username:** @{user.username}\n" 238 | f"💬 **Chat Id:** `{user.id}`\n" 239 | f"🌐 **Data Center:** {user.dc_id} ({dc_location})\n" 240 | f"💎 **Premium User:** {premium_status}\n" 241 | f"🛡 **Verified:** {verified_status}\n" 242 | f"🚩 **Flags:** {'⚠️ Scam' if getattr(user, 'is_scam', False) else '⚠️ Fake' if getattr(user, 'is_fake', False) else '✅ Clean'}\n" 243 | f"🕒 **Status:** {status}\n" 244 | f"📅 **Account Created On:** {account_created_str}\n" 245 | f"⏳ **Account Age:** {account_age}" 246 | ) 247 | if user.is_bot: 248 | response = ( 249 | "🌟 **Bot Information** 🌟\n\n" 250 | f"🤖 **Bot Name:** {user.first_name} {user.last_name or ''}\n" 251 | f"🆔 **Bot ID:** `{user.id}`\n" 252 | f"🔖 **Username:** @{user.username}\n" 253 | f"🌐 **Data Center:** {user.dc_id} ({dc_location})\n" 254 | f"💎 **Premium User:** {premium_status}\n" 255 | f"🛡 **Verified:** {verified_status}\n" 256 | f"🚩 **Flags:** {'⚠️ Scam' if getattr(user, 'is_scam', False) else '⚠️ Fake' if getattr(user, 'is_fake', False) else '✅ Clean'}\n" 257 | f"📅 **Account Created On:** {account_created_str}\n" 258 | f"⏳ **Account Age:** {account_age}" 259 | ) 260 | buttons = [ 261 | [InlineKeyboardButton("✨ Android Link", url=f"tg://openmessage?user_id={user.id}"), InlineKeyboardButton("⚡️ iOS Link", url=f"tg://user?id={user.id}")], 262 | [InlineKeyboardButton("💥 Permanent Link", user_id=user.id)], 263 | ] 264 | photo = await client.download_media(user.photo.big_file_id) if user.photo else PROFILE_ERROR_URL 265 | await client.send_photo(chat_id=message.chat.id, photo=photo, caption=response, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) 266 | logger.info("User/bot info fetched successfully with buttons") 267 | except (PeerIdInvalid, UsernameNotOccupied, IndexError): 268 | logger.info(f"Username '{username}' not found as a user/bot. Checking for chat...") 269 | try: 270 | chat = await client.get_chat(username) 271 | dc_location = DC_LOCATIONS.get(chat.dc_id, "Unknown") 272 | response = ( 273 | f"🌟 **Chat Information** 🌟\n\n" 274 | f"📛 **{chat.title}**\n" 275 | f"🆔 **ID:** `{chat.id}`\n" 276 | f"📌 **Type:** {'Supergroup' if chat.type == ChatType.SUPERGROUP else 'Group' if chat.type == ChatType.GROUP else 'Channel'}\n" 277 | f"👥 **Member count:** {chat.members_count}" 278 | ) 279 | buttons = [ 280 | [InlineKeyboardButton("⚡️Joining Link", url=f"t.me/c/{str(chat.id).replace('-100', '')}/100"), InlineKeyboardButton("💥 Permanent Link", url=f"t.me/c/{str(chat.id).replace('-100', '')}/100")], 281 | ] 282 | photo = await client.download_media(chat.photo.big_file_id) if chat.photo else PROFILE_ERROR_URL 283 | await client.send_photo(chat_id=message.chat.id, photo=photo, caption=response, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) 284 | logger.info("Chat info fetched successfully with buttons") 285 | except (ChannelInvalid, PeerIdInvalid): 286 | await client.send_message(chat_id=message.chat.id, text="**Looks like I don't have control over that user.**", parse_mode=ParseMode.MARKDOWN) 287 | except Exception as e: 288 | logger.error(f"Error fetching chat info: {str(e)}") 289 | await client.send_message(chat_id=message.chat.id, text=f"**Looks like I don't have control over that user**", parse_mode=ParseMode.MARKDOWN) 290 | except Exception as e: 291 | logger.error(f"Error fetching user or bot info: {str(e)}") 292 | await client.send_message(chat_id=message.chat.id, text=f"**Looks like I don't have control over that user**", parse_mode=ParseMode.MARKDOWN) 293 | except Exception as e: 294 | logger.error(f"Unhandled exception: {str(e)}") 295 | await client.send_message(chat_id=message.chat.id, text=f"**Looks like I don't have control over that user**", parse_mode=ParseMode.MARKDOWN) 296 | else: 297 | await progress_message.delete() 298 | except Exception as e: 299 | logger.error(f"Unhandled exception: {str(e)}") 300 | 301 | @app.on_message(filters.command("start", prefixes=["/", ".", ",", "!"]) & (filters.group | filters.private)) 302 | async def start(client, message): 303 | buttons = [ 304 | [InlineKeyboardButton("Update Channel", url="https://t.me/Modvip_rm"), InlineKeyboardButton("My Dev👨‍💻", user_id=7303810912)] 305 | ] 306 | await client.send_message(message.chat.id, START_MESSAGE, parse_mode=ParseMode.HTML, disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(buttons)) 307 | 308 | app = Client("info_bot", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN) 309 | setup_info_handler(app) 310 | 311 | if __name__ == "__main__": 312 | app.run() 313 | --------------------------------------------------------------------------------