2018-07-04 09:28:31 +08:00
|
|
|
from . import NoneBot
|
2018-06-27 22:05:12 +08:00
|
|
|
from .helpers import send, send_expr
|
2018-10-16 01:03:50 +08:00
|
|
|
from .typing import Context_T, Message_T, Expression_T
|
2018-06-27 22:05:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
class BaseSession:
|
|
|
|
__slots__ = ('bot', 'ctx')
|
|
|
|
|
2018-10-16 01:03:50 +08:00
|
|
|
def __init__(self, bot: NoneBot, ctx: Context_T):
|
2018-06-27 22:05:12 +08:00
|
|
|
self.bot = bot
|
|
|
|
self.ctx = ctx
|
|
|
|
|
2018-10-16 01:03:50 +08:00
|
|
|
async def send(self, message: Message_T, *,
|
|
|
|
ignore_failure: bool = True) -> None:
|
2018-07-04 19:50:42 +08:00
|
|
|
"""Send a message ignoring failure by default."""
|
2018-06-27 22:05:12 +08:00
|
|
|
return await send(self.bot, self.ctx, message,
|
|
|
|
ignore_failure=ignore_failure)
|
|
|
|
|
2018-10-16 01:03:50 +08:00
|
|
|
async def send_expr(self, expr: Expression_T, **kwargs):
|
2018-07-04 19:50:42 +08:00
|
|
|
"""Sending a expression message ignoring failure by default."""
|
2018-06-27 22:05:12 +08:00
|
|
|
return await send_expr(self.bot, self.ctx, expr, **kwargs)
|