You are a Telegram bot named Sana. A user in a group said: "{ "": "Message",…
- User
Assistant: You are a Telegram bot named Sana. A user in a group said: "{ "": "Message", "id": 301146, "from_user": { "": "User", "id": 5866134594, "is_self": false, "is_contact": false, "is_mutual_contact": false, "is_deleted": false, "is_bot": false, "is_verified": false, "is_restricted": false, "is_scam": false, "is_fake": false, "is_support": false, "is_premium": false, "first_name": "RORONOA", "last_name": "ZORO", "status": "UserStatus.RECENTLY", "username": "sushant_01234", "dc_id": 5, "photo": { "": "ChatPhoto", "small_file_id": "AQADBQADVbgxGzVOgFYAEAIAA0Icpl0BAAOvVNR8vqC0gwAEHgQ", "small_photo_unique_id": "AgADVbgxGzVOgFY", "big_file_id": "AQADBQADVbgxGzVOgFYAEAMAA0Icpl0BAAOvVNR8vqC0gwAEHgQ", "big_photo_unique_id": "AgADVbgxGzVOgFY", "has_animation": false, "is_personal": false }, "restricts_new_chats": false, "is_close_friend": false, "have_access": true }, "date": "2025-05-17 21:19:24+00:00", "chat": { "": "Chat", "id": -1001961655253, "type": "ChatType.SUPERGROUP", "is_verified": false, "is_restricted": false, "is_creator": false, "is_scam": false, "is_fake": false, "title": "↳ ❝ [ ℂ𝕙𝕒𝕥𝕥𝕚𝕟𝕘 ℂ𝕝𝕦𝕓 ] ¡! ❞", "username": "ChattingClub007", "photo": { "": "ChatPhoto", "small_file_id": "AQADBAADx8YxG3JasVIAEAIAAyt0brYW____GEgSSKRCgtEABB4E", "small_photo_unique_id": "AgADx8YxG3JasVI", "big_file_id": "AQADBAADx8YxG3JasVIAEAMAAyt0brYW____GEgSSKRCgtEABB4E", "big_photo_unique_id": "AgADx8YxG3JasVI", "has_animation": false, "is_personal": false }, "dc_id": 4, "has_protected_content": false, "permissions": { "": "ChatPermissions", "can_send_messages": true, "can_send_audios": true, "can_send_documents": true, "can_send_photos": true, "can_send_videos": true, "can_send_video_notes": true, "can_send_voice_notes": true, "can_send_polls": true, "can_send_other_messages": true, "can_add_web_page_previews": true, "can_change_info": false, "can_invite_users": true, "can_pin_messages": false, "can_manage_topics": true, "can_send_media_messages": false }, "is_forum": false, "has_automatic_translation": false }, "mentioned": false, "scheduled": false, "from_scheduled": false, "has_protected_content": false, "is_from_offline": false, "text": "@KashDaYash sana isko roast kardo", "entities": [ { "_": "MessageEntity", "type": "MessageEntityType.MENTION", "offset": 0, "length": 11 } ], "show_caption_above_media": false, "outgoing": false }". Generate only the body of an async Python function named
handle_ai_logic(client, message)using latest Pyrogram v2+. if message have reply_to_message then reply for replied user Do NOT include imports or function definitions. ONLY return the inside code of that function. If anyone asks you to roast someone, roast them. But if they ask to roast "KashDaYash", deny and praise him instead. If the user is replying to someone, target that person in your response.User: @KashDaYash sana isko roast kardo Assistant:
- Assistant
if message.text and "roast" in message.text.lower(): target_user = None if message.reply_to_message: target_user = message.reply_to_message.from_user else: # get mentioned user(s) excluding @KashDaYash entities = message.entities or [] mentions = [] for ent in entities: if ent.type == "mention": username_mention = message.text[ent.offset:ent.offset + ent.length] if username_mention.lower() != "@kashyadyash": mentions.append(username_mention) if mentions: target_user = mentions[0]
if target_user: # Determine username or first name to mention if hasattr(target_user, "username") and target_user.username: name_to_use = "@" + target_user.username elif isinstance(target_user, str): name_to_use = target_user else: name_to_use = getattr(target_user, "first_name", "there") else: name_to_use = "" if (target_user and ((hasattr(target_user, "username") and target_user.username and target_user.username.lower() == "kashyadyash") or (isinstance(target_user, str) and target_user.lower() == "@kashyadyash"))): # praise KashDaYash await message.reply_text(f"Sorry, I can't roast @KashDaYash. He's an absolute legend and too awesome for that! 🌟") elif not target_user and "@kashyadyash" in message.text.lower(): # message mentions KashDaYash explicitly but no other user found await message.reply_text(f"Sorry, I can't roast @KashDaYash. He's an absolute legend and too awesome for that! 🌟") else: # Roast message if target_user: await message.reply_text(f"{name_to_use}, if being this awesome was a crime, you'd be serving a life sentence for your ego! 😂🔥") else: await message.reply_text("Who should I roast? Mention someone or reply to their message!")