mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 00:55:07 +08:00
Add repeater plugin
This commit is contained in:
parent
d4a19303b8
commit
1d0885ef2e
21
none_demo/plugins/repeater.py
Normal file
21
none_demo/plugins/repeater.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user