|
14 | 14 |
|
15 | 15 | class PluginProtocol(Protocol):
|
16 | 16 | """The protocol that plugin executor trully need a plugin to implement.
|
17 |
| - |
| 17 | +
|
18 | 18 | You should implement `BasePlugin` instead of this protocol.
|
19 | 19 | Unless you know what you are doing."""
|
| 20 | + |
20 | 21 | def positive_tag(self) -> str: ...
|
21 | 22 | def negative_tag(self) -> str: ...
|
22 |
| - async def task(self, payload: v1.WebhookRequestPayload, memos_cli: MemosCli) -> v1.Memo: ... |
| 23 | + async def task( |
| 24 | + self, payload: v1.WebhookRequestPayload, memos_cli: MemosCli |
| 25 | + ) -> v1.Memo: ... |
23 | 26 | def should_trigger(self, payload: v1.WebhookRequestPayload) -> bool: ...
|
24 | 27 |
|
25 | 28 |
|
@@ -60,7 +63,9 @@ def tag(self) -> str:
|
60 | 63 | ...
|
61 | 64 |
|
62 | 65 | @abstractmethod
|
63 |
| - async def task(self, payload: v1.WebhookRequestPayload, memos_cli: MemosCli) -> v1.Memo: |
| 66 | + async def task( |
| 67 | + self, payload: v1.WebhookRequestPayload, memos_cli: MemosCli |
| 68 | + ) -> v1.Memo: |
64 | 69 | """The webhook task function.
|
65 | 70 |
|
66 | 71 | Return the modified memo, and the plugin will auto update the memo with modified content and negative tag.
|
@@ -138,9 +143,7 @@ async def update_memo_content(
|
138 | 143 | Once the task triggered, will replace the `#tag` with `#tag/done`.
|
139 | 144 | If the `#tag` not exists, will add the `#tag/done` to first line.
|
140 | 145 | """
|
141 |
| - self.logger.debug( |
142 |
| - f"Background task started with param: {payload.to_json()}" |
143 |
| - ) |
| 146 | + self.logger.debug(f"Background task started with param: {payload.to_json()}") |
144 | 147 |
|
145 | 148 | res_memo = await plugin.task(payload, self.memos_cli)
|
146 | 149 | self.logger.info("Background task success completed")
|
@@ -169,5 +172,6 @@ async def execute(self, payload: v1.WebhookRequestPayload) -> None:
|
169 | 172 | continue
|
170 | 173 |
|
171 | 174 | await self.update_memo_content(plugin, payload)
|
| 175 | + return # only execute one plugin |
172 | 176 |
|
173 | 177 | self.logger.info("All plugins executed")
|
0 commit comments