Skip to content
Snippets Groups Projects
Commit df31a7f1 authored by Iori Ichinose's avatar Iori Ichinose :speech_balloon:
Browse files

working on supports for pipelines

parent c164f2ce
No related branches found
No related tags found
No related merge requests found
import re
from nonebot.message import event_preprocessor, event_postprocessor
from nonebot.adapters.cqhttp import Bot, Event, MessageEvent, Message
from nonebot.typing import T_State
re_pipeline = re.compile(r'(.*)[|](.*)')
@event_preprocessor
async def cmd_grep(bot: Bot, event: Event, state: T_State):
if not isinstance(event, MessageEvent):
return
text = event.get_plaintext()
if m := re_pipeline.match(text):
msg, command = m.group(0).strip(), m.group(1).strip()
event.message = Message(msg)
event.raw_message = msg
state['_command'] = command
state['_send'] = msg
@event_postprocessor
async def sender(bot: Bot, event: Event, state: T_State):
if '_send' not in state:
return
send = state['_send']
if '_command' in state:
pass
await bot.send(event, send)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment