Skip to content

Commit

Permalink
fix(plugins/duplicatiplugin): message is too long
Browse files Browse the repository at this point in the history
Telegram.Bot.Exceptions.ApiRequestException: Bad Request: message is too long
  • Loading branch information
yiyungent committed Jan 19, 2024
1 parent a420e45 commit 89f399b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions plugins/DuplicatiPlugin/Controllers/SendController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ await botClient.SendTextMessageAsync(
string temp = $"Duplicati: {jsonModel.OperationName} \r\n"
+ $"{jsonModel.BackupName} \r\n"
+ $"{badge} {badgeStr}";

// fixed: Telegram.Bot.Exceptions.ApiRequestException: Bad Request: message is too long
temp += string.IsNullOrEmpty(extraInfo) ? string.Empty : $"\r\n{extraInfo}";
int telegramMaxMessageLength = 4096;
if (temp.Length > telegramMaxMessageLength)
{
temp = temp.Substring(0, telegramMaxMessageLength - 6) + "...";
}

// 发送
await botClient.SendTextMessageAsync(
Expand Down
4 changes: 2 additions & 2 deletions plugins/DuplicatiPlugin/DuplicatiPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>PluginCore.Plugins.DuplicatiPlugin</PackageId>
<Version>0.2.3</Version>
<FileVersion>0.2.3.0</FileVersion>
<Version>0.2.4</Version>
<FileVersion>0.2.4.0</FileVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Company>yiyun</Company>
<Authors>yiyun</Authors>
Expand Down
2 changes: 1 addition & 1 deletion plugins/DuplicatiPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
> 本项目基于 [TelegramBots/Telegram.Bot: .NET Client for Telegram Bot API](https://github.com/TelegramBots/Telegram.Bot)
<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.moeci.com/matomo.php?idsite=2&amp;rec=1&amp;action_name=PluginCore.Plugins..DuplicatiPlugin-v0.2.3.README" style="border:0" alt="" />
<img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.moeci.com/matomo.php?idsite=2&amp;rec=1&amp;action_name=PluginCore.Plugins..DuplicatiPlugin-v0.2.4.README" style="border:0" alt="" />
<!-- End Matomo -->
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.2.3",
"Version": "0.2.4",
"SupportedVersions": [ "0.0.1" ]
}

0 comments on commit 89f399b

Please sign in to comment.