nonebot2/none_demo/plugins/repeater.py

21 lines
578 B
Python
Raw Normal View History

2018-07-04 16:21:01 +08:00
from none import on_natural_language, NLPSession, NLPResult
2018-07-03 10:47:07 +08:00
_last_session = None
@on_natural_language(only_to_me=False)
async def _(session: NLPSession):
if session.ctx.get('group_id') != 672076603:
return None
global _last_session
result = None
if _last_session and \
_last_session.ctx['user_id'] != session.ctx['user_id'] and \
_last_session.msg == session.msg:
result = NLPResult(61.0, 'echo', {'message': _last_session.msg})
_last_session = None
2018-07-06 19:07:02 +08:00
else:
_last_session = session
2018-07-03 10:47:07 +08:00
return result