misc.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import secrets
  2. import string
  3. import ipinfo
  4. from pyrogram import filters
  5. from pyrogram.types import Message
  6. from cryptography.fernet import Fernet
  7. from wbb.utils.botinfo import BOT_ID
  8. from wbb import app, FERNET_ENCRYPTION_KEY
  9. from wbb.utils import cust_filter, random_line
  10. __MODULE__ = "Misc"
  11. __HELP__ = '''/commit - Generate Funny Commit Messages
  12. /runs - Idk Test Yourself
  13. /quote - Get Random Linux Quotes
  14. /id - Get Chat_ID or User_ID
  15. /dev - Forward Anything To Developers [SPAM = GBAN]
  16. /random - Generate Random Complex Passwords
  17. /http - Get Cats Reference Photo For Http Error Codes
  18. /encrypt - Encrypt Text [Can Only Be Decrypted By This Bot]
  19. /decrypt - Decrypt Text
  20. /ipinfo - Get Info About An Ip Address'''
  21. @app.on_message(cust_filter.command(commands=("commit")) & ~filters.edited)
  22. async def commit(_, message: Message):
  23. await message.reply_text((await random_line('wbb/utils/commit.txt')))
  24. @app.on_message(cust_filter.command(commands=("runs")) & ~filters.edited)
  25. async def runs(_, message: Message):
  26. await message.reply_text((await random_line('wbb/utils/runs.txt')))
  27. @app.on_message(cust_filter.command(commands=("quote")) & ~filters.edited)
  28. async def quote(_, message: Message):
  29. await message.reply_text((await random_line('wbb/utils/quotes.txt')))
  30. @app.on_message(cust_filter.command(commands=("id")) & ~filters.edited)
  31. async def get_id(_, message: Message):
  32. app.set_parse_mode("markdown")
  33. if message.text != '/id':
  34. username = message.text.replace('/id', '')
  35. user_id = (await app.get_users(username)).id
  36. msg = f"{username}'s ID is `{user_id}`"
  37. await message.reply_text(msg)
  38. elif message.text == '/id' and not bool(message.reply_to_message):
  39. chat_id = message.chat.id
  40. msg = f"{message.chat.title}'s ID is `{chat_id}`"
  41. await message.reply_text(msg)
  42. elif message.text == '/id' and bool(message.reply_to_message):
  43. from_user_id = message.reply_to_message.from_user.id
  44. from_user_mention = message.reply_to_message.from_user.mention
  45. msg = f"{from_user_mention}'s ID is `{from_user_id}`"
  46. await message.reply_text(msg)
  47. @app.on_message(cust_filter.command(commands=("dev")) & ~filters.edited)
  48. async def dev(_, message: Message):
  49. app.set_parse_mode("markdown")
  50. if (await app.get_chat_member(
  51. message.chat.id,
  52. BOT_ID)).can_restrict_members:
  53. await message.reply_to_message.forward('WBBSupport')
  54. await app.send_message("WBBSupport",
  55. "Forwarded By: `{}` | {}\n"
  56. "Forwarded From: `{}` | {}"
  57. .format(message.from_user.id,
  58. message.from_user.mention,
  59. message.chat.id,
  60. message.chat.title))
  61. await message.reply_text("Your Message Has Been Forward To Devs,"
  62. + " Any Missuse Of This Feature Will Not"
  63. + " Be Tolerated And You Will Be"
  64. + " Gbanned instantaneously!")
  65. else:
  66. await message.reply_text("To Use This Feature You Have To Make Me"
  67. + " Admin")
  68. # Password
  69. @app.on_message(cust_filter.command(commands=('random')) & ~filters.edited)
  70. async def random(_, message: Message):
  71. app.set_parse_mode('markdown')
  72. if message.text != "/random":
  73. length = message.text.replace('/random', '')
  74. try:
  75. if 1 < int(length) < 1000:
  76. alphabet = string.ascii_letters + string.digits
  77. password = ''.join(secrets.choice(alphabet) for i in
  78. range(int(length)))
  79. await message.reply_text(f"`{password}`")
  80. else:
  81. await message.reply_text('Specify A Length Between 1-1000')
  82. except ValueError:
  83. await message.reply_text("Strings Won't Work!, Pass A"
  84. + " Positive Integer Between 1-1000")
  85. else:
  86. await message.reply_text('"/random" Needs An Argurment.'
  87. ' Ex: `/random 5`')
  88. # http cat search
  89. @app.on_message(cust_filter.command(commands=('http')) & ~filters.edited)
  90. async def http(_, message: Message):
  91. if message.text != "/http":
  92. code = message.text.replace('/http', '')
  93. url = f"https://http.cat/{code}"
  94. final = url.replace(' ', '')
  95. await message.reply_photo(final)
  96. else:
  97. await message.reply_text('"/http" Needs An Argument. Ex: `/http 404`')
  98. # Encrypt
  99. @app.on_message(cust_filter.command(commands=('encrypt')) & ~filters.edited)
  100. async def encrypt(_, message: Message):
  101. app.set_parse_mode('markdown')
  102. if not message.reply_to_message:
  103. await message.reply_text('Reply To A Message To Encrypt It.')
  104. else:
  105. text = message.reply_to_message.text
  106. text_in_bytes = bytes(text, 'utf-8')
  107. cipher_suite = Fernet(FERNET_ENCRYPTION_KEY)
  108. encrypted_text = cipher_suite.encrypt(text_in_bytes)
  109. bytes_in_text = encrypted_text.decode("utf-8")
  110. await message.reply_text(bytes_in_text)
  111. # Decrypt
  112. @app.on_message(cust_filter.command(commands=('decrypt')) & ~filters.edited)
  113. async def decrypt(_, message: Message):
  114. if not message.reply_to_message:
  115. await message.reply_text('Reply To A Message To Decrypt It.')
  116. else:
  117. text = message.reply_to_message.text
  118. text_in_bytes = bytes(text, 'utf-8')
  119. cipher_suite = Fernet(FERNET_ENCRYPTION_KEY)
  120. decoded_text = cipher_suite.decrypt(text_in_bytes)
  121. bytes_in_text = decoded_text.decode("utf-8")
  122. await message.reply_text(bytes_in_text)
  123. # Ipinfo
  124. @app.on_message(cust_filter.command(commands=('ipinfo')) & ~filters.edited)
  125. async def ipaddrinfo(_, message: Message):
  126. app.set_parse_mode('markdown')
  127. ipaddr = message.text.replace("/ipinfo", "")
  128. if ipaddr != "":
  129. handler = ipinfo.getHandler()
  130. details = handler.getDetails(ipaddr)
  131. await message.reply_text(f'''`IP - {details.ip}
  132. City - {details.city}
  133. Region - {details.region}
  134. Country - {details.country}
  135. Location - {details.loc}
  136. ORG - {details.org}
  137. Postal - {details.postal}
  138. Timezone - {details.timezone}`''')
  139. else:
  140. await message.reply_text('`/ipinfo` Requires An IP As Argument'
  141. + '. Ex - `/ipinfo 1.1.1.1`')