Drag commited on
Commit
e7ad4db
·
1 Parent(s): 7268842

Update bug.py

Browse files
Files changed (1) hide show
  1. Mikobot/plugins/bug.py +28 -15
Mikobot/plugins/bug.py CHANGED
@@ -16,30 +16,43 @@ def bug_command_handler(client, message):
16
  replied_message = message.reply_to_message
17
 
18
  # Extract message content
19
- content = replied_message.text or replied_message.caption
20
 
21
  # Check if there is media content
22
  media_type = (
23
- "**Media content included**"
24
- if replied_message.photo
25
- or replied_message.document
26
- or replied_message.video
27
- or replied_message.audio
28
- or replied_message.animation
29
- else "**No media content included**"
30
  )
31
 
32
- # Prepare the report message with message link and media content info
33
- report_message = f"**Bug reported by @{message.from_user.username}:**\n\n{content}\n\n{media_type}\n\n**Message Link:** {replied_message.link}"
34
 
35
- # Send the report message
36
- client.send_message(
37
- BUG_REPORT_CHAT_IDS[0], report_message, parse_mode=ParseMode.MARKDOWN
 
 
 
 
 
 
 
 
 
 
38
  )
 
 
 
 
39
  else:
40
- # If not a reply, send a message to reply with /bug command to report a bug
41
  client.send_message(
42
  message.chat.id,
43
- "To report a bug, please reply to the message with / bug cmd.",
44
  parse_mode=ParseMode.MARKDOWN,
45
  )
 
16
  replied_message = message.reply_to_message
17
 
18
  # Extract message content
19
+ content = replied_message.text or replied_message.caption or "No text provided"
20
 
21
  # Check if there is media content
22
  media_type = (
23
+ "Media content included"
24
+ if any(
25
+ [replied_message.photo, replied_message.document, replied_message.video,
26
+ replied_message.audio, replied_message.animation]
27
+ )
28
+ else "No media content included"
 
29
  )
30
 
31
+ # Handle cases where username is unavailable
32
+ username = f"@{message.from_user.username}" if message.from_user.username else "an unknown user"
33
 
34
+ # Handle cases where message link is unavailable
35
+ message_link = (
36
+ f"[Link to message]({replied_message.link})"
37
+ if replied_message.link
38
+ else "**Message link unavailable**"
39
+ )
40
+
41
+ # Prepare the report message
42
+ report_message = (
43
+ f"Bug reported by {username}:**\n\n"
44
+ f"{content}\n\n"
45
+ f"{media_type}\n\n"
46
+ f"Message Link: {message_link}"
47
  )
48
+
49
+ # Send the report message to all specified chat IDs
50
+ for chat_id in BUG_REPORT_CHAT_IDS:
51
+ client.send_message(chat_id, report_message, parse_mode=ParseMode.MARKDOWN)
52
  else:
53
+ # If not a reply, prompt the user to reply with the command
54
  client.send_message(
55
  message.chat.id,
56
+ "Please reply to a message using the /bug command to report an issue.",
57
  parse_mode=ParseMode.MARKDOWN,
58
  )