Skip to content

Commit

Permalink
✨ new filter
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Dec 9, 2024
1 parent c8e1e8a commit 5cf4f9c
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 207 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,34 @@

## 示例

使用命令行:
```shell
# 生成配置文件
$ entari new
```
```shell
# 运行
$ entari
```

使用配置文件:
```yaml
# config.yml
basic:
network:
- type: ws
host: "127.0.0.1"
port: 5140
path: satori
path: "satori"
ignore_self_message: true
log_level: INFO
plugin:
example_plugin: {}
::echo: {}
prefix: ["/"]
plugins:
~record_message: true
::auto_reload:
watch_dirs: ["plugins"]
watch_dirs: ["."]
::echo: true
::inspect: true
```
```python
Expand Down Expand Up @@ -60,8 +74,8 @@ app.run()
from arclet.entari import Session, Entari, WS, command

@command.on("add {a} {b}")
async def add(a: int, b: int, session: Session):
await session.send(f"{a + b = }")
def add(a: int, b: int):
return f"{a + b = }"


app = Entari(WS(port=5500, token="XXX"))
Expand Down
7 changes: 2 additions & 5 deletions arclet/entari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
from .core import Entari as Entari
from .event import MessageCreatedEvent as MessageCreatedEvent
from .event import MessageEvent as MessageEvent
from .filter import direct_message as direct_message
from .filter import notice_me as notice_me
from .filter import public_message as public_message
from .filter import reply_me as reply_me
from .filter import to_me as to_me
from .filter import Filter as Filter
from .message import MessageChain as MessageChain
from .plugin import Plugin as Plugin
from .plugin import PluginMetadata as PluginMetadata
Expand All @@ -63,5 +59,6 @@

WS = WebsocketsInfo
WH = WebhookInfo
filter_ = Filter

__version__ = "0.9.0"
10 changes: 9 additions & 1 deletion arclet/entari/event/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ReplyMeSupplier(SupplyAuxiliary):
async def __call__(self, scope: Scope, interface: Interface):
if self.id in interface.executed:
return
message: MessageChain = interface.ctx["$message_content"]
account = await interface.query(Account, "account", force_return=True)
reply = await interface.query(Reply, "reply", force_return=True)
if not account:
Expand All @@ -69,7 +70,14 @@ async def __call__(self, scope: Scope, interface: Interface):
is_reply_me = False
else:
is_reply_me = _is_reply_me(reply, account)
return interface.update(**{"is_reply_me": is_reply_me})
if is_reply_me and message and isinstance(message[0], Text):
message = message.copy()
text = message[0].text.lstrip()
if not text:
message.pop(0)
else:
message[0] = Text(text)
return interface.update(**{"$message_content": message, "is_reply_me": is_reply_me})

@property
def scopes(self) -> set[Scope]:
Expand Down
187 changes: 0 additions & 187 deletions arclet/entari/filter.py

This file was deleted.

Loading

0 comments on commit 5cf4f9c

Please sign in to comment.