Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Mar 7, 2023
1 parent 06d6c14 commit d7a7571
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@
- Feature #473 : let user input when there is no target task in configs
## 1.0.2
- Fix #484 : fix read dic config error
- Merge PR #472 : add reverse proxy host for telegram notification
- Merge PR #483 : update login field for entrypoint
3 changes: 2 additions & 1 deletion src/Ray.BiliBiliTool.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ internal static IHostBuilder CreateHostBuilder(string[] args)
//用户机密:
if (env.IsDevelopment() && env.ApplicationName?.Length > 0)
{
var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName));
//var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName));
var appAssembly = Assembly.GetAssembly(typeof(Program));
configurationBuilder.AddUserSecrets(appAssembly, optional: true, reloadOnChange: true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ray.BiliBiliTool.Console/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"chatId": "",
"restrictedToMinimumLevel": "Information",
"proxy": "", //代理,user:password@host:port
"apiHost": ""
"apiHost": "https://api.telegram.org" //可以替换成自己搭建的反代host(https://hostloc.com/thread-805441-1-1.html)
}
},
//4.企业微信机器人(https://work.weixin.qq.com/api/doc/90000/90136/91770)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TelegramApiClient : PushService

private readonly string _chatId;
private readonly string _proxy;
private const string TelegramBotApiUrl = "https://api.telegram.org/bot";
private const string DefaultTelegramBotApiHost = "https://api.telegram.org";

/// <summary>
/// The API URL.
Expand Down Expand Up @@ -42,12 +42,9 @@ public TelegramApiClient(string botToken, string chatId, string proxy = "", stri

_chatId = chatId;
_proxy = proxy;
var botApiUrl = TelegramBotApiUrl;
if (!string.IsNullOrWhiteSpace(apiHost))
{
botApiUrl = apiHost;
}
this._apiUrl = new Uri($"{botApiUrl}{botToken}/sendMessage");

var botApiHost = string.IsNullOrWhiteSpace(apiHost)? DefaultTelegramBotApiHost:apiHost;
this._apiUrl = new Uri($"{botApiHost}/bot{botToken}/sendMessage");

if (proxy.IsNotNullOrEmpty())
{
Expand Down
4 changes: 2 additions & 2 deletions test/LogTest/TestTelegram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class TestTelegram

public TestTelegram()
{
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
Program.CreateHost(new string[] { });
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Development");
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });

_botToken = Global.ConfigurationRoot["Serilog:WriteTo:3:Args:botToken"];
_chatId = Global.ConfigurationRoot["Serilog:WriteTo:3:Args:chatId"];
Expand Down

0 comments on commit d7a7571

Please sign in to comment.