mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-18 09:25:46 +08:00
31 lines
929 B
Python
31 lines
929 B
Python
from typing import Union, Callable, Dict, Any, List, Sequence
|
|
|
|
from aiocqhttp import CQHttp
|
|
|
|
from .helpers import send, send_expr
|
|
|
|
|
|
class BaseSession:
|
|
__slots__ = ('bot', 'ctx')
|
|
|
|
def __init__(self, bot: CQHttp, ctx: Dict[str, Any]):
|
|
self.bot = bot
|
|
self.ctx = ctx
|
|
|
|
async def send(self,
|
|
message: Union[str, Dict[str, Any], List[Dict[str, Any]]],
|
|
*, ignore_failure: bool = True) -> None:
|
|
"""
|
|
Send a message ignoring failure by default.
|
|
"""
|
|
return await send(self.bot, self.ctx, message,
|
|
ignore_failure=ignore_failure)
|
|
|
|
async def send_expr(self,
|
|
expr: Union[str, Sequence[str], Callable],
|
|
**kwargs):
|
|
"""
|
|
Sending a expression message ignoring failure by default.
|
|
"""
|
|
return await send_expr(self.bot, self.ctx, expr, **kwargs)
|