user_info.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from wbb import app, SUDOERS, spamwatch
  2. from pyrogram import filters
  3. from wbb.utils.dbfunctions import is_gbanned_user, user_global_karma
  4. import os
  5. import traceback
  6. __MODULE__ = "Info"
  7. __HELP__ = "/info [USERNAME|ID] - Get info about a user."
  8. async def get_user_info(user):
  9. user = await app.get_users(user)
  10. user_id = user.id
  11. username = user.username
  12. first_name = user.first_name
  13. mention = user.mention("Link")
  14. status = user.status
  15. dc_id = user.dc_id
  16. photo_id = user.photo.big_file_id if user.photo else None
  17. is_gbanned = await is_gbanned_user(user_id)
  18. is_sudo = user_id in SUDOERS
  19. karma = await user_global_karma(user_id)
  20. banned_in_spamwatch = False if not spamwatch.get_ban(user_id) else True
  21. caption = f"""
  22. **ID:** `{user_id}`
  23. **DC:** {dc_id}
  24. **Name:** {first_name}
  25. **Username:** {("@" + username) if username else None}
  26. **Permalink:** {mention}
  27. **Status:** {status}
  28. **Sudo:** {is_sudo}
  29. **Karma:** {karma}
  30. **Gbanned:** {is_gbanned}
  31. **Spamwatch Restricted:** {banned_in_spamwatch}
  32. """
  33. return [caption, photo_id]
  34. @app.on_message(filters.command("info"))
  35. async def info_func(_, message):
  36. try:
  37. if message.reply_to_message:
  38. user = message.reply_to_message.from_user.id
  39. elif not message.reply_to_message and len(message.command) == 1:
  40. user = message.from_user.id
  41. elif not message.reply_to_message and len(message.command) != 1:
  42. user = message.text.split(None, 1)[1]
  43. info_caption, photo_id = await get_user_info(user)
  44. if not photo_id:
  45. await app.send_message(message.chat.id, text=info_caption)
  46. return
  47. photo = await app.download_media(photo_id)
  48. await app.send_photo(message.chat.id, photo=photo, caption=info_caption)
  49. os.remove(photo)
  50. except Exception as e:
  51. await message.reply_text(str(e))
  52. e = traceback.format_exc()
  53. print(e)