Improve session

This commit is contained in:
Richard Chien
2018-06-25 16:50:34 +08:00
parent 77db6bfc84
commit 7da2043f94
6 changed files with 67 additions and 88 deletions

View File

@ -1,6 +1,4 @@
from typing import Dict, Any, Union, List
from aiocqhttp import CQHttp, Error as CQHttpError
from typing import Dict, Any
def context_source(ctx: Dict[str, Any]) -> str:
@ -12,13 +10,3 @@ def context_source(ctx: Dict[str, Any]) -> str:
if ctx.get('user_id'):
src += f'/user/{ctx["user_id"]}'
return src
async def send(bot: CQHttp, ctx: Dict[str, Any],
message: Union[str, Dict[str, Any], List[Dict[str, Any]]],
*, ignore_failure: bool = True) -> None:
try:
await bot.send(ctx, message)
except CQHttpError:
if not ignore_failure:
raise