Files
BiliBiliToolPro/test/LogTest/TestTelegram.cs
database-mysql e519cac94e
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
pull file
2026-02-11 23:32:56 +08:00

41 lines
1.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Ray.BiliBiliTool.Console;
using Ray.BiliBiliTool.Infrastructure;
using Ray.Serilog.Sinks.TelegramBatched;
using Xunit;
namespace LogTest
{
public class TestTelegram
{
private string _botToken;
private string _chatId;
public TestTelegram()
{
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
Program.CreateHost(["ENVIRONMENT=Development"]);
_botToken = Global.ConfigurationRoot?["Serilog:WriteTo:3:Args:botToken"];
_chatId = Global.ConfigurationRoot?["Serilog:WriteTo:3:Args:chatId"];
}
[Fact]
public async Task Test2()
{
var client = new TelegramApiClient(_botToken, _chatId);
string msg = LogConstants.Msg2;
var result = await client.PushMessageAsync(msg, "标题");
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
/*
* 如果指定markdown星号会导致推送失败
*/
}
}
}