nonebot2/none/helpers.py

13 lines
325 B
Python
Raw Normal View History

2018-06-25 16:50:34 +08:00
from typing import Dict, Any
2018-06-15 06:58:24 +08:00
def context_source(ctx: Dict[str, Any]) -> str:
src = ''
if ctx.get('group_id'):
2018-06-25 15:22:59 +08:00
src += f'/group/{ctx["group_id"]}'
2018-06-15 06:58:24 +08:00
elif ctx.get('discuss_id'):
2018-06-25 15:22:59 +08:00
src += f'/discuss/{ctx["discuss_id"]}'
2018-06-15 06:58:24 +08:00
if ctx.get('user_id'):
2018-06-25 15:22:59 +08:00
src += f'/user/{ctx["user_id"]}'
2018-06-15 06:58:24 +08:00
return src