Skip to content

Commit d53f072

Browse files
authored
Merge pull request #32 from Elepover/pmcenter-lazer
pmcenter 2.0 feature drop
2 parents 58cf01b + dd05fa4 commit d53f072

162 files changed

Lines changed: 2337 additions & 1515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FILE_STRUCTURE.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ File structure of pmcenter's source code:
44
|- pmcenter - Source code main directory
55
|- BotCommands - Every bot command's processing logic
66
| |- ...
7+
|- BotProcess - Bot's message routing logics
8+
| |- ...
9+
|- CallbackActions - Every inline keyboard command's processing logic
10+
| |- ...
711
|- CommandLines - Every commandline's processing logic
812
| |- ...
913
|- Configurations - Configurations' processing logics
1014
| |- ...
11-
|- Enums - pmcenter's self-defined enums
15+
|- EventHandlers - Global error handler and Ctrl-C handler
1216
| |- ...
1317
|- Interfaces - pmcenter's self-defined interfaces
1418
| |- ...
@@ -18,15 +22,17 @@ File structure of pmcenter's source code:
1822
| | | |- ...
1923
| | |- Writing - For writing things to database
2024
| | | |- ...
25+
| |- H2Helper - http/2 helper
26+
| | |- ...
27+
| |- Logging - Logging module
28+
| | |- ...
2129
| |- NetworkTest - Testing network quality, used by some commands
2230
| | |- ...
2331
| |- Threads - Threads' logics
2432
| | |- ...
33+
| |- UpdateHelper - pmcenter updates helper
34+
| | |- ...
2535
| |- ...
26-
|- BotProcess.cs - Bot's master logic
27-
|- CommandLineRouter.cs - Commandlines' router
28-
|- CommandLines.cs - Loading commandlines to memory
29-
|- CommandManager.cs - Bot commands' router
3036
|- Program.cs - Main entry of pmcenter
3137
|- Setup.cs - Setup wizard's processing logic
3238
|- Template.cs - As its name

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pmcenter
22

