diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd7c0e6f3..004126a1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -107,3 +107,7 @@
- Feature #460 : publish single file when release
- Feature: use new scripts for gh actions's release
- 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
diff --git a/common.props b/common.props
index 7db168f46..5512e5aa8 100644
--- a/common.props
+++ b/common.props
@@ -1,7 +1,7 @@
Ray
- 1.0.1
+ 1.0.2
$(NoWarn);CS1591;CS0436
diff --git a/helm/README.md b/helm/README.md
index 18718c956..8c617d0f8 100644
--- a/helm/README.md
+++ b/helm/README.md
@@ -1,48 +1,38 @@
-# BiliBili Tool
+# BiliBili Tool
BiliBiliTool 是一个自动执行任务的工具,当我们忘记做某项任务时,它会像一个贴心小助手,按照我们预先吩咐它的命令,在指定频率、时间范围内帮助我们完成计划的任务。
[Overview of BiliBili Tool](https://github.com/RayWangQvQ/BiliBiliToolPro)
-
+
## TL;DR
-### 在集群中通过本地代码直接部署
+### 在集群中通过chart部署
```console
$ git clone https://github.com/RayWangQvQ/BiliBiliToolPro.git
$ cd ${local_code_repo}/helm/bilibili-tool
-$ vim values.yaml # provides your cookie and cron
+[optional]$ vim values.yaml # provides your own settings like cookies
$ helm install .
```
-### 在集群中通过chart部署
+如果没有在values.yaml中提供cookie,那么需要手动扫描日志中的二维码进行登录
```console
-$ git clone https://github.com/RayWangQvQ/BiliBiliToolPro.git
-$ cd ${local_code_repo}/helm/bilibili-tool
-$ helm cm-push .
-```
-Then on the cluster control plane
-```console
-$ mkdir /tmp/bilibili-tool && cd /tmp/bilibili-tool
-$ helm repo add
-$ helm update && helm pull /bilibili-tool
-$ tar -zvxf -C . && cd
-$ vim values.yaml # provides your cookie and cron
-$ helm install .
+$kubectl logs -f
```
+如果在values.yaml中提供了cookie,那么可以不扫描也可以扫描进行登录,上面的步骤可以暂时不执行
+
## Introduction
这个chart通过[Helm](https://helm.sh)在[Kubernetes](https://kubernetes.io)集群上拉起一个[BiliBiliToolPro](https://github.com/RayWangQvQ/BiliBiliToolPro)deployment
-
## Prerequisites
- Kubernetes
-- Helm
+- Helm
或者
@@ -54,8 +44,8 @@ $ helm install .
安装Chart并命名为 `my-release`:
```console
-$ helm repo add my-repo
-$ helm install my-release my-repo/bilibili-tool(:0.2.1)
+$helm repo add my-repo
+$helm install my-release my-repo/bilibili-tool(:1.0.1)
```
上述命令需要用户在values.yaml里提供cookie等必须信息
@@ -68,7 +58,7 @@ $ helm install my-release my-repo/bilibili-tool(:0.2.1)
卸载 `my-release` deployment:
```console
-$ helm delete my-release
+$helm delete my-release
```
上述命令卸载掉所有的release相关资源
@@ -78,25 +68,29 @@ $ helm delete my-release
| Name | Description | Value | Required |
| ------------------------- | ----------------------------------------------- | ----- | -------- |
| `replicaCount` | Deployment Relicas Count | `1` | true |
+| `namespace` | Deployment and ConfigMap deployed namespace | `default` | true |
+| `configmap.name` | ConfigMap name contains the entry files | `entry` | true |
| `image.repository` | Global Dockevr registry | `zai7lou/bilibili_tool_pro` | true |
-| `image.tag` | Image Tag | `0.2.1` | true |
+| `image.tag` | Image Tag | `1.0.1` | true |
| `image.pullPolicy` | Image Pull Policy | `IfNotPresent` | true |
| `imagePullSecrets` | Image Pull Secrets | `[]` | false |
| `nameOverride` | Deployment name in the Chart | `""` | false |
| `fullnameOverride` | Release name when set | `""` | false |
| `resources.limits` | The resources limits for the BiliBili Tool containers | `{}` | true |
| `resources.limits.memory` | The limited memory for the BiliBili Tool containers | `180Mi` | true |
-| `resources.limits.cpu` | The limited cpu for the BiliBili Tool containers | `100m` | true |
+| `resources.limits.cpu` | The limited cpu for the BiliBili Tool containers | `100m` | true |
| `resources.requests` | The resources requests for the BiliBili Tool containers | `{}` | true |
| `resources.requests.memory` | The requested memory for the BiliBili Tool containers | `180Mi` | true |
-| `resources.requests.cpu` | The requested cpu for the BiliBili Tool containers | `100m` | true |
+| `resources.requests.cpu` | The requested cpu for the BiliBili Tool containers | `100m` | true |
| `affinity` | Affinity for pod assignment | `{}` | false |
| `nodeSelector` | Node labels for pod assignment | `{}` | false |
| `tolerations` | Tolerations for pod assignment | `[]` | false |
| `env` | Environment variables for the BiliBili Tool container, Ray_BiliBiliCookies__1 and Ray_DailyTaskConfig__Cron are required, others vars pls take a look at [supported envvars](https://github.com/RayWangQvQ/BiliBiliToolPro/blob/main/docs/configuration.md) | `[]` | true |
-| `volumes.enabled` | Enable persistent log volume for BiliBili Tool or not | `"false"` | true |
-| `volumes.path` | The host path mounted into pod | `"/tmp/Logs"` | false |
-| `volumes.name` | The volume name | `"bili-tool-vol"` | false |
+| `volumes.log.enabled` | Enable persistent log volume for BiliBili Tool or not | `"false"` | true |
+| `volumes.log.path` | The host path mounted into pod | `"/tmp/Logs"` | false |
+| `volumes.log.name` | The volume name | `"bili-tool-vol"` | false |
+| `volumes.login.enabled` | Enable persistent log volume contains the entries for BiliBili Tool or not | `"false"` | true |
+| `volumes.login.name` | The volume name | `"entry"` | false |
| `podAnnotations` | The annotations for the BiliBili Tool pod | `{}` | false |
可以用指定helm install命令行参数 `--set key=value[,key=value]`, 比如
@@ -110,24 +104,25 @@ $ helm install my-release \
也可以通过指定一个YAML格式的values文件来配置以上参数,比如
```console
-$ helm install my-release -f values.yaml my_chart_repo/bilibili-tool
+$helm install my-release -f values.yaml my_chart_repo/bilibili-tool
```
> **Tip**: 你可以使用默认的 [values.yaml](bilibili-tool/values.yaml)进行配置
-
当想更新一些变量时,可以通过指定参数或者直接修改YAML的values文件进行更新
```console
-$ helm upgrade my-release my_chart_repo/bilibili-tool <-f values> or <--set-file ...>
+$helm upgrade my-release my_chart_repo/bilibili-tool <-f values> or <--set-file ...>
```
+## Upgrade
+
+建议重新装release
+
## [Optional]本地Cluster运行
通过安装[kind](https://kind.sigs.k8s.io/docs/user/quick-start/)工具在本地运行一个Kubernetes Cluster
-### Prerequisites
-
go 1.17+ and Docker installed
```console
@@ -140,4 +135,5 @@ nodes:
- role: worker
$ EOF
```
+
at least one worker node otherwise you have to provides tolerations in the values.yaml to schedule on master node
diff --git a/helm/bilibili-tool/Chart.yaml b/helm/bilibili-tool/Chart.yaml
index 4c2e181b0..86102872d 100644
--- a/helm/bilibili-tool/Chart.yaml
+++ b/helm/bilibili-tool/Chart.yaml
@@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
-version: 0.1.0
+version: 1.0.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
-appVersion: "0.2.1"
+appVersion: "1.0.1"
diff --git a/helm/bilibili-tool/templates/configmap.yaml b/helm/bilibili-tool/templates/configmap.yaml
new file mode 100644
index 000000000..f909e7bbd
--- /dev/null
+++ b/helm/bilibili-tool/templates/configmap.yaml
@@ -0,0 +1,83 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ .Values.configmap.name }}
+ namespace: {{ .Values.namespace }}
+data:
+ entry_before.sh: |
+ #!/bin/bash
+ set -e
+ echo -e "entry_before\n"
+ entry_after.sh: |
+ #!/bin/bash
+ set -e
+ echo -e "entry_after\n"
+ entry.sh: |
+ #!/bin/bash
+ set -e
+
+ . /app/scripts/entry_before.sh
+
+ CONSOLE_DLL="Ray.BiliBiliTool.Console.dll"
+ CRON_FILE="/etc/cron.d/bilicron"
+
+ # https://stackoverflow.com/questions/27771781/how-can-i-access-docker-set-environment-variables-from-a-cron-job
+ echo "[step 1/5]导入环境变量"
+ printenv | grep -v "no_proxy" >/etc/environment
+ declare -p | grep -v "no_proxy" >/etc/cron.env
+ echo -e "=>完成\n"
+
+ echo "[step 2/5]配置cron定时任务"
+ echo "SHELL=/bin/bash" >$CRON_FILE
+ echo "BASH_ENV=/etc/cron.env" >>$CRON_FILE
+ if [ -z "$Ray_DailyTaskConfig__Cron$Ray_LiveLotteryTaskConfig__Cron$Ray_UnfollowBatchedTaskConfig__Cron$Ray_VipBigPointConfig__Cron$Ray_LiveFansMedalTaskConfig__Cron" ]; then
+ echo "=>使用默认的定时任务配置"
+ cat /app/scripts/crontab >>$CRON_FILE
+ else
+ echo "=>使用用户指定的定时任务配置"
+ if ! [ -z "$Ray_DailyTaskConfig__Cron" ]; then
+ echo "$Ray_DailyTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=Daily" >>$CRON_FILE
+ fi
+ if ! [ -z "$Ray_LiveLotteryTaskConfig__Cron" ]; then
+ echo "$Ray_LiveLotteryTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=LiveLottery" >>$CRON_FILE
+ fi
+ if ! [ -z "$Ray_UnfollowBatchedTaskConfig__Cron" ]; then
+ echo "$Ray_UnfollowBatchedTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=UnfollowBatched" >>$CRON_FILE
+ fi
+ if ! [ -z "$Ray_VipBigPointConfig__Cron" ]; then
+ echo "$Ray_VipBigPointConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=VipBigPoint" >>$CRON_FILE
+ fi
+ if ! [ -z "$Ray_LiveFansMedalTaskConfig__Cron" ]; then
+ echo "$Ray_LiveFansMedalTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=LiveFansMedal" >>$CRON_FILE
+ fi
+ fi
+
+ if ! [ -z "$Ray_Crontab" ]; then
+ echo "=>检测到自定义定时任务"
+ echo "$Ray_Crontab" >>$CRON_FILE
+ fi
+
+ cat $CRON_FILE
+ chmod 0644 $CRON_FILE
+ crontab $CRON_FILE # 指定定时列表文件
+
+ echo -e "=>完成\n"
+
+ echo "[step 3/5]启动定时任务,开启每日定时运行"
+ cron
+ echo -e "=>完成\n"
+
+ echo "[step 4/5]初始运行,进行Login"
+ cd /app && dotnet Ray.BiliBiliTool.Console.dll --runTasks=Login
+ echo -e "=>完成Login\n"
+
+ echo "[step 5/5]初始运行,尝试测试Cookie"
+ dotnet Ray.BiliBiliTool.Console.dll --runTasks=Test
+ echo -e "=>完成\n"
+
+ echo -e "[step 全部已完成]\n"
+
+ . /app/scripts/entry_after.sh
+
+ touch /var/log/cron.log #todo:debian似乎并没有记录cron的日志。。。
+ tail -f /var/log/cron.log # 追踪cron日志,避免当前脚本终止导致容器终止
diff --git a/helm/bilibili-tool/templates/deployment.yaml b/helm/bilibili-tool/templates/deployment.yaml
index 10a63b687..19e999777 100644
--- a/helm/bilibili-tool/templates/deployment.yaml
+++ b/helm/bilibili-tool/templates/deployment.yaml
@@ -2,6 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "bilibili_tool.fullname" . }}
+ namespace: {{ .Values.namespace }}
labels:
{{- include "bilibili_tool.labels" . | nindent 4 }}
spec:
@@ -17,11 +18,28 @@ spec:
labels:
{{- include "bilibili_tool.selectorLabels" . | nindent 8 }}
spec:
- {{- if .Values.volumes.enabled }}
+ {{- if or (eq .Values.volumes.log.enabled true) (eq .Values.volumes.login.enabled true) }}
volumes:
- - name: {{ .Values.volumes.name }}
+ {{- if .Values.volumes.log.enabled }}
+ - name: {{ .Values.volumes.log.name }}
hostPath:
- path: {{ .Values.volumes.path }}
+ path: {{ .Values.volumes.log.path }}
+ {{- end }}
+ {{- if .Values.volumes.login.enabled }}
+ - name: {{ .Values.volumes.login.name }}
+ configMap:
+ name: {{ .Values.configmap.name }}
+ items:
+ - key: "entry.sh"
+ path: "entry.sh"
+ mode: 0755
+ - key: "entry_before.sh"
+ path: "entry_before.sh"
+ mode: 0755
+ - key: "entry_after.sh"
+ path: "entry_after.sh"
+ mode: 0755
+ {{- end }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
@@ -33,10 +51,16 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- toYaml .Values.env | nindent 12 }}
- {{- if .Values.volumes.enabled }}
+ {{- if or (eq .Values.volumes.log.enabled true) (eq .Values.volumes.login.enabled true) }}
volumeMounts:
+ {{- if .Values.volumes.log.enabled }}
- mountPath: "/bilibili_tool/Logs"
- name: {{ .Values.volumes.name }}
+ name: {{ .Values.volumes.log.name }}
+ {{- end }}
+ {{- if .Values.volumes.login.enabled }}
+ - mountPath: "/app/scripts"
+ name: {{ .Values.volumes.login.name }}
+ {{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
diff --git a/helm/bilibili-tool/values.yaml b/helm/bilibili-tool/values.yaml
index f061f0c5d..79db9f2e7 100644
--- a/helm/bilibili-tool/values.yaml
+++ b/helm/bilibili-tool/values.yaml
@@ -2,13 +2,18 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
+
+namespace: default
replicaCount: 1
+configmap:
+ name: entry
+
image:
repository: zai7lou/bilibili_tool_pro
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
- tag: "0.2.1"
+ tag: "1.0.1"
imagePullSecrets: []
nameOverride: ""
@@ -34,10 +39,16 @@ env:
# value: ""
volumes:
- enabled: false
# if `enabled=true`, then path and name is required
- path: "/tmp/Logs"
- name: "bili-tool-vol"
+ log:
+ enabled: true
+ path: "/tmp/logs"
+ name: "bili-tool-vol"
+ login:
+ enabled: true
+ name: "entry"
+
+
podAnnotations: {}
@@ -45,10 +56,10 @@ resources:
# Recommended to set this resources field
limits:
cpu: 100m
- memory: 180Mi
+ memory: 120Mi
requests:
cpu: 100m
- memory: 180Mi
+ memory: 120Mi
nodeSelector: {}
diff --git a/src/Ray.BiliBiliTool.Config/Constants.cs b/src/Ray.BiliBiliTool.Config/Constants.cs
index e52e3648f..870682bbe 100644
--- a/src/Ray.BiliBiliTool.Config/Constants.cs
+++ b/src/Ray.BiliBiliTool.Config/Constants.cs
@@ -1,5 +1,7 @@
+using System.Collections;
using System.Collections.Generic;
+using System.Linq;
namespace Ray.BiliBiliTool.Config
{
@@ -33,13 +35,16 @@ public static class OptionsNames
///
public static Dictionary GetExpDic()
{
- return new Dictionary()
+ var dic = new Dictionary()
{
{"每日登录", "5"},
{"每日观看视频", "5"},
{"每日分享视频", "5"},
{"每日投币", "10"}
};
+ return dic.Select(x =>
+ new KeyValuePair($"{OptionsNames.ExpDictionaryName}:{x.Key}", x.Value))
+ .ToDictionary(k => k.Key, v => v.Value);
}
///
@@ -49,7 +54,7 @@ public static Dictionary GetExpDic()
///
public static Dictionary GetDonateCoinCanContinueStatusDic()
{
- return new Dictionary()
+ var dic = new Dictionary()
{
{"0", "成功"},
{"-400", "请求错误"},
@@ -59,6 +64,10 @@ public static Dictionary GetDonateCoinCanContinueStatusDic()
{"34004", "投币间隔太短"},
{"34005", "超过投币上限"}
};
+ return dic.Select(x =>
+ new KeyValuePair($"{OptionsNames.DonateCoinCanContinueStatusDictionaryName}:{x.Key}", x.Value))
+ .ToDictionary(k => k.Key, v => v.Value)
+ ;
}
public static Dictionary GetCommandLineMappingsDic()
diff --git a/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs b/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs
index 9169b6d06..5ba063782 100644
--- a/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs
+++ b/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs
@@ -26,8 +26,8 @@ public static IServiceCollection AddBiliBiliConfigs(this IServiceCollection serv
.Configure(configuration.GetSection("Security"))
.Configure(configuration.GetSection("ReceiveVipPrivilegeConfig"))
.Configure(configuration.GetSection("LiveFansMedalTaskOptions"))
- .Configure>(Constants.OptionsNames.ExpDictionaryName, configuration.GetSection("Exp"))
- .Configure>(Constants.OptionsNames.DonateCoinCanContinueStatusDictionaryName, configuration.GetSection("DonateCoinCanContinueStatus"));
+ .Configure>(Constants.OptionsNames.ExpDictionaryName, configuration.GetSection(Constants.OptionsNames.ExpDictionaryName))
+ .Configure>(Constants.OptionsNames.DonateCoinCanContinueStatusDictionaryName, configuration.GetSection(Constants.OptionsNames.DonateCoinCanContinueStatusDictionaryName));
return services;
}
diff --git a/src/Ray.BiliBiliTool.Console/Program.cs b/src/Ray.BiliBiliTool.Console/Program.cs
index d3f96da7d..7dc7ce0a1 100644
--- a/src/Ray.BiliBiliTool.Console/Program.cs
+++ b/src/Ray.BiliBiliTool.Console/Program.cs
@@ -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);
}
diff --git a/src/Ray.BiliBiliTool.Console/appsettings.json b/src/Ray.BiliBiliTool.Console/appsettings.json
index 79a607921..89740733a 100644
--- a/src/Ray.BiliBiliTool.Console/appsettings.json
+++ b/src/Ray.BiliBiliTool.Console/appsettings.json
@@ -113,7 +113,8 @@
"botToken": "",
"chatId": "",
"restrictedToMinimumLevel": "Information",
- "proxy": "" //代理,user:password@host:port
+ "proxy": "", //代理,user:password@host:port
+ "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)
diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs
index 3004c40ef..67442a3d6 100644
--- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs
+++ b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs
@@ -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";
///
/// The API URL.
@@ -32,7 +32,7 @@ public class TelegramApiClient : PushService
/// The Telegram bot token.
/// The timeout seconds.
/// Thrown if the bot token is null or empty.
- public TelegramApiClient(string botToken, string chatId, string proxy="", int timeoutSeconds = 10)
+ public TelegramApiClient(string botToken, string chatId, string proxy = "", string apiHost = "", int timeoutSeconds = 10)
{
if (string.IsNullOrWhiteSpace(botToken))
{
@@ -43,7 +43,8 @@ public TelegramApiClient(string botToken, string chatId, string proxy="", int ti
_chatId = chatId;
_proxy = proxy;
- this._apiUrl = new Uri($"{TelegramBotApiUrl}{botToken}/sendMessage");
+ var botApiHost = string.IsNullOrWhiteSpace(apiHost)? DefaultTelegramBotApiHost:apiHost;
+ this._apiUrl = new Uri($"{botApiHost}/bot{botToken}/sendMessage");
if (proxy.IsNotNullOrEmpty())
{
@@ -101,7 +102,7 @@ private WebProxy GetWebProxy(string proxyAddress)
var credentials = new NetworkCredential(proxyUser, proxyPass);
- webProxy = new WebProxy(address, true,null, credentials);
+ webProxy = new WebProxy(address, true, null, credentials);
}
else
{
diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs
index 5ac1455aa..4fa7d2b2e 100644
--- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs
+++ b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs
@@ -15,11 +15,13 @@ public class TelegramBatchedSink : BatchedSink
private readonly string _botToken;
private readonly string _chatId;
private readonly string _proxy;
+ private readonly string _apiHost;
public TelegramBatchedSink(
string botToken,
string chatId,
string proxy,
+ string apiHost,
Predicate predicate,
bool sendBatchesAsOneMessages,
IFormatProvider formatProvider,
@@ -29,6 +31,7 @@ LogEventLevel minimumLogEventLevel
_botToken = botToken;
_chatId = chatId;
_proxy = proxy;
+ _apiHost = apiHost;
}
public override void Emit(LogEvent logEvent)
@@ -37,7 +40,7 @@ public override void Emit(LogEvent logEvent)
base.Emit(logEvent);
}
- protected override PushService PushService => new TelegramApiClient(_botToken, _chatId, _proxy, 5);
+ protected override PushService PushService => new TelegramApiClient(_botToken, _chatId, _proxy, _apiHost, 5);
public override void Dispose()
{
diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs
index ab9ebb466..9b4ca8d51 100644
--- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs
+++ b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs
@@ -13,6 +13,7 @@ public static LoggerConfiguration TelegramBatched(
string botToken,
string chatId,
string proxy,
+ string apiHost,
string containsTrigger = Constants.DefaultContainsTrigger,
bool sendBatchesAsOneMessages = true,
IFormatProvider formatProvider = null,
@@ -22,7 +23,7 @@ public static LoggerConfiguration TelegramBatched(
if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger;
Predicate predicate = x => x.MessageTemplate.Text.Contains(containsTrigger);
- return loggerSinkConfiguration.Sink(new TelegramBatchedSink(botToken, chatId, proxy, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel);
+ return loggerSinkConfiguration.Sink(new TelegramBatchedSink(botToken, chatId, proxy, apiHost, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel);
}
}
}
diff --git a/test/ConfigTest/TestDonateCoinStatusConfig.cs b/test/ConfigTest/TestDonateCoinStatusConfig.cs
index bdb677b67..dd696b50f 100644
--- a/test/ConfigTest/TestDonateCoinStatusConfig.cs
+++ b/test/ConfigTest/TestDonateCoinStatusConfig.cs
@@ -1,14 +1,11 @@
using System;
-using System.Text.Json;
using System.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Ray.BiliBiliTool.Config;
-using Ray.BiliBiliTool.Config.Options;
using Ray.BiliBiliTool.Console;
using Xunit;
using Ray.BiliBiliTool.Infrastructure;
-using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
namespace ConfigTest
@@ -29,6 +26,8 @@ public void Test1()
var dic = options.Get(Constants.OptionsNames.DonateCoinCanContinueStatusDictionaryName);
Debug.WriteLine(dic.ToJson());
+
+ Assert.True(dic.Count > 0);
}
}
}
diff --git a/test/ConfigTest/TestExpConfig.cs b/test/ConfigTest/TestExpConfig.cs
index 348e3ba8c..94c2d3c8d 100644
--- a/test/ConfigTest/TestExpConfig.cs
+++ b/test/ConfigTest/TestExpConfig.cs
@@ -1,14 +1,11 @@
using System;
-using System.Text.Json;
using System.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Ray.BiliBiliTool.Config;
-using Ray.BiliBiliTool.Config.Options;
using Ray.BiliBiliTool.Console;
using Xunit;
using Ray.BiliBiliTool.Infrastructure;
-using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
namespace ConfigTest
@@ -25,10 +22,12 @@ public void Test1()
{
using var scope = Global.ServiceProviderRoot.CreateScope();
- var options = scope.ServiceProvider.GetRequiredService>>();
- var dic = options.Get("exp");
+ var options = scope.ServiceProvider.GetRequiredService>>();
+ var dic = options.Get(Constants.OptionsNames.ExpDictionaryName);
Debug.WriteLine(dic.ToJson());
+
+ Assert.True(dic.Count > 0);
}
}
}
diff --git a/test/LogTest/TestTelegram.cs b/test/LogTest/TestTelegram.cs
index 65ff2cfaf..6a3b811e7 100644
--- a/test/LogTest/TestTelegram.cs
+++ b/test/LogTest/TestTelegram.cs
@@ -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"];