Improve a little

This commit is contained in:
Richard Chien 2018-06-30 21:00:41 +08:00
parent 4c07626124
commit 1835a4c33d
2 changed files with 8 additions and 7 deletions

View File

@ -188,7 +188,7 @@ class _FurtherInteractionNeeded(Exception):
class CommandSession(BaseSession):
__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, *,
current_arg: str = '', args: Optional[Dict[str, Any]] = None):
@ -197,7 +197,7 @@ class CommandSession(BaseSession):
self.current_key = None
self.current_arg = current_arg
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]
self.args = args or {}
self.last_interaction = None
@ -212,7 +212,7 @@ class CommandSession(BaseSession):
self.ctx = ctx
self.current_arg = current_arg
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]
@property

View File

@ -6,9 +6,10 @@ from none.command import permissions as perm
@on_command('echo', only_to_me=False)
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)
async def _(session: CommandSession):
await session.send(unescape(session.current_arg))
await session.send(
unescape(session.args.get('text') or session.current_arg))