Skip to content

Commit

Permalink
update master to latest pmcenter-lazer version
Browse files Browse the repository at this point in the history
Update master branch for pmcenter v2 preparation
  • Loading branch information
Elepover authored Apr 5, 2020
2 parents ee41696 + 4de73d4 commit 58cf01b
Show file tree
Hide file tree
Showing 38 changed files with 377 additions and 70 deletions.
15 changes: 15 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pmcenter Authors

Thanks to all the people that had made contributions to the pmcenter project:

If you're a new contributor, feel free to add yourself to the list when committing.

### List of pmcenter Authors

Elepover / Elepooooover
Genteure
jimchen5209 / Jim Chen
lwl12
milkice233 / milkice
tasi788 / 踢低吸
U2FsdGVkX1
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A telegram bot helping you process private messages.
> - [⛵ Changing File Location](#changing-file-location)
> - [🚀 Starting](#starting)
> - [🔩 Commands](#commands)
> - [❔ FAQ](#faq)
> - [🔺 Disclaimer](#disclaimer)
## Branches
Expand Down Expand Up @@ -173,6 +174,8 @@ Or, use setup wizard:
| `AdvancedLogging` | `Boolean` || If enabled, pmcenter will display the code files and line number where the logging was triggered. |
| `DisableTimeDisplay` | `Boolean` || Don't display time in the logs. |
| `UpdateChannel` | `String` || Choose which update channel you prefer to. |
| `IgnoreKeyboardInterrupt` | `Boolean` || Choose whether pmcenter should ignore Ctrl-C interrupts or not. |
| `DisableNetCore3Check` | `Boolean` || Turn this on to hide .NET Core Runtime version warnings. |
| `Statistics` | `Stats` || Statistics data. |
| `Socks5Proxies` | `Array` || List of SOCKS5 proxies. |
| `BannedKeywords` | `Array` || Storage of banned keywords. |
Expand Down Expand Up @@ -261,9 +264,9 @@ You can write a `systemd service` to keep it running, even after the host machin

Please note: `/restart` command only works with a daemon that auto-restarts pmcenter when it exits. pmcenter cannot restart by itself.

# Known Problems
## Known Problems

## OpenSSL Compatibility Problem
### OpenSSL Compatibility Problem

This problem only occurs on Linux, and will not occur on Windows.

Expand All @@ -284,6 +287,34 @@ As is mentioned in issue [#33179](https://github.com/dotnet/corefx/issues/33179)
2. Upgrade to a newer (later than #34443) .NET Core 2.1 runtime.
3. Install OpenSSL 1.0.

# Disclaimer
## FAQ

### Why are you still targeting to .NET Core 2.1?

According to [.NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core), the .NET Core 2.2 is now EOL, .NET Core 3.0 is also approaching its _End of Support Date_. As for .NET Core 3.1, which has LTS support level, it may not be as widely supported as .NET Core 2.1 (which also has LTS support level). So we finally chose .NET Core 2.1.

The existing pmcenter code is completely compatible with .NET Core 3.1, but will not take advantage of the new features (like AOT compilation and TLS 1.3 support).

pmcenter is planning to move to .NET Core 3.1, see [issue #25](https://github.com/Elepover/pmcenter/issues/25).

### Why cannot I reply to anonymously forwarded messages?

Please enable the `EnableMsgLink` option in pmcenter's configurations file. Only messages forwarded when `EnableMsgLink` option is turned on can be replied.

For more information, refer to the [configurations](#pmcenter-settings) part.

### Why pmcenter.json is too large?

Maybe your pmcenter instance has saved too many Message Links, try this following command:

`/clearmessagelinks`

### Why pmcenter didn't restart when I use the `/restart` command?

The `/restart` command requires a daemon process or service manager (like `systemd` in some Linux distros), it cannot be restarted by itself. Check your system's configurations.

We also have a sample `systemd` service for you [here](https://github.com/Elepover/pmcenter/blob/master/pmcenter.service).

## Disclaimer

The program is licensed under Apache License _(Version 2.0. Dependencies are licensed under MIT License)_ and comes with **ABSOLUTELY NO WARRANTY**. By using the program in any way, you acknowledge and confirm that the developer of the program is **NOT RESPONSIBLE** for service outage, data loss or any other rare unlisted incident caused by the program.
37 changes: 34 additions & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
> - [⛵ 改变文件位置](#改变文件位置)
> - [🚀 启动](#启动)
> - [🔩 命令](#命令)
> - [❔ 常见问题](#常见问题)
> - [🔺 免责声明](#免责声明)
## 分支
Expand Down Expand Up @@ -175,6 +176,8 @@ docker run -d -v $(pwd)/pmcenter.json:/opt/pmcenter/pmcenter.json --restart alwa
| `AdvancedLogging` | `Boolean` || 如果启用,pmcenter 会在日志消息中附加输出时的代码文件及行号信息 |
| `DisableTimeDisplay` | `Boolean` || 不在日志中显示时间 |
| `UpdateChannel` | `String` || 选择更新频道 |
| `IgnoreKeyboardInterrupt` | `Boolean` || 是否忽略 Ctrl-C 中断 |
| `DisableNetCore3Check` | `Boolean` || 启用以忽略 .NET Core 运行时版本检查 |
| `Statistics` | `Stats` || 统计数据 |
| `Socks5Proxies` | `Array` || SOCKS5 代理列表 |
| `BannedKeywords` | `Array` || 屏蔽的关键字存储 |
Expand Down Expand Up @@ -264,9 +267,9 @@ pmcenter_lang: pmcenter 语言文件路径。

请注意: `/restart` 命令仅在有有效的守护进程,且其能在 pmcenter 退出后自动将其重启的情况下工作。pmcenter 无法自行重新启动。

# 已知问题
## 已知问题

## OpenSSL 1.1 兼容性问题
### OpenSSL 1.1 兼容性问题

此问题仅在 Linux 环境下出现,与 Windows 无关。

Expand All @@ -287,7 +290,35 @@ System.Net.Http.HttpRequestException: The SSL connection could not be establishe
2. 更新 (新于 #34443) 的 .NET Core 2.1 运行时。
3. 安装 OpenSSL 1.0.

# 免责声明
## 常见问题

### 为什么 pmcenter 的目标框架仍然是 .NET Core 2.1?

根据 [.NET Core 支持政策](https://dotnet.microsoft.com/platform/support/policy/dotnet-core),.NET Core 2.2 已停止支持,.NET Core 3.0 也即将达到“终止支持日期”,至于有长期支持的 .NET Core 3.1,其支持范围可能不如同样为长期支持的 .NET Core 2.1,所以我们最终选择了 .NET Core 2.1.

现有的 pmcenter 代码与 .NET Core 3.1 完全兼容,但无法利用其新特性 (如提前编译及 TLS 1.3 支持)。

pmcenter 正在准备转向 .NET Core 3.1,请参考 [issue #25](https://github.com/Elepover/pmcenter/issues/25).

### 为什么我无法回复匿名转发的消息?

请在 pmcenter 设置文件中启用 `EnableMsgLink` 选项。只有在 `EnableMsgLink` 选项启用后的转发的消息可以被回复。

如需更多信息,请参见[配置](#pmcenter-设置)部分。

### 为什么 pmcenter.json 这么大?

可能您的 pmcenter 实例保存了太多的消息链接,请尝试使用以下命令:

`/clearmessagelinks`

### 为什么 pmcenter 在我使用 `/restart` 命令时并未重启?

`/restart` 命令需要一个守护进程或服务管理器 (比如在一些 Linux 发行版中的 `systemd`),其无法自行重启,请检查您的系统设置。

我们也[在此](https://github.com/Elepover/pmcenter/blob/master/pmcenter.service)为您提供了一份示例 `systemd` 服务文件。

## 免责声明

很抱歉,但鉴于某些事件,我们实在不得不加入这个章节,以至于独立成一个 commit 来提交。

Expand Down
9 changes: 5 additions & 4 deletions locales/pmcenter_locale_en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TargetVersion": "1.9.1.271",
"TargetVersion": "1.9.280.15",
"LangCode": "en.imported",
"LanguageNameInEnglish": "English",
"LanguageNameInNative": "English",
Expand Down Expand Up @@ -40,13 +40,13 @@
"Message_SysStatus_UpdateLevel_Unknown": "❓ Unknown",
"Message_SysStatus_RestartRequired": "🔄 *Bot restart required to apply changes.*",
"Message_SysStatus_Summary": "📝 *Device name*: `$1`\n💿 *Operating System*: `$2`\nℹ *OS description*: `$3`\n⌛ *Server uptime*: `$4`\n🕓 *Bot uptime*: `$5`\n📅 *Server time (UTC)*: `$6`\n📐 *Runtime version*: `$7`\nℹ *Runtime description*: `$8`\n📏 *Application version*: `$9`\n💠 *Processor count*: `$a`\n📖 *Language code*: `$b`\n🛫 *Update channel (current)*: `$f`\n🛬 *Update channel (target)*: `$g`\n🔄 *Update checker*: `$c`\n🔄 *Rate limit processor*: `$d`\n🔄 *Configuration reset verifier*: `$e`",
"Message_Restarting": "🔄 Restarting...\n\n_It only works with systemd daemon._",
"Message_Restarting": "🔄 Restarting...\n\n_It only works with systemd-like daemons._",
"Message_NotificationsOff": "📳 Notifications are *OFF*.",
"Message_NotificationsOn": "📲 Notifications are *ON*.",
"Message_SupportTextMessagesOnly": "📋 Sorry... Only text messages can be forwarded in Anonymous Forward mode.",
"Message_ForwarderNotReal": "ℹ The actual sender of this message is $1, whose UID is `$2`.\n\nYou can also ban this user by sending this following command:\n\n`/banid $2`\n\nTo undo this, send this command:\n\n`/pardonid $2`",
"Message_GeneralFailure": "✖ Error processing request: $1",
"Message_LangVerMismatch": "⚠ Language file ($1) is not for current version ($2), consider updating language file?",
"Message_LangVerMismatch": "⚠ Language file (`$1`) is not for current version (`$2`), consider updating language file?",
"Message_SwitchingLang": "💠 Switching language...",
"Message_LangSwitched": "🚀 Language switched!",
"Message_ThreadStatus_Unknown": "Unknown",
Expand All @@ -69,5 +69,6 @@
"Message_Stats": "📝 *Statistics*\n\n💬 Received messages: `$1`\n🔄 Forwarded to owner: `$2`\n🔄 Forwarded from owner: `$3`\n🚀 Commands received: `$4`",
"Message_Retracted": "✅ This message has been retracted.",
"Message_MsgLinksCleared": "✅ All message links have been cleared.",
"Message_AvailableLang": "ℹ *Available languages*\n\n`$1`"
"Message_AvailableLang": "ℹ *Available languages*\n\n`$1`",
"Message_NetCore31Required": "⚠ You need `.NET Core 3.1` (runtime) installed in order to receive pmcenter v2 and further updates.\n\nLatest .NET Core runtime version detected on your device: `$1`\n\nThis warning will only show once."
}
7 changes: 4 additions & 3 deletions locales/pmcenter_locale_zh.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TargetVersion": "1.9.1.271",
"TargetVersion": "1.9.280.15",
"LangCode": "zh.simplified",
"LanguageNameInEnglish": "Chinese (Simplified)",
"LanguageNameInNative": "简体中文",
Expand Down Expand Up @@ -46,7 +46,7 @@
"Message_SupportTextMessagesOnly": "📋 抱歉,匿名转发模式下仅能转发纯文本消息。",
"Message_ForwarderNotReal": "ℹ 实际消息发送者为: $1, 其 UID 为: `$2`.\n\n您也可以发送以下命令来屏蔽该用户:\n\n`/banid $2`\n\n若要撤销操作,请发送:\n\n`/pardonid $2`",
"Message_GeneralFailure": "✖ 处理请求时出错: $1",
"Message_LangVerMismatch": "⚠ 语言文件 ($1) 不适用于当前版本 ($2), 请考虑升级。",
"Message_LangVerMismatch": "⚠ 语言文件 (`$1`) 不适用于当前版本 (`$2`), 请考虑升级。",
"Message_SwitchingLang": "💠 正在切换语言...",
"Message_LangSwitched": "🚀 语言已切换!",
"Message_ThreadStatus_Unknown": "未知",
Expand All @@ -69,5 +69,6 @@
"Message_Stats": "📝 *统计数据*\n\n💬 接收到的消息: `$1`\n🔄 已转发给所有者: `$2`\n🔄 从所有者处转发: `$3`\n🚀 接收到的命令: `$4`",
"Message_Retracted": "✅ 消息已撤回。",
"Message_MsgLinksCleared": "✅ 所有消息链接已清空。",
"Message_AvailableLang": "ℹ *可用语言*\n\n`$1`"
"Message_AvailableLang": "ℹ *可用语言*\n\n`$1`",
"Message_NetCore31Required": "⚠ 您的设备上需要安装 `.NET Core 3.1` (运行时) 以获取 pmcenter v2 或未来版本的更新。\n\n在您设备上检测到的最新 .NET Core 运行时版本为: `$1`\n\n此警告只会出现一次。"
}
7 changes: 4 additions & 3 deletions locales/pmcenter_locale_zh.meow.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TargetVersion": "1.9.1.271",
"TargetVersion": "1.9.280.15",
"LangCode": "zh.meow",
"LanguageNameInEnglish": "Chinese (Meow)",
"LanguageNameInNative": "喵体中文",
Expand Down Expand Up @@ -46,7 +46,7 @@
"Message_SupportTextMessagesOnly": "📋 抱歉qaq, 匿名转发模式下仅能转发纯文本消息。",
"Message_ForwarderNotReal": "ℹ 实际消息发送者为: $1, 其 UID 为: `$2`.\n\n主人也可以发送以下命令来拍扁该用户:\n\n`/banid $2`\n\n若要撤销操作,请发送:\n\n`/pardonid $2`",
"Message_GeneralFailure": "✖ 处理请求时撞墙了qaq: $1",
"Message_LangVerMismatch": "⚠ 诶,语言文件 ($1) 好像不适用于当前版本 ($2) 呢, 要不要帮本喵升级一下呢w",
"Message_LangVerMismatch": "⚠ 诶,语言文件 (`$1`) 好像不适用于当前版本 (`$2`) 呢, 要不要帮本喵升级一下呢w",
"Message_SwitchingLang": "💠 语言包马上就切换好惹w",
"Message_LangSwitched": "🚀 语言包切换好啦~",
"Message_ThreadStatus_Unknown": "未知",
Expand All @@ -69,5 +69,6 @@
"Message_Stats": "📝 *统计数据*\n\n💬 小喵接收到的消息: `$1`\n🔄 已转发给主人: `$2`\n🔄 从主人这里转发: `$3`\n🚀 接收到的命令: `$4`",
"Message_Retracted": "✅ 消息已经从主人那边撤回啦~",
"Message_MsgLinksCleared": "✅ 所有消息链接都清理掉啦~",
"Message_AvailableLang": "ℹ *可用语言*\n\n`$1`"
"Message_AvailableLang": "ℹ *可用语言*\n\n`$1`",
"Message_NetCore31Required": "⚠ 您的设备上需要安装 `.NET Core 3.1` (运行时) 以获取 pmcenter v2 或未来版本的更新。\n\n在您设备上检测到的最新 .NET Core 运行时版本为: `$1`\n\n此警告只会出现一次。"
}
7 changes: 4 additions & 3 deletions locales/pmcenter_locale_zh.tw.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TargetVersion": "1.9.1.271",
"TargetVersion": "1.9.280.15",
"LangCode": "zh.tw",
"LanguageNameInEnglish": "Chinese (Traditional, Taiwan)",
"LanguageNameInNative": "繁體中文(台灣)",
Expand Down Expand Up @@ -46,7 +46,7 @@
"Message_SupportTextMessagesOnly": "📋 抱歉,匿名轉傳模式下僅能轉傳純文字訊息。",
"Message_ForwarderNotReal": "ℹ 實際訊息發送者為: $1, 其 UID 為: `$2`.\n\n您也可以發送以下指令來封鎖該用戶:\n\n`/banid $2`\n\n若要撤銷操作,請發送:\n\n`/pardonid $2`",
"Message_GeneralFailure": "✖ 處理請求時出錯: $1",
"Message_LangVerMismatch": "⚠ 語言文件 ($1) 不適用於目前版本 ($2), 請考慮升級。",
"Message_LangVerMismatch": "⚠ 語言文件 (`$1`) 不適用於目前版本 (`$2`), 請考慮升級。",
"Message_SwitchingLang": "💠 正在切換語言...",
"Message_LangSwitched": "🚀 語言已切換!",
"Message_ThreadStatus_Unknown": "未知",
Expand All @@ -69,5 +69,6 @@
"Message_Stats": "📝 *統計數據*\n\n💬 接收到的訊息: `$1`\n🔄 已轉傳給所有者: `$2`\n🔄 從所有者處轉傳: `$3`\n🚀 接收到的指令: `$4`",
"Message_Retracted": "✅ 訊息已撤銷。",
"Message_MsgLinksCleared": "✅ 所有訊息鏈接已清空。",
"Message_AvailableLang": "ℹ *可用語言*\n\n`$1`"
"Message_AvailableLang": "ℹ *可用語言*\n\n`$1`",
"Message_NetCore31Required": "⚠ 您的設備上需要安裝 `.NET Core 3.1` (運行時) 以獲取 pmcenter v2 或更新版本更新。\n\n在您的設備上識別到的最新 .NET Core 運行時版本為: `$1`\n\n此警告僅會出現一次。"
}
Binary file added og-banner.psd
Binary file not shown.
2 changes: 1 addition & 1 deletion pmcenter/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dotnet_diagnostic.CA1062.severity = suggestion
# CA1707: Identifiers should not contain underscores
dotnet_diagnostic.CA1707.severity = suggestion

# IDE0060: 删除未使用的参数
# IDE0060: Delete unused arguments
dotnet_code_quality_unused_parameters = all:suggestion

# CA2234: Pass system uri objects instead of strings
Expand Down
6 changes: 3 additions & 3 deletions pmcenter/BotCommands/ResetConfCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task<bool> ExecuteAsync(TelegramBotClient botClient, Update update)
false,
Vars.CurrentConf.DisableNotifications,
update.Message.MessageId).ConfigureAwait(false);
Environment.Exit(0);
Methods.ExitApp(0);
return true;
}
else
Expand All @@ -51,8 +51,8 @@ public async Task<bool> ExecuteAsync(TelegramBotClient botClient, Update update)
false,
Vars.CurrentConf.DisableNotifications,
update.Message.MessageId).ConfigureAwait(false);
Thread ConfValidator = new Thread(() => Methods.ThrDoResetConfCount());
ConfValidator.Start();
Vars.ConfValidator = new Thread(() => Methods.ThrDoResetConfCount());
Vars.ConfValidator.Start();
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pmcenter/BotCommands/RestartCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<bool> ExecuteAsync(TelegramBotClient botClient, Update update)
Vars.CurrentConf.DisableNotifications,
update.Message.MessageId).ConfigureAwait(false);
Thread.Sleep(5000);
Environment.Exit(0);
Methods.ExitApp(0);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pmcenter/BotCommands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ await Downloader.DownloadFileTaskAsync(
Vars.CurrentConf.DisableNotifications,
update.Message.MessageId).ConfigureAwait(false);
Log("Exiting program... (Let the daemon do the restart job)", "BOT");
Environment.Exit(0);
ExitApp(0);
return true;
// end of difference
}
Expand Down
4 changes: 2 additions & 2 deletions pmcenter/BotProcess.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
// BotProcess.cs / pmcenter project / https://github.com/Elepover/pmcenter
// Main processing logic of pmcenter.
// Copyright (C) 2018 Elepover. Licensed under the Apache License (Version 2.0).
// Copyright (C) The pmcenter authors. Licensed under the Apache License (Version 2.0).
*/

using pmcenter.Commands;
Expand All @@ -16,7 +16,7 @@ namespace pmcenter
{
public static class BotProcess
{
private static readonly CommandManager commandManager = new CommandManager();
private static readonly CommandRouter commandManager = new CommandRouter();

static BotProcess()
{
Expand Down
3 changes: 2 additions & 1 deletion pmcenter/CommandLines.cs → pmcenter/CommandLineProcess.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
// CommandLines.cs / pmcenter project / https://github.com/Elepover/pmcenter
// Commandlines are processed here.
// Copyright (C) 2018 Elepover. Licensed under the Apache License (Version 2.0).
// Copyright (C) The pmcenter authors. Licensed under the Apache License (Version 2.0).
*/

using System.Threading.Tasks;
Expand All @@ -16,6 +16,7 @@ static CmdLineProcess()
{
CmdLineRouter.RegisterCommand(new CommandLines.HelpCmdLine());
CmdLineRouter.RegisterCommand(new CommandLines.InfoCmdLine());
CmdLineRouter.RegisterCommand(new CommandLines.NonServiceModeCmdLine());
CmdLineRouter.RegisterCommand(new CommandLines.SetupWizardCmdLine());
CmdLineRouter.RegisterCommand(new CommandLines.ResetCmdLine());
CmdLineRouter.RegisterCommand(new CommandLines.BackupCmdLine());
Expand Down
2 changes: 1 addition & 1 deletion pmcenter/CommandLineRouter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
// CommandLineRouter.cs / pmcenter project / https://github.com/Elepover/pmcenter
// Command line routing manager.
// Copyright (C) 2018 Elepover. Licensed under the Apache License (Version 2.0).
// Copyright (C) The pmcenter authors. Licensed under the Apache License (Version 2.0).
*/

using System;
Expand Down
2 changes: 1 addition & 1 deletion pmcenter/CommandLines/HelpCmdLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class HelpCmdLine : ICmdLine
{
public string Prefix => "help";
public bool ExitAfterExecution => true;
private static string HelpString => "pmcenter commandline help\n--help: Display this message.\n--info: Get application information.\n--update: Update application manually.\n--backup: Backup configurations.\n--setup: Run setup wizard.\n--reset: Reset everything (use carefully).";
private static string HelpString => "pmcenter commandline help\n--help: Display this message.\n--info: Get application information.\n--update: Update application manually.\n--backup: Backup configurations.\n--setup: Run setup wizard.\n--reset: Reset everything (use carefully).\n--noservice: Disable service mode, making pmcenter appear as always waiting for user inputs.";
public Task<bool> Process()
{
Log("Printing commandline help...", "CMD");
Expand Down
Loading

0 comments on commit 58cf01b

Please sign in to comment.