2021-07-30 08:06:10 +00:00
|
|
|
import traceback
|
|
|
|
|
2022-06-28 06:11:03 +00:00
|
|
|
from core.builtins.message import MessageSession
|
2022-07-03 06:05:40 +00:00
|
|
|
from core.elements import Url, ErrorMessage
|
2022-06-12 07:07:53 +00:00
|
|
|
from core.utils import get_url
|
2021-11-20 01:35:38 +00:00
|
|
|
from modules.github.utils import time_diff, dirty_check, darkCheck
|
2021-07-30 08:06:10 +00:00
|
|
|
|
2021-08-07 07:56:48 +00:00
|
|
|
|
2021-07-30 08:06:10 +00:00
|
|
|
async def user(msg: MessageSession):
|
|
|
|
try:
|
2022-08-10 13:22:44 +00:00
|
|
|
result = await get_url('https://api.github.com/users/' + msg.parsed_msg['<name>'], 200, fmt='json')
|
2022-08-18 15:24:46 +00:00
|
|
|
if 'message' in result and result['message'] == 'Not Found':
|
|
|
|
await msg.finish('查无此人,请检查输入。')
|
|
|
|
elif 'message' in result and result['message']:
|
|
|
|
await msg.finish(result['message'])
|
2021-07-30 08:06:10 +00:00
|
|
|
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')
|
2021-08-01 14:26:55 +00:00
|
|
|
if 'company' in result and result['company'] is not None:
|
2021-07-30 08:06:10 +00:00
|
|
|
optional.append('Work · ' + result['company'])
|
2021-08-01 14:26:55 +00:00
|
|
|
if 'twitter_username' in result and result['twitter_username'] is not None:
|
2021-07-30 08:06:10 +00:00
|
|
|
optional.append('Twitter · ' + result['twitter_username'])
|
2021-08-01 14:26:55 +00:00
|
|
|
if 'blog' in result and result['blog'] is not None:
|
2021-07-30 08:06:10 +00:00
|
|
|
optional.append('Site · ' + result['blog'])
|
2021-08-01 14:26:55 +00:00
|
|
|
if 'location' in result and result['location'] is not None:
|
2021-07-30 08:06:10 +00:00
|
|
|
optional.append('Location · ' + result['location'])
|
|
|
|
|
|
|
|
bio = result['bio']
|
|
|
|
if bio is None:
|
|
|
|
bio = ''
|
|
|
|
else:
|
|
|
|
bio = '\n' + result['bio']
|
|
|
|
|
|
|
|
optional_text = '\n' + ' | '.join(optional)
|
2021-08-01 14:26:55 +00:00
|
|
|
message = f'''{result['login']} aka {result['name']} ({result['id']}){bio}
|
2021-12-18 05:42:34 +00:00
|
|
|
|
2021-07-30 08:06:10 +00:00
|
|
|
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
|
2021-12-18 05:42:34 +00:00
|
|
|
|
2022-01-17 13:28:49 +00:00
|
|
|
{str(Url(result['html_url']))}'''
|
2021-07-30 08:06:10 +00:00
|
|
|
|
2021-08-01 14:26:55 +00:00
|
|
|
is_dirty = await dirty_check(message, result['login']) or darkCheck(message)
|
2021-07-30 08:06:10 +00:00
|
|
|
if is_dirty:
|
2021-08-01 14:26:55 +00:00
|
|
|
message = 'https://wdf.ink/6OUp'
|
2021-07-30 08:06:10 +00:00
|
|
|
|
2022-05-21 16:04:29 +00:00
|
|
|
await msg.finish(message)
|
2022-08-10 13:22:44 +00:00
|
|
|
except ValueError:
|
|
|
|
await msg.finish('发生错误:找不到仓库,请检查拼写是否正确。')
|
2021-07-30 08:06:10 +00:00
|
|
|
except Exception as error:
|
2022-08-10 13:22:44 +00:00
|
|
|
await msg.sendMessage(ErrorMessage(str(error)))
|
|
|
|
traceback.print_exc()
|