rice.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from pyrogram import filters
  2. from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
  3. from wbb import app
  4. RICE_GROUP = "DE_WM"
  5. RICE_CHANNEL = "RiceGallery"
  6. @app.on_message(filters.chat(RICE_GROUP)
  7. & filters.media
  8. & filters.regex(r"^\[RICE\] ")
  9. & ~filters.forwarded
  10. & ~filters.edited)
  11. async def rice(_, message: Message):
  12. """Forward media and media_group messages which has caption starts
  13. with [RICE] with space and description in RICE_GROUP to RICE_CHANNEL
  14. edited or forwarded messages won't be forwarded
  15. """
  16. await message.reply_text(
  17. "**Waiting for admin to approve**",
  18. reply_markup=InlineKeyboardMarkup(
  19. [
  20. [
  21. InlineKeyboardButton(
  22. "Approve (Forward)",
  23. callback_data="forward"
  24. ),
  25. InlineKeyboardButton(
  26. "Ignore",
  27. callback_data="ignore"
  28. )
  29. ]
  30. ]
  31. ),
  32. quote=True,
  33. parse_mode="markdown"
  34. )
  35. @app.on_callback_query(filters.regex("forward"))
  36. async def callback_query_forward_rice(_, callback_query):
  37. app.set_parse_mode("html")
  38. approver = callback_query.from_user
  39. group_chat = callback_query.message.chat
  40. approver_status = (await group_chat.get_member(approver.id)).status
  41. if not (approver_status in ("creator", "administrator")):
  42. await callback_query.answer("Only admin can approve this!")
  43. return
  44. await callback_query.answer("Successfully approved")
  45. m_rice = callback_query.message.reply_to_message
  46. if m_rice.media_group_id:
  47. message_id = m_rice.message_id
  48. media_group = await app.get_media_group(RICE_GROUP, message_id)
  49. reply = await app.forward_messages(
  50. RICE_CHANNEL, RICE_GROUP,
  51. [m.message_id for m in media_group])
  52. link = reply[0].link
  53. else:
  54. reply = await m_rice.forward(RICE_CHANNEL)
  55. link = reply.link
  56. await callback_query.message.delete()
  57. reply_text = (f"<b>OP</b>: {m_rice.from_user.mention()}\n"
  58. f"<b>Approver</b>: {approver.mention()}\n"
  59. f"<b>Forwarded</b>: "
  60. f"<a href=\"{link}\">Rice Gallery</a>")
  61. await m_rice.reply_text(reply_text, disable_web_page_preview=True)
  62. @app.on_callback_query(filters.regex("ignore"))
  63. async def callback_query_ignore_rice(_, callback_query):
  64. m_rice = callback_query.message.reply_to_message
  65. group_chat = callback_query.message.chat
  66. from_user = callback_query.from_user
  67. from_user_status = (await group_chat.get_member(from_user.id)).status
  68. rice_op = callback_query.message.reply_to_message.from_user
  69. if from_user.id == rice_op.id:
  70. await callback_query.answer("Ok, this rice won't be forwarded")
  71. elif from_user_status in ("creator", "administrator"):
  72. await m_rice.reply_text(f"{from_user.mention} ignored this rice")
  73. else:
  74. await callback_query.answer("Only admin or OP could ignore it")
  75. return
  76. await callback_query.message.delete()