mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
Improve a little
This commit is contained in:
parent
4c07626124
commit
1835a4c33d
@ -188,7 +188,7 @@ class _FurtherInteractionNeeded(Exception):
|
|||||||
|
|
||||||
class CommandSession(BaseSession):
|
class CommandSession(BaseSession):
|
||||||
__slots__ = ('cmd', 'current_key', 'current_arg', 'current_arg_text',
|
__slots__ = ('cmd', 'current_key', 'current_arg', 'current_arg_text',
|
||||||
'images', 'args', 'last_interaction')
|
'current_arg_images', 'args', 'last_interaction')
|
||||||
|
|
||||||
def __init__(self, bot: CQHttp, ctx: Dict[str, Any], cmd: Command, *,
|
def __init__(self, bot: CQHttp, ctx: Dict[str, Any], cmd: Command, *,
|
||||||
current_arg: str = '', args: Optional[Dict[str, Any]] = None):
|
current_arg: str = '', args: Optional[Dict[str, Any]] = None):
|
||||||
@ -197,7 +197,7 @@ class CommandSession(BaseSession):
|
|||||||
self.current_key = None
|
self.current_key = None
|
||||||
self.current_arg = current_arg
|
self.current_arg = current_arg
|
||||||
self.current_arg_text = Message(current_arg).extract_plain_text()
|
self.current_arg_text = Message(current_arg).extract_plain_text()
|
||||||
self.images = [s.data['url'] for s in ctx['message']
|
self.current_arg_images = [s.data['url'] for s in ctx['message']
|
||||||
if s.type == 'image' and 'url' in s.data]
|
if s.type == 'image' and 'url' in s.data]
|
||||||
self.args = args or {}
|
self.args = args or {}
|
||||||
self.last_interaction = None
|
self.last_interaction = None
|
||||||
@ -212,7 +212,7 @@ class CommandSession(BaseSession):
|
|||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.current_arg = current_arg
|
self.current_arg = current_arg
|
||||||
self.current_arg_text = Message(current_arg).extract_plain_text()
|
self.current_arg_text = Message(current_arg).extract_plain_text()
|
||||||
self.images = [s.data['url'] for s in ctx['message']
|
self.current_arg_images = [s.data['url'] for s in ctx['message']
|
||||||
if s.type == 'image' and 'url' in s.data]
|
if s.type == 'image' and 'url' in s.data]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -6,9 +6,10 @@ from none.command import permissions as perm
|
|||||||
|
|
||||||
@on_command('echo', only_to_me=False)
|
@on_command('echo', only_to_me=False)
|
||||||
async def echo(session: CommandSession):
|
async def echo(session: CommandSession):
|
||||||
await session.send(session.current_arg)
|
await session.send(session.args.get('text') or session.current_arg)
|
||||||
|
|
||||||
|
|
||||||
@on_command('say', permission=perm.SUPERUSER, only_to_me=False)
|
@on_command('say', permission=perm.SUPERUSER, only_to_me=False)
|
||||||
async def _(session: CommandSession):
|
async def _(session: CommandSession):
|
||||||
await session.send(unescape(session.current_arg))
|
await session.send(
|
||||||
|
unescape(session.args.get('text') or session.current_arg))
|
||||||
|
Loading…
Reference in New Issue
Block a user