mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-21 18:15:50 +08:00
Add return value to Session.send()
This commit is contained in:
parent
a86199d5f3
commit
245c0db3c7
@ -1,6 +1,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import random
|
import random
|
||||||
from typing import Sequence, Callable
|
from typing import Sequence, Callable, Any
|
||||||
|
|
||||||
from . import NoneBot
|
from . import NoneBot
|
||||||
from .exceptions import CQHttpError
|
from .exceptions import CQHttpError
|
||||||
@ -48,16 +48,17 @@ async def send(bot: NoneBot, ctx: Context_T,
|
|||||||
message: Message_T, *,
|
message: Message_T, *,
|
||||||
ensure_private: bool = False,
|
ensure_private: bool = False,
|
||||||
ignore_failure: bool = True,
|
ignore_failure: bool = True,
|
||||||
**kwargs) -> None:
|
**kwargs) -> Any:
|
||||||
"""Send a message ignoring failure by default."""
|
"""Send a message ignoring failure by default."""
|
||||||
try:
|
try:
|
||||||
if ensure_private:
|
if ensure_private:
|
||||||
ctx = ctx.copy()
|
ctx = ctx.copy()
|
||||||
ctx['message_type'] = 'private'
|
ctx['message_type'] = 'private'
|
||||||
await bot.send(ctx, message, **kwargs)
|
return await bot.send(ctx, message, **kwargs)
|
||||||
except CQHttpError:
|
except CQHttpError:
|
||||||
if not ignore_failure:
|
if not ignore_failure:
|
||||||
raise
|
raise
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def render_expression(expr: Expression_T, *,
|
def render_expression(expr: Expression_T, *,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user