github.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import aiohttp
  2. from pyrogram import filters
  3. from wbb import app
  4. from wbb.utils.errors import capture_err
  5. __MODULE__ = 'Github'
  6. __HELP__ = "Get information about a GitHub user.\n /github [username]"
  7. @app.on_message(filters.command('github'))
  8. @capture_err
  9. async def github(_, message):
  10. if len(message.command) != 2:
  11. await message.reply_text("/git Username")
  12. return
  13. username = message.text.split(None, 1)[1]
  14. URL = f'https://api.github.com/users/{username}'
  15. async with aiohttp.ClientSession() as session:
  16. async with session.get(URL) as request:
  17. if request.status == 404:
  18. return await message.reply_text("404")
  19. result = await request.json()
  20. try:
  21. url = result['html_url']
  22. name = result['name']
  23. company = result['company']
  24. bio = result['bio']
  25. created_at = result['created_at']
  26. avatar_url = result['avatar_url']
  27. blog = result['blog']
  28. location = result['location']
  29. repositories = result['public_repos']
  30. followers = result['followers']
  31. following = result['following']
  32. caption = f"""**Info Of {name}**
  33. **Username:** `{username}`
  34. **Bio:** `{bio}`
  35. **Profile Link:** [Here]({url})
  36. **Company:** `{company}`
  37. **Created On:** `{created_at}`
  38. **Repositories:** `{repositories}`
  39. **Blog:** `{blog}`
  40. **Location:** `{location}`
  41. **Followers:** `{followers}`
  42. **Following:** `{following}`"""
  43. except Exception as e:
  44. print(str(e))
  45. pass
  46. await message.reply_photo(photo=avatar_url, caption=caption)