Skip to content

Commit 12e066e

Browse files
committed
🔖 version 0.17.0
1 parent 28f80a9 commit 12e066e

File tree

5 files changed

+235
-10
lines changed

5 files changed

+235
-10
lines changed

arclet/entari/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@
9090
WS = WebsocketsInfo
9191
WH = WebhookInfo
9292

93-
__version__ = "0.17.0rc5"
93+
__version__ = "0.17.0"

arclet/entari/plugin/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ def load_plugins(dir_: str | PathLike | Path):
228228
for p in path.iterdir():
229229
if p.suffix in (".py", "") and p.stem not in {"__init__", "__pycache__"}:
230230
p = p.resolve().relative_to(prefix)
231-
plg = ".".join(p.parts[:-1:1]) + "." + p.stem
231+
if len(p.parts) > 1:
232+
plg = ".".join(p.parts[:-1:1]) + "." + p.stem
233+
else:
234+
plg = p.stem
232235
load_plugin(plg)
233236

234237

entari.schema.json

Lines changed: 223 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
"description": "WebSocket server endpoint path",
125125
"title": "Path"
126126
},
127+
"secure": {
128+
"type": "boolean",
129+
"default": false,
130+
"description": "Whether to use HTTPS and WSS for the server connection",
131+
"title": "Secure"
132+
},
127133
"token": {
128134
"type": "string",
129135
"description": "Authentication token for the WebSocket server",
@@ -171,6 +177,12 @@
171177
"description": "Webhook self-server endpoint path",
172178
"title": "Path"
173179
},
180+
"secure": {
181+
"type": "boolean",
182+
"default": false,
183+
"description": "Whether to use HTTPS for the server connection",
184+
"title": "Secure"
185+
},
174186
"token": {
175187
"type": "string",
176188
"description": "Authentication token for the webhook",
@@ -343,6 +355,22 @@
343355
"default": 50,
344356
"description": "轮询间隔,单位为毫秒,默认为 50 毫秒",
345357
"title": "Step"
358+
},
359+
"$disable": {
360+
"type": "string",
361+
"description": "Expression for whether disable this plugin"
362+
},
363+
"$prefix": {
364+
"type": "string",
365+
"description": "Plugin name prefix"
366+
},
367+
"$priority": {
368+
"type": "integer",
369+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
370+
},
371+
"$filter": {
372+
"type": "string",
373+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
346374
}
347375
},
348376
"additionalProperties": false,
@@ -351,7 +379,25 @@
351379
"::echo": {
352380
"type": "object",
353381
"description": "Echo the content; no configuration required",
354-
"additionalProperties": true
382+
"additionalProperties": true,
383+
"properties": {
384+
"$disable": {
385+
"type": "string",
386+
"description": "Expression for whether disable this plugin"
387+
},
388+
"$prefix": {
389+
"type": "string",
390+
"description": "Plugin name prefix"
391+
},
392+
"$priority": {
393+
"type": "integer",
394+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
395+
},
396+
"$filter": {
397+
"type": "string",
398+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
399+
}
400+
}
355401
},
356402
".record_message": {
357403
"type": "object",
@@ -368,6 +414,22 @@
368414
"default": false,
369415
"description": "是否记录发送的消息",
370416
"title": "Record Send"
417+
},
418+
"$disable": {
419+
"type": "string",
420+
"description": "Expression for whether disable this plugin"
421+
},
422+
"$prefix": {
423+
"type": "string",
424+
"description": "Plugin name prefix"
425+
},
426+
"$priority": {
427+
"type": "integer",
428+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
429+
},
430+
"$filter": {
431+
"type": "string",
432+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
371433
}
372434
},
373435
"additionalProperties": false,
@@ -376,7 +438,25 @@
376438
".scheduler": {
377439
"type": "object",
378440
"description": "Simple Scheduler with interval / crontab task; no configuration required",
379-
"additionalProperties": true
441+
"additionalProperties": true,
442+
"properties": {
443+
"$disable": {
444+
"type": "string",
445+
"description": "Expression for whether disable this plugin"
446+
},
447+
"$prefix": {
448+
"type": "string",
449+
"description": "Plugin name prefix"
450+
},
451+
"$priority": {
452+
"type": "integer",
453+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
454+
},
455+
"$filter": {
456+
"type": "string",
457+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
458+
}
459+
}
380460
},
381461
"example_reusable@1": {
382462
"type": "object",
@@ -389,6 +469,22 @@
389469
"output": {
390470
"type": "string",
391471
"title": "Output"
472+
},
473+
"$disable": {
474+
"type": "string",
475+
"description": "Expression for whether disable this plugin"
476+
},
477+
"$prefix": {
478+
"type": "string",
479+
"description": "Plugin name prefix"
480+
},
481+
"$priority": {
482+
"type": "integer",
483+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
484+
},
485+
"$filter": {
486+
"type": "string",
487+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
392488
}
393489
},
394490
"required": [
@@ -409,6 +505,22 @@
409505
"output": {
410506
"type": "string",
411507
"title": "Output"
508+
},
509+
"$disable": {
510+
"type": "string",
511+
"description": "Expression for whether disable this plugin"
512+
},
513+
"$prefix": {
514+
"type": "string",
515+
"description": "Plugin name prefix"
516+
},
517+
"$priority": {
518+
"type": "integer",
519+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
520+
},
521+
"$filter": {
522+
"type": "string",
523+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
412524
}
413525
},
414526
"required": [
@@ -421,12 +533,71 @@
421533
"example_plugin2": {
422534
"type": "object",
423535
"description": "D:\\Projects\\Entari\\example_plugins\\example_plugin2\\__init__.py; no configuration required",
424-
"additionalProperties": true
536+
"additionalProperties": true,
537+
"properties": {
538+
"$disable": {
539+
"type": "string",
540+
"description": "Expression for whether disable this plugin"
541+
},
542+
"$prefix": {
543+
"type": "string",
544+
"description": "Plugin name prefix"
545+
},
546+
"$priority": {
547+
"type": "integer",
548+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
549+
},
550+
"$filter": {
551+
"type": "string",
552+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
553+
}
554+
}
425555
},
426556
"example_plugin": {
427557
"type": "object",
428558
"description": "D:\\Projects\\Entari\\example_plugin.py; no configuration required",
429-
"additionalProperties": true
559+
"additionalProperties": true,
560+
"properties": {
561+
"$disable": {
562+
"type": "string",
563+
"description": "Expression for whether disable this plugin"
564+
},
565+
"$prefix": {
566+
"type": "string",
567+
"description": "Plugin name prefix"
568+
},
569+
"$priority": {
570+
"type": "integer",
571+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
572+
},
573+
"$filter": {
574+
"type": "string",
575+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
576+
}
577+
}
578+
},
579+
"example_plugin3": {
580+
"type": "object",
581+
"description": "No configuration required",
582+
"additionalProperties": true,
583+
"properties": {
584+
"$disable": {
585+
"type": "string",
586+
"description": "Expression for whether disable this plugin"
587+
},
588+
"$prefix": {
589+
"type": "string",
590+
"description": "Plugin name prefix"
591+
},
592+
"$priority": {
593+
"type": "integer",
594+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
595+
},
596+
"$filter": {
597+
"type": "string",
598+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
599+
}
600+
}
430601
},
431602
"example_plugin6": {
432603
"type": "object",
@@ -441,6 +612,22 @@
441612
"type": "string",
442613
"default": "example_plugin6",
443614
"title": "B"
615+
},
616+
"$disable": {
617+
"type": "string",
618+
"description": "Expression for whether disable this plugin"
619+
},
620+
"$prefix": {
621+
"type": "string",
622+
"description": "Plugin name prefix"
623+
},
624+
"$priority": {
625+
"type": "integer",
626+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
627+
},
628+
"$filter": {
629+
"type": "string",
630+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
444631
}
445632
},
446633
"additionalProperties": false,
@@ -473,6 +660,22 @@
473660
"default": true,
474661
"description": "是否使用配置前缀",
475662
"title": "Use Config Prefix"
663+
},
664+
"$disable": {
665+
"type": "string",
666+
"description": "Expression for whether disable this plugin"
667+
},
668+
"$prefix": {
669+
"type": "string",
670+
"description": "Plugin name prefix"
671+
},
672+
"$priority": {
673+
"type": "integer",
674+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
675+
},
676+
"$filter": {
677+
"type": "string",
678+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
476679
}
477680
},
478681
"additionalProperties": false,
@@ -498,6 +701,22 @@
498701
"type": "string",
499702
"description": "基础目录,默认为空,表示使用 `app_name` 作为目录名,",
500703
"title": "Base Dir"
704+
},
705+
"$disable": {
706+
"type": "string",
707+
"description": "Expression for whether disable this plugin"
708+
},
709+
"$prefix": {
710+
"type": "string",
711+
"description": "Plugin name prefix"
712+
},
713+
"$priority": {
714+
"type": "integer",
715+
"description": "Plugin loading priority, lower value means higher priority (default: 16)"
716+
},
717+
"$filter": {
718+
"type": "string",
719+
"description": "Plugin filter expression, which will be evaluated in the context of the plugin"
501720
}
502721
},
503722
"additionalProperties": false,

entari.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ plugins:
2727
example_reusable@2:
2828
input: foo
2929
output: bar!
30-
example_plugin2: {}
31-
?example_plugin3: {}
30+
example_plugin2:
31+
$filter: >
32+
(platform in ("onebot", "milky") and member.roles[0].id ne 'member')
33+
or
34+
platform eq "console"
35+
example_plugin3:
36+
$filter: message == "test_plugin3"
3237
?example_plugin4: {}
3338
?example_plugin5: {}
3439
example_plugin6: {}

example_plugins/example_plugin3.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from arclet.letoderea import enter_if, deref
21
from arclet.entari import (
32
Session,
43
MessageCreatedEvent,
@@ -10,7 +9,6 @@
109

1110
def __plugin_apply__(plug: Plugin):
1211
@plug.dispatch(MessageCreatedEvent)
13-
@enter_if & (deref(Session).content == "test_plugin")
1412
async def _(session: Session):
1513
await session.send(repr(plugin.get_plugin()))
1614

0 commit comments

Comments
 (0)