Skip to content

Commit

Permalink
feat(plugins/duplicatiplugin/): duplicati通知新方式
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Jan 26, 2023
1 parent 2d9aae9 commit cbe136f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
13 changes: 10 additions & 3 deletions plugins/DuplicatiPlugin/Controllers/SendController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class SendController : ControllerBase
public async Task<ActionResult> Apply([FromRoute] string key, [FromForm] string message)
{
SettingsModel settings = PluginCore.PluginSettingsModelFactory.Create<SettingsModel>(nameof(DuplicatiPlugin));

#region 数据预处理
// 切割 message
string splitLineStr = "<--DuplicatiPlugin-->";
int splitLineFirstIndex = message.IndexOf(splitLineStr);
Expand Down Expand Up @@ -51,10 +53,11 @@ await botClient.SendTextMessageAsync(

// 解析 message
DuplicatiMessageModel jsonModel = JsonSerializer.Deserialize<DuplicatiMessageModel>(jsonStr);
// TODO: 解析 duplicatiStr

// TODO: 解析 duplicatiStr
#endregion

// 使用设置里的 Telegram
#region Telegram 通知
try
{
#region Telegram
Expand Down Expand Up @@ -86,8 +89,12 @@ await botClient.SendTextMessageAsync(
Utils.LogUtil.Exception(ex);

return Ok("fail");
}
}
#endregion

#region 保存数据库, key 做来源区分

#endregion

return Ok("Ok");
}
Expand Down
18 changes: 17 additions & 1 deletion plugins/DuplicatiPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
> 3. `@userinfobot` 通过此机器人获取你的 `Id` , 即为 `ChatId`

### 2. 全局设置 Duplicati
### 2. 方式1: 全局设置 Duplicati

- [右键复制本链接, 然后再替换其中内容](/api/Duplicati/TgBotToken/replace-your-botToken/to/TgChatId/replace-your-chatId/apply)

Expand All @@ -29,9 +29,25 @@
> Duplicati - 设置 - 默认选项 - 以文本形式编辑
```
--send-http-result-output-format=Duplicati
--send-http-url=替换为你的链接
```

### 2. 方式2: 全局设置 Duplicati

- [右键复制本链接, 然后再替换其中内容](/api/Duplicati/replace-your-key/apply)

```
/api/Duplicati/替换为你的来源key,用作区分/apply
```

> Duplicati - 设置 - 默认选项 - 以文本形式编辑
```
--send-http-result-output-format=Duplicati
--send-http-message={"Name":"Duplicati","OperationName":"%OPERATIONNAME%","BackupName":"%backup-name%","ParsedResult":"%PARSEDRESULT%","LocalPath":"%LOCALPATH%","RemoteUrl":"%REMOTEURL%"}<--DuplicatiPlugin-->%RESULT%
--send-http-url=替换为你的链接
```



Expand Down
2 changes: 1 addition & 1 deletion plugins/DuplicatiPlugin/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"DisplayName": "Duplicati插件",
"Description": "Duplicati插件",
"Author": "yiyun",
"Version": "0.1.0",
"Version": "0.2.0",
"SupportedVersions": [ "0.0.1" ]
}
5 changes: 4 additions & 1 deletion plugins/DuplicatiPlugin/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"UseDebugModel": false,
"Telegram": {
"Enable": true
"Enable": false,
"BotToken": "",
"ChatId": ""
}
}

0 comments on commit cbe136f

Please sign in to comment.