Sign inSign up

moderras/pmcenter

By moderras

•Updated about 6 years ago

我只是给他做个可以直接pull的docker镜像, 原项目链接: https://github.com/Elepover/pmcenter

Image
1

1.8K

moderras/pmcenter repository overview

⁠pmcenter

build status telegram channel license language rank repo size in bytes environment last commit status

A telegram bot helping you process private messages.

⁠Documentation Language

⁠Table of Contents

⁠Features

  • 🚉 Cross-platform support from Windows to Linux and Raspian
  • 🛡️ High stability and availability
  • 📡 SOCKS5 proxy support
  • 🚧 Powerful anti-spamming system
    • 💬 Multiple filtering modes
      • 🔣 Regular expression mode
      • 🔠 Full word matching mode
    • 👤 Blocking by User ID
    • 🔄 Automatic blocking by message count
    • ☑️ Support for manual blocking
  • 📺 Daily maintenance, all on Telegram
    • 📥 Automatic updates
      • 🕑 Optional auto update check
      • ➡️ Manual update check
    • 🔄 Restarting bot
    • 🌐 Switching languages
    • 🗃 Reading/Writing configurations
    • 💻 Getting system status
  • ℹ️ Real message source display
  • 🆔 Support the new privacy mode introduced in Telegram 5.5.0
  • ... and more!

⁠Setting Up Your Own pmcenter

The following content will guide you through the installation process.

⁠Prerequisites
  • Microsoft .NET Core (Runtime / SDK)
  • Git (optional, not needed if you uses the binaries)

For officially supported operating systems, see here⁠.

For NOT officially supported operating systems, see here⁠.

For Arch Linux, there's an official package.

For Raspian or other distributions based on armv7 architecture, run this following script as root:

apt-get install curl libunwind8 gettext
curl -sSL -o dotnet.tar.gz https://download.microsoft.com/download/9/1/7/917308D9-6C92-4DA5-B4B1-B4A19451E2D2/dotnet-runtime-2.1.0-linux-arm.tar.gz
mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
ln -s /opt/dotnet/dotnet /usr/local/bin
rm dotnet.tar.gz
dotnet --info
⁠Build pmcenter Yourself

You need to install .NET Core SDK and Runtime to finish this.

Run this script to clone, build and initiate your own pmcenter:

git clone https://github.com/Elepover/pmcenter.git --depth=1
cd pmcenter/pmcenter
dotnet restore
dotnet publish --configuration Release
cp -R bin/Release/netcoreapp2.1/publish ../
cd .. && mv publish build
cd build
dotnet pmcenter.dll

The compiled binaries will be put in the pmcenter/build folder in your working directory.

⁠Use Pre-compiled Binaries

Only .NET Core Runtime is required in this step.

Run this script to download and initiate your own pmcenter:

mkdir pmcenter
cd pmcenter
wget https://ci.appveyor.com/api/projects/Elepover/pmcenter/artifacts/pmcenter.zip
unzip pmcenter.zip
dotnet pmcenter.dll
⁠Use Docker

DO NOT COPY & PASTE. You need to edit it before executing.

wget https://raw.githubusercontent.com/Elepover/pmcenter/master/Dockerfile
docker build . -t pmcenter
docker run -v PATH_OF_YOUR_pmcenter.json:/opt/pmcenter/pmcenter.json pmcenter

That's all.

⁠Configuring

During the first run, pmcenter will automatically generate the pmcenter.json and pmcenter_locale.json file for you. Change the settings to set up.

Or, use setup wizard:

dotnet pmcenter.dll --setup

Note: Running pmcenter with root privileges is STRONGLY UNRECOMMENDED. We recommend you run pmcenter as a regular user.

⁠pmcenter Settings
KeyTypeUser EditableDescription
APIKeyString✓Your Telegram bot's API key.
OwnerIDLong✓The owner's Telegram user ID.
EnableCcBoolean✓Decides whether cc feature is enabled or not.
CcArray✓Other users/groups/channels to receive forwarded messages.
AutoBanBoolean✓Decides whether the flood-banning feature is enabled or not.
AutoBanThresholdInt✓How many messages in 0.5m will be banned.
ForwardingPausedBoolean✓Decides whether the message forwarding is enabled or not.
KeywordBanningBoolean✓Decides whether the keyword banning feature is enabled or not.
KeywordAutoBanBoolean✓Automatically bans the matching user.
EnableRegexBoolean✓Enables regex matching in keywords banning or not.
AutoLangUpdateBoolean✓Allows the bot to automatically update language file after updating.
LangURLString✓URL to the updated language file.
DisableNotificationsBoolean✓Enable/Disable notifications.
EnableRepliedConfirmationBoolean✓Enable/Disable "reply successful" messages.
EnableForwardedConfirmationBoolean✓Enable/Disable "forwarded to owner" messages.
EnableAutoUpdateCheckBoolean✓Enable/Disable automatic update check.
UseUsernameInMsgInfoBoolean✓Decides whether to display user's nickname in message details or not.
AnonymousForwardBoolean✓Enable/Disable anonymous forwarding (BETA, text messages only)
DonateStringString✓Text to show when users send the /donate command. Leave empty to disable this feature.
LowPerformanceModeBoolean✓Tune pmcenter for low-end hardware like a Raspberry Pi.
DetailedMsgLoggingBoolean✓Enable/Disable detailed message information output.
UseProxyBoolean✓Use/Not to use SOCKS5 proxy.
ResolveHostnamesLocallyBoolean✓Use/Not to use remote server to resolve domain names.
CatchAllExceptionsBoolean✓Decides whether to forward all exceptions to the owner or not.
NoStartupMessageBoolean✓Enable/Disable "startup complete" messages.
ContChatTargetLong✕Target of Continued Conversation.
EnableMsgLinkBoolean✓Enable/Disable message links.
AllowUserRetractionBoolean✓Enable/Disable message retraction.
StatisticsStats✕Statistics data.
Socks5ProxiesArray✓List of SOCKS5 proxies.
BannedKeywordsArray✓Storage of banned keywords.
BannedArray✓Storage of banned users.
MessageLinksArray✕Storage of message links.
⁠Proxy Configuration
KeyTypeDescription
ServerNameStringServer hostname.
ServerPortIntServer port.
UsernameStringProxy user name.
ProxyPassStringProxy password.

Tip: After upgrades, you can send /saveconf command to the bot to fix missing new settings.

⁠Note
  • The variables like $1 in the Message_ReplySuccessful and other keys could be safely deleted, if you like.
  • Emojis are supported, and were used by default.
  • Currently the response of the /info command is unchangeable.
  • Familiar with another language? Pull requests are welcome!
  • 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.
⁠Changing File Location

On version 1.5.85.174 and later, pmcenter will check these two following environment variables on startup:

pmcenter_conf: pmcenter's configurations file's location.
pmcenter_lang: pmcenter's language file's location.

On these 3 scenarios, pmcenter will still use default location:

  • The environment variable doesn't exist.
  • The environment variable cannot be accessed.
  • File not found.

⁠Starting

After all these, you can start your own pmcenter safely by using this command:

dotnet pmcenter.dll

You can write a systemd service to keep it running, even after the host machine's rebooting.

⁠Commands

CommandAvailable toDescription
/startOwner, UsersDisplay start message.
/donateOwner, UsersDisplay donate information.
/infoOwnerDisplay the message's information. The command must be in reply to the target message.
/banOwnerRestrict the message's sender from contacting you again.
/banid <ID>OwnerRestrict a sender by his/her ID.
/pardonOwnerPardon the message's sender that you've banned before.
/pardonid <ID>OwnerPardon a sender by his/her ID.
/helpOwnerDisplay the help message.
/pingOwnerTest if the bot is working.
/switchfwOwnerSwitch message forwarding status.
/switchbwOwnerSwitch keyword banning status.
/switchnfOwnerSwitch notifications status.
/switchlang <URL>OwnerSwitch language file.
/switchlangcode [code]OwnerSwitch language file by language code.
/detectpermOwnerTest access to configurations.
/backupOwnerBackup configurations.
/editconf <CONF>OwnerManually edit configurations and translations w/ JSON-formatted text.
/saveconfOwnerManually save configurations and translations. Useful after upgrades.
/readconfOwnerReload configurations without restarting bot.
/resetconfOwnerReset configurations.
/uptimeOwnerGet system uptime info.
/updateOwnerCheck for updates and update bot if available.
/chkupdateOwnerOnly check for updates.
/catconfOwnerGet current configurations.
/restartOwnerRestart bot.
/statusOwnerGet host device's status.
/performOwnerStart performance test.
/testnetworkOwnerTest latency to servers used by pmcenter.
/chat [ID]OwnerEnter Continued Conversation mode with someone.
/stopchatOwnerLeave Continued Conversation.
/retractOwner, UsersRetract a message.
/clearmessagelinksOwnerClear message links.
/getstatsOwnerGet statistics data.

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

⁠Known Problems

⁠OpenSSL Compatibility Problem

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

When using older versions (earlier than PR #34443⁠ (14 Feb, 2019)) of .NET Core 2.1, which is incompatible with OpenSSL 1.1+, pmcenter will throw the following exception:

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. 
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. 
---> System.TypeInitializationException: The type initializer for 'SslMethods' threw an exception. 
---> System.TypeInitializationException: The type initializer for 'Ssl' threw an exception. 
---> System.TypeInitializationException: The type initializer for 'SslInitializer' threw an exception. 
---> Interop+Crypto+OpenSslCryptographicException: error:0E076071:configuration file routines:MODULE_RUN:unknown module name

As is mentioned in issue #33179⁠, there're several workarounds:

  1. Find openssl.cnf and comment out the ssl_conf = ssl_sect line.
  2. Upgrade to a newer (later than #34443) .NET Core 2.1 runtime.
  3. Install OpenSSL 1.0.

⁠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.

Tag summary

Content type

Image

Digest

Size

35 MB

Last updated

about 6 years ago

docker pull moderras/pmcenter