3-
[![build status](https://ci.appveyor.com/api/projects/status/gmbdiackw0563980?svg=true)](https://ci.appveyor.com/project/Elepover/pmcenter) [![CodeFactor](https://www.codefactor.io/repository/github/elepover/pmcenter/badge)](https://www.codefactor.io/repository/github/elepover/pmcenter) [![telegram channel](https://img.shields.io/badge/telegram-channel-blue.svg)](https://t.me/pmcenter_devlog) ![license](https://img.shields.io/github/license/elepover/pmcenter.svg) ![language rank](https://img.shields.io/github/languages/top/elepover/pmcenter.svg?color=brightgreen) ![repo size in bytes](https://img.shields.io/github/repo-size/elepover/pmcenter.svg) ![environment](https://img.shields.io/badge/dotnet-v2.1-blue.svg) ![last commit](https://img.shields.io/github/last-commit/elepover/pmcenter.svg) ![status](https://img.shields.io/badge/status-maintaining-success.svg)
3+
[![build status](https://ci.appveyor.com/api/projects/status/gmbdiackw0563980?svg=true)](https://ci.appveyor.com/project/Elepover/pmcenter) [![CodeFactor](https://www.codefactor.io/repository/github/elepover/pmcenter/badge)](https://www.codefactor.io/repository/github/elepover/pmcenter) [![telegram channel](https://img.shields.io/badge/telegram-channel-blue.svg)](https://t.me/pmcenter_devlog) ![license](https://img.shields.io/github/license/elepover/pmcenter.svg) ![language rank](https://img.shields.io/github/languages/top/elepover/pmcenter.svg?color=brightgreen) ![repo size in bytes](https://img.shields.io/github/repo-size/elepover/pmcenter.svg) ![environment](https://img.shields.io/badge/dotnet-v3.1-blueviolet.svg) ![last commit](https://img.shields.io/github/last-commit/elepover/pmcenter.svg) ![status](https://img.shields.io/badge/status-maintaining-success.svg)
44

55
A telegram bot helping you process private messages.
66

@@ -142,6 +142,7 @@ Or, use setup wizard:
142142

143143
| Key | Type | User Editable | Description |
144144
| :---- | :---- | :---- | ----:|
145+
| `Minify` | `Boolean`|| To minify pmcenter configurations or not. |
145146
| `APIKey` | `String`|| Your Telegram bot's API key. |
146147
| `OwnerID` | `Long` || The owner's Telegram user ID. |
147148
| `EnableCc` | `Boolean` || Decides whether cc feature is enabled or not. |
@@ -176,7 +177,13 @@ Or, use setup wizard:
176177
| `UpdateChannel` | `String` || Choose which update channel you prefer to. |
177178
| `IgnoreKeyboardInterrupt` | `Boolean` || Choose whether pmcenter should ignore Ctrl-C interrupts or not. |
178179
| `DisableNetCore3Check` | `Boolean` || Turn this on to hide .NET Core Runtime version warnings. |
180+
| `DisableMessageLinkTip` | `Boolean` || Turn this on to hide message link tip prompts. |
181+
| `AnalyzeStartupTime` | `Boolean` || Turn this on to show detailed analysis of startup time. |
182+
| `SkipAPIKeyVerification` | `Boolean` || Turn this on to skip API Key verification on startup. |
183+
| `EnableActions` | `Boolean` || Turn this on to enable message actions. |
184+
| `CheckLangVersionMismatch` | `Boolean` || Check language version and send alert on startup. |
179185
| `Statistics` | `Stats` || Statistics data. |
186+
| `IgnoredLogModules` | `Array` || List of ignored log modules. Selected modules will not generate output to console. |
180187
| `Socks5Proxies` | `Array` || List of SOCKS5 proxies. |
181188
| `BannedKeywords` | `Array` || Storage of banned keywords. |
182189
| `Banned` | `Array` || Storage of banned users. |
@@ -199,7 +206,8 @@ Tip: After upgrades, you can send `/saveconf` command to the bot to fix missing
199206
- **Emojis** are supported, and were used by default.
200207
- Currently the response of the `/info` command is unchangeable.
201208
- Familiar with another language? Pull requests are welcome!
202-
- Please think twice before turning on `EnableMsgLink`, it makes it possible for you to reply to messages that are forwarded anonymously or from channels, however, it will cost more and more of your storage space and memory as the storage grows and makes it slower for pmcenter to process configuration files.
209+
- ~~Please think twice before turning on `EnableMsgLink`, it makes it possible for you to reply to messages that are forwarded anonymously or from channels, however, it will cost more and more of your storage space and memory as the storage grows and makes it slower for pmcenter to process configuration files.~~
210+
- Now Message Links play an important role in pmcenter's basic functions. Turning it off is NOT recommended.
203211

204212
#### Changing File Location
205213

@@ -246,6 +254,7 @@ You can write a `systemd service` to keep it running, even after the host machin
246254
| `/backup` | Owner | Backup configurations. |
247255
| `/editconf <CONF>` | Owner | Manually edit configurations and translations w/ JSON-formatted text. |
248256
| `/saveconf` | Owner | Manually save configurations and translations. Useful after upgrades. |
257+
| `/autosave [off/interval]` | Owner | Enable/Disable autosave. Intervals are in milliseconds (1/1000 of a second). |
249258
| `/readconf` | Owner | Reload configurations without restarting bot. |
250259
| `/resetconf` | Owner | Reset configurations. |
251260
| `/uptime` | Owner | Get system uptime info. |
@@ -301,6 +310,8 @@ pmcenter is planning to move to .NET Core 3.1, see [issue #25](https://github.co
301310

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

313+
You can NOT reply to the messages that were forwarded when `EnableMsgLink` option was disabled since their corresponding message links were missing.
314+
304315
For more information, refer to the [configurations](#pmcenter-settings) part.
305316

306317
### Why pmcenter.json is too large?

README_zh.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pmcenter
22

3-
[![build status](https://ci.appveyor.com/api/projects/status/gmbdiackw0563980?svg=true)](https://ci.appveyor.com/project/Elepover/pmcenter) [![CodeFactor](https://www.codefactor.io/repository/github/elepover/pmcenter/badge)](https://www.codefactor.io/repository/github/elepover/pmcenter) [![telegram channel](https://img.shields.io/badge/telegram-channel-blue.svg)](https://t.me/pmcenter_devlog) ![license](https://img.shields.io/github/license/elepover/pmcenter.svg) ![language rank](https://img.shields.io/github/languages/top/elepover/pmcenter.svg?color=brightgreen) ![repo size in bytes](https://img.shields.io/github/repo-size/elepover/pmcenter.svg) ![environment](https://img.shields.io/badge/dotnet-v2.1-blue.svg) ![last commit](https://img.shields.io/github/last-commit/elepover/pmcenter.svg) ![status](https://img.shields.io/badge/status-maintaining-success.svg)
3+
[![build status](https://ci.appveyor.com/api/projects/status/gmbdiackw0563980?svg=true)](https://ci.appveyor.com/project/Elepover/pmcenter) [![CodeFactor](https://www.codefactor.io/repository/github/elepover/pmcenter/badge)](https://www.codefactor.io/repository/github/elepover/pmcenter) [![telegram channel](https://img.shields.io/badge/telegram-channel-blue.svg)](https://t.me/pmcenter_devlog) ![license](https://img.shields.io/github/license/elepover/pmcenter.svg) ![language rank](https://img.shields.io/github/languages/top/elepover/pmcenter.svg?color=brightgreen) ![repo size in bytes](https://img.shields.io/github/repo-size/elepover/pmcenter.svg) ![environment](https://img.shields.io/badge/dotnet-v3.1-blueviolet.svg) ![last commit](https://img.shields.io/github/last-commit/elepover/pmcenter.svg) ![status](https://img.shields.io/badge/status-maintaining-success.svg)
44

55
一个帮你处理私人聊天消息的 Telegram 机器人。
66

@@ -144,6 +144,7 @@ docker run -d -v $(pwd)/pmcenter.json:/opt/pmcenter/pmcenter.json --restart alwa
144144

145145
| 项目 | 类型 | 用户可编辑 | 描述 |
146146
| :---- | :---- | :---- | ----:|
147+
| `Minify` | `Boolean`|| 是否精简化 pmcenter 配置 |
147148
| `APIKey` | `String` || 你的 Telegram 机器人 API 密钥 |
148149
| `OwnerID` | `Long` || 使用者的 Telegram ID |
149150
| `EnableCc` | `Boolean` || 是否启用 Cc 功能 |
@@ -178,7 +179,13 @@ docker run -d -v $(pwd)/pmcenter.json:/opt/pmcenter/pmcenter.json --restart alwa
178179
| `UpdateChannel` | `String` || 选择更新频道 |
179180
| `IgnoreKeyboardInterrupt` | `Boolean` || 是否忽略 Ctrl-C 中断 |
180181
| `DisableNetCore3Check` | `Boolean` || 启用以忽略 .NET Core 运行时版本检查 |
182+
| `DisableMessageLinkTip` | `Boolean` || 启用以忽略消息链接提示 |
183+
| `AnalyzeStartupTime` | `Boolean` || 启用以显示细化的启动时间分析 |
184+
| `SkipAPIKeyVerification` | `Boolean` || 启用以跳过启动时的 API 密钥校验 |
185+
| `EnableActions` | `Boolean` || 启动以启用消息操作面版 |
186+
| `CheckLangVersionMismatch` | `Boolean` || 在启动时检测语言文件版本 |
181187
| `Statistics` | `Stats` || 统计数据 |
188+
| `IgnoredLogModules` | `Array` || 忽略的日志模块列表,这些模块将不会输出信息到控制台 |
182189
| `Socks5Proxies` | `Array` || SOCKS5 代理列表 |
183190
| `BannedKeywords` | `Array` || 屏蔽的关键字存储 |
184191
| `Banned` | `Array` || 封禁用户存储 |
@@ -202,7 +209,8 @@ docker run -d -v $(pwd)/pmcenter.json:/opt/pmcenter/pmcenter.json --restart alwa
202209
- 目前 `/info` 命令的回复尚且无法更改。
203210
- 欢迎 Pull Requests.
204211
- 切换中文语言包,只需发送 `/switchlang https://raw.githubusercontent.com/Elepover/pmcenter/master/locales/pmcenter_locale_zh.json`
205-
- 在启用 `EnableMsgLink` 前请三思:虽然此功能允许您回复匿名转发消息及频道消息,但 pmcenter 的存储和内存占用将随消息量增长而增加,并将拖慢 pmcenter 操作配置文件时的速度。
212+
- ~~在启用 `EnableMsgLink` 前请三思:虽然此功能允许您回复匿名转发消息及频道消息,但 pmcenter 的存储和内存占用将随消息量增长而增加,并将拖慢 pmcenter 操作配置文件时的速度。~~
213+
- 现在消息链接在 pmcenter 正常功能中起着重要作用,我们不推荐将其禁用。
206214

207215
#### 改变文件位置
208216

@@ -249,6 +257,7 @@ pmcenter_lang: pmcenter 语言文件路径。
249257
| `/backup` | 所有者 | 备份配置文件 |
250258
| `/editconf <CONF>` | 所有者 | 手动保存 JSON 格式的配置及翻译 |
251259
| `/saveconf` | 所有者 | 手动保存配置及翻译,可用于更新后补齐缺少的配置项 |
260+
| `/autosave [off/时间间隔]` | 所有者 | 启用或停用自动保存,时间间隔单位为毫秒(1/1000 秒) |
252261
| `/readconf` | 所有者 | 在不重启机器人的情况下,重新载入配置 |
253262
| `/resetconf` | 所有者 | 重置配置文件 |
254263
| `/uptime` | 所有者 | 获取系统在线时间信息 |
@@ -304,6 +313,8 @@ pmcenter 正在准备转向 .NET Core 3.1,请参考 [issue #25](https://github
304313

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

316+
您无法回复在此选项处于禁用状态时被转发的消息,因为对应的消息链接不存在。
317+
307318
如需更多信息,请参见[配置](#pmcenter-设置)部分。
308319

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

locales/pmcenter_locale_en.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"TargetVersion": "1.9.280.15",
2+
"TargetVersion": "2.0.2.0",
33
"LangCode": "en.imported",
44
"LanguageNameInEnglish": "English",
55
"LanguageNameInNative": "English",
66
"Message_OwnerStart": "😊 *Hi!* I'm your `pmcenter` bot, and I work just for you.\nThis message means that you've set up the bot successfully.\nTo reply to any forwarded messages, just directly reply to them here.\n\nThank you for using the `pmcenter` bot!",
77
"Message_UserStartDefault": "📨 *Hi!* To send anything to my owner, just send it here.\n⚠ To be informed: I'll *automatically* ban flooding users.",
88
"Message_ReplySuccessful": "✅ Successfully replied to user $1!",
99
"Message_ForwardedToOwner": "✅ Your message has been forwarded to my owner!",
10-
"Message_Help": "❓ `pmcenter` *Bot Help*\n/start - Display welcome message.\n/info - Display the message's info.\n/ban - Restrict the user from contacting you.\n/banid <ID> - Restrict a user from contacting you with his/her ID.\n/pardon - Pardon the user.\n/pardonid <ID> - Pardon a user with his/her ID.\n/ping - Test if the bot is working.\n/switchfw - Pause/Resume message forwarding.\n/switchbw - Enable/Disable keyword banning.\n/switchnf - Enable/Disable notifications.\n/switchlang <URL> - Switch language file.\n/switchlangcode [Code] - Switch language with language code.\n/detectperm - Detect permissions.\n/backup - Backup configurations.\n/editconf <CONF> - Manually edit settings w/ JSON-formatted text.\n/saveconf - Manually save all settings and translations. Especially useful after upgrades.\n/readconf - Reload configurations without restarting bot.\n/resetconf - Reset configurations.\n/uptime - Check system uptime information.\n/update - Check for updates and update bot.\n/chkupdate - Only check for updates.\n/catconf - Get your current configurations.\n/restart - Restart bot.\n/status - Get host device's status information.\n/perform - Run performance test.\n/testnetwork - Test latency to servers used by pmcenter.\n/chat - Enter Continued Conversation mode.\n/stopchat - Leave Continued Conversation mode.\n/retract - Retract a message.\n/clearmessagelinks - Clear message links.\n/getstats - Get statistics data.\n/help - Display this message.\n\nThank you for using `pmcenter`!",
10+
"Message_Help": "❓ `pmcenter` *Bot Help*\n/start - Display welcome message.\n/info - Display the message's info.\n/ban - Restrict the user from contacting you.\n/banid <ID> - Restrict a user from contacting you with his/her ID.\n/pardon - Pardon the user.\n/pardonid <ID> - Pardon a user with his/her ID.\n/ping - Test if the bot is working.\n/switchfw - Pause/Resume message forwarding.\n/switchbw - Enable/Disable keyword banning.\n/switchnf - Enable/Disable notifications.\n/switchlang <URL> - Switch language file.\n/switchlangcode [Code] - Switch language with language code.\n/detectperm - Detect permissions.\n/backup - Backup configurations.\n/editconf <CONF> - Manually edit settings w/ JSON-formatted text.\n/saveconf - Manually save all settings and translations. Especially useful after upgrades.\n/readconf - Reload configurations without restarting bot.\n/resetconf - Reset configurations.\n/uptime - Check system uptime information.\n/update - Check for updates and update bot.\n/chkupdate - Only check for updates.\n/catconf - Get your current configurations.\n/restart - Restart bot.\n/status - Get host device's status information.\n/perform - Run performance test.\n/testnetwork - Test latency to servers used by pmcenter.\n/chat - Enter Continued Conversation mode.\n/stopchat - Leave Continued Conversation mode.\n/retract - Retract a message.\n/clearmessagelinks - Clear message links.\n/getstats - Get statistics data.\n/autosave [off/interval] - Switch autosave status.\n/help - Display this message.\n\nThank you for using `pmcenter`!",
1111
"Message_UserBanned": "🚫 The user has been banned permanently.",
1212
"Message_UserPardoned": "✅ You've pardoned the user.",
1313
"Message_CommandNotReplying": "😶 Don't talk to me, spend time chatting with those who love you.",
@@ -70,5 +70,21 @@
7070
"Message_Retracted": "✅ This message has been retracted.",
7171
"Message_MsgLinksCleared": "✅ All message links have been cleared.",
7272
"Message_AvailableLang": "ℹ *Available languages*\n\n`$1`",
73-
"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."
73+
"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.",
74+
"Message_MsgLinkTip": "ℹ Tip: You need to set `EnableMsgLink` option to `true` in pmcenter configurations in order to reply to anonymously forwarded messages.\nThis also happens when the message link for the message couldn't be found.\nDue to Telegram API's restrictions, it's impossible now to reply to that message.\nAfter you set `EnableMsgLink` to `true`, you'll be able to reply to this kind of messages.\n\nThis tip will only prompt once.",
75+
"Message_AutoSaveEnabled": "✅ Autosave *enabled*, interval: `$1s`.",
76+
"Message_AutoSaveIntervalTooShort": "⚠ The current autosave interval (`$1ms`) is *too short*! It may cause high CPU and disk usage as a result. *Disable it if you didn't intend to do that!*",
77+
"Message_AutoSaveDisabled": "✅ Autosave *disabled*.",
78+
"Message_Action_Banned": "✅ User $1 has been banned!",
79+
"Message_Action_Pardoned": "✅ User $1 has been pardoned!",
80+
"Message_Action_ContChatEnabled": "✅ You're now chatting with $1!",
81+
"Message_Action_ContChatDisabled": "✅ Continued chat disabled!",
82+
"Message_Action_Error": "✖ Action failed. Check logs.",
83+
"Message_Action_ErrorWithDetails": "✖ Action failed: $1",
84+
"Message_Action_ChooseAction": "❓ *What do you want to do with this message?*",
85+
"Message_Action_Ban": "✖ Ban the user",
86+
"Message_Action_Pardon": "✅ Pardon the user",
87+
"Message_Action_Chat": "💬 Enter continued conversation",
88+
"Message_Action_StopChat": "💬 Stop continued conversation",
89+
"Message_Action_LinkNotFound": "✖ Cannot find the corresponding message link, did you just clear the message links, or was the message links feature disabled?"
7490
}

0 commit comments

Comments
 (0)