Add permission

This commit is contained in:
Richard Chien
2018-06-15 15:00:58 +08:00
parent 19c211b253
commit 998d5b327b
5 changed files with 77 additions and 8 deletions

View File

@ -1,4 +1,6 @@
from typing import Dict, Any
from typing import Dict, Any, Union, List
from aiocqhttp import CQHttp, Error as CQHttpError
def context_source(ctx: Dict[str, Any]) -> str:
@ -10,3 +12,13 @@ def context_source(ctx: Dict[str, Any]) -> str:
if ctx.get('user_id'):
src += 'p%s' % 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