github.py 1.6 KB

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