Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/github/user.py
2021-08-24 14:49:35 +08:00

45 lines
2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import traceback
from core.elements import MessageSession
from modules.github.utils import query, time_diff, dirty_check, darkCheck
async def user(msg: MessageSession):
try:
result = await query('https://api.github.com/users/' + msg.parsed_msg['<name>'], 'json')
optional = []
if 'hireable' in result and result['hireable'] is True:
optional.append('Hireable')
if 'is_staff' in result and result['is_staff'] is True:
optional.append('GitHub Staff')
if 'company' in result and result['company'] is not None:
optional.append('Work · ' + result['company'])
if 'twitter_username' in result and result['twitter_username'] is not None:
optional.append('Twitter · ' + result['twitter_username'])
if 'blog' in result and result['blog'] is not None:
optional.append('Site · ' + result['blog'])
if 'location' in result and result['location'] is not None:
optional.append('Location · ' + result['location'])
bio = result['bio']
if bio is None:
bio = ''
else:
bio = '\n' + result['bio']
optional_text = '\n' + ' | '.join(optional)
message = f'''{result['login']} aka {result['name']} ({result['id']}){bio}
Type · {result['type']} | Follower · {result['followers']} | Following · {result['following']} | Repo · {result['public_repos']} | Gist · {result['public_gists']}{optional_text}
Account Created {time_diff(result['created_at'])} ago | Latest activity {time_diff(result['updated_at'])} ago
{result['html_url']}'''
is_dirty = await dirty_check(message, result['login']) or darkCheck(message)
if is_dirty:
message = 'https://wdf.ink/6OUp'
await msg.sendMessage(message)
except Exception as error:
await msg.sendMessage('发生错误:' + str(error) + '\n错误汇报地址https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=')
traceback.print_exc()