惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
T
Threatpost
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
C
CERT Recently Published Vulnerability Notes
V
Vulnerabilities – Threatpost
Help Net Security
Help Net Security
Project Zero
Project Zero
博客园 - 聂微东
博客园_首页
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
Latest news
Latest news
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
C
Cyber Attacks, Cyber Crime and Cyber Security
A
Arctic Wolf
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
F
Full Disclosure
Recent Announcements
Recent Announcements
SecWiki News
SecWiki News
C
Cybersecurity and Infrastructure Security Agency CISA
F
Fortinet All Blogs
The Hacker News
The Hacker News
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
The GitHub Blog
The GitHub Blog
量子位
Hugging Face - Blog
Hugging Face - Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Palo Alto Networks Blog
T
Troy Hunt's Blog
O
OpenAI News
T
Threat Research - Cisco Blogs
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tenable Blog

噜啦 - telegram

CentOS 7 搭建私聊 Telegram Bot
Debian 9 搭建私聊 Telegram Bot
博主: 噜啦 · 2019-02-26 · via 噜啦 - telegram

最近看到了Github上面一个开源的项目 PmCenter ,可以通过此项目来搭建一个私聊Bot,解决+86用户不能私聊的问题

此教程仅在Vultr Debian 9 测试通过,不保证其他Linux系统的可用性,不建议使用minimal系统,精简得太厉害



更新了CentOS 7 x64的教程,更加简单,可能是这篇写复杂了,嘻嘻



安装 NET Core SDK

更新以及安装组件

apt-get update && apt-get install unzip curl sudo libunwind8 gettext apt-transport-https

注册产品密钥以及产品源

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/dotnetdev.list'

Install NET Core SDK

sudo apt-get update && sudo apt-get install dotnet-sdk-2.0.0

将 dotnet 添加到 PATH

export PATH=$PATH:$HOME/dotnet

检查是否安装成功

dotnet --version

出现

root@Lula:~# dotnet --version
2.0.0

即安装成功


安装.NET Core Runtime

注册Microsoft密钥和订阅源

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

Install .NET Runtime

sudo apt-get update && sudo apt-get install aspnetcore-runtime-2.2

运行 pmcenter 机器人

拉取源码

mkdir pmcenter
cd pmcenter
wget https://ci.appveyor.com/api/projects/Elepover/pmcenter/artifacts/pmcenter.zip
unzip pmcenter.zip

运行

dotnet pmcenter.dll

第一次运行将会在/root/pmcenter目录下生成pmcenter.json配置文件,修改APIKeyOwnerID以及LangURL后其他使用默认配置即可

配置文件说明

APIKey是Bot的密钥,Botfather里面可以查看
OwnerID为主人TG账号的ID,第三方的TG(Plus message)可以看到,不要弄错了
LangURL是语言文件地址

两份汉化语言文件地址:

正常一点的
https://raw.githubusercontent.com/Elepover/pmcenter/master/locales/pmcenter_locale_zh.json

萌哒哒的
https://raw.githubusercontent.com/Elepover/pmcenter/master/locales/pmcenter_locale_zh.meow.json

设置pmceter开机自启

Debian 9是带有rc.local服务,但是不带/etc/rc.local文件

手工添加一个/etc/rc.local文件


cat <<EOF >/etc/rc.local
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    cd /root/pmcenter && dotnet pmcenter.dll
    exit 0
    EOF

然后赋予权限

chmod +x /etc/rc.local

启动接着rc-local服务

systemctl start rc-local

查看状态

systemctl status rc-local

机器人开启后,与Bot的对话中输入/help查看帮助信息

赞赏作者

如果觉得我的文章对你有用,请随意赞赏