user_info.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 spamwatch.get_ban(
  21. user_id) == False else True
  22. caption = f"""
  23. **ID:** `{user_id}`
  24. **DC:** {dc_id}
  25. **Name:** {first_name}
  26. **Username:** {("@" + username) if username else None}
  27. **Permalink:** {mention}
  28. **Status:** {status}
  29. **Sudo:** {is_sudo}
  30. **Karma:** {karma}
  31. **Gbanned:** {is_gbanned}
  32. **Spamwatch Restricted:** {banned_in_spamwatch}
  33. """
  34. return [caption, photo_id]
  35. @app.on_message(filters.command("info"))
  36. async def info_func(_, message):
  37. try:
  38. if len(message.command) != 2:
  39. await message.reply_text("**Usage:**/info [USERNAME|ID]")
  40. return
  41. user = message.text.split(None, 1)[1]
  42. info_caption, photo_id = await get_user_info(user)
  43. if not photo_id:
  44. await app.send_message(message.chat.id, text=info_caption)
  45. return
  46. photo = await app.download_media(photo_id)
  47. await app.send_photo(message.chat.id, photo=photo, caption=info_caption)
  48. os.remove(photo)
  49. except Exception as e:
  50. await message.reply_text(str(e))
  51. e = traceback.format_exc()
  52. print(e)