-
Notifications
You must be signed in to change notification settings - Fork 5
/
github.py
42 lines (40 loc) · 1.19 KB
/
github.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Get information about an user on GitHub
Syntax: .github USERNAME"""
from telethon import events
import requests
from ULTRA.utils import admin_cmd
@borg.on(admin_cmd("github (.*)"))
async def _(event):
if event.fwd_from:
return
input_str = event.pattern_match.group(1)
url = "https://api.github.com/users/{}".format(input_str)
r = requests.get(url)
if r.status_code != 404:
b = r.json()
avatar_url = b["avatar_url"]
html_url = b["html_url"]
gh_type = b["type"]
name = b["name"]
company = b["company"]
blog = b["blog"]
location = b["location"]
bio = b["bio"]
created_at = b["created_at"]
await borg.send_file(
event.chat_id,
caption="""Name: [{}]({})
Type: {}
Company: {}
Blog: {}
Location: {}
Bio: {}
Profile Created: {}""".format(name, html_url, gh_type, company, blog, location, bio, created_at),
file=avatar_url,
force_document=False,
allow_cache=False,
reply_to=event
)
await event.delete()
else:
await event.edit("`{}`: {}".format(input_str, r.text))