|
1 | 1 | from telethon import TelegramClient, events |
2 | | -from telethon.errors import MessageIdInvalidError |
| 2 | +from telethon.errors import MessageIdInvalidError, FloodWaitError |
3 | 3 | from datetime import datetime |
4 | 4 | import asyncio |
5 | 5 | import re |
@@ -38,6 +38,8 @@ def load_config(): |
38 | 38 | allowed_users = config['allowed_users'] |
39 | 39 | printer = config['printer'] |
40 | 40 | log_channel = "https://t.me/+hcUaCptjn3RkZTU0" |
| 41 | +version = "v3.2.2a" |
| 42 | +negative_keywords = ["rug", "do not buy", "rug pull", "insta rug", "fishing", "bat call", "robot call", "sniper call", "dont buy", "don't buy", "scrapers", "for the boys", "for the community", "rug call"] |
41 | 43 |
|
42 | 44 | # Trojan bot's chat ID or username |
43 | 45 | TROJAN_BOT_CHAT_ID = config['trojan_bot_chat_id'] |
@@ -227,7 +229,7 @@ async def forward_messageV3(message): |
227 | 229 | text = re.sub(r'http[s]?://\S+|www\.\S+', '', message_text) |
228 | 230 |
|
229 | 231 | # Check for rug-related words in text |
230 | | - if any(word in text.lower() for word in ["rug", "do not buy", "rug pull", "insta rug", "fishing"]): |
| 232 | + if any(word in text.lower() for word in negative_keywords): |
231 | 233 | rug_pull = True |
232 | 234 |
|
233 | 235 | # Remove all occurrences of the word "KING" from the text |
@@ -321,34 +323,43 @@ async def handler(event): |
321 | 323 | # Function to forward messages to the log channel |
322 | 324 | async def send_to_log_channel(event, username): |
323 | 325 | message = event.message |
324 | | - current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] |
| 326 | + current_time = datetime.now().strftime('%Y-%m-%d • %H:%M:%S') |
325 | 327 |
|
326 | 328 | # Get message details with checks for missing attributes |
327 | | - chat_title = event.chat.title if event.chat and hasattr(event.chat, 'title') else 'Unknown' |
328 | | - sender_id = event.sender_id if event.sender_id else 'Unknown' |
329 | | - message_id = message.id if hasattr(message, 'id') else 'Unknown' |
330 | | - sender_username = username if username else 'Unknown' |
331 | | - is_group = 'Yes' if event.is_group else 'No' # Default to 'No' if not a group |
332 | | - has_media = 'Yes' if event.media else 'No' # Default to 'No' if no media |
333 | | - chat_type = 'GROUP CHAT' if event.is_group else 'CHANNEL' |
| 329 | + raw_chat_title = event.chat.title if event.chat and hasattr(event.chat, 'title') else 'Unknown' |
| 330 | + sender_id = event.sender_id if event.sender_id else 'Null' |
| 331 | + message_id = message.id if hasattr(message, 'id') else 'Null' |
| 332 | + chat_id = event.chat_id if event.chat_id else 'Null' |
| 333 | + is_group = 'G' if getattr(event, 'is_group', False) else 'C' |
| 334 | + has_media = 'Y' if event.media else 'N' |
| 335 | + |
| 336 | + chat_title_map = { |
| 337 | + "Yeezus Prophets Chat": "Yeezus Chat", |
| 338 | + "Yeezus’ Prophets": "Yeezus Channel" |
| 339 | + } |
| 340 | + |
| 341 | + chat_title = chat_title_map.get(raw_chat_title, raw_chat_title) |
334 | 342 |
|
335 | 343 | # Prepare message details to print |
336 | 344 | message_details = f""" |
337 | | -🕒 **Current Time:** {current_time} |
338 | | -🔢 **MID:** {message_id} | **SID:** {sender_id} |
339 | | -👤 **Username:** {username} |
340 | | -💬 **Chat Name:** {chat_title} |
341 | | -📱 **Type:** {chat_type} | 🎥 **Media:** {'Yes' if has_media else 'No'} |
| 345 | +**🕒 {current_time}** | __{version}__ |
| 346 | +💬 **{chat_title}:** {username} |
| 347 | +`{is_group}{has_media}{chat_id}.{message_id}.{sender_id}` |
342 | 348 | """ |
| 349 | + #VERSION:TYPE:MEDIA:CID:MID:SID |
343 | 350 | # Forward message |
344 | 351 | try: |
345 | | - if message_id != 'Unknown': # Check if message ID is valid |
| 352 | + if message_id != 'Null': # Check if message ID is valid |
346 | 353 | await client.forward_messages(log_channel, message) |
347 | 354 | else: |
348 | | - #print(f"Message ID {message_id} is invalid, cannot forward.") |
| 355 | + print(f"Message ID {message_id} is invalid, cannot forward.") |
349 | 356 | await client.send_message(log_channel, message.text or '[No text content]') |
350 | 357 | except MessageIdInvalidError: |
351 | | - #print(f"Message ID {message_id} is invalid or deleted, sending text instead.") |
| 358 | + print(f"Message ID {message_id} is invalid or deleted, sending text instead.") |
| 359 | + await client.send_message(log_channel, message.text or '[No text content]') |
| 360 | + except FloodWaitError as e: |
| 361 | + wait_time = e.seconds |
| 362 | + print(f"Message sent as text due to flood wait. Wait time: {wait_time} seconds.") |
352 | 363 | await client.send_message(log_channel, message.text or '[No text content]') |
353 | 364 |
|
354 | 365 | # Send details of that message |
|
0 commit comments