From 1d0885ef2ed6c0fb852719d9ce4cf4e6c6c07bf7 Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Tue, 3 Jul 2018 10:47:07 +0800 Subject: [PATCH] Add repeater plugin --- none_demo/plugins/repeater.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 none_demo/plugins/repeater.py diff --git a/none_demo/plugins/repeater.py b/none_demo/plugins/repeater.py new file mode 100644 index 00000000..a34e8852 --- /dev/null +++ b/none_demo/plugins/repeater.py @@ -0,0 +1,21 @@ +from none import ( + on_natural_language, NLPSession, NLPResult +) + +_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 + _last_session = session + return result