Telegram 私聊機器人Telegram Private Message Chat Bot
本項目已進入隨緣更新狀態,如您對使用.NET沒有意見的話,可考慮使用pmcenter 作為PM機器人的解決方案
Warning: This bot is no longer under maintenance. You are better off with other solutions.
創建Telegram機器人,獲取Token
一台外面的服務器,安裝好Python和pip,並用pip安裝python-telegram-bot==11.1.0
Create a bot and get its token
Install Python and pip, then use pip to install python-telegram-bot==11.1.0
打開config.json並配置
{
"Admin" : 0 ,
"//1" : "管理员用户ID(数字ID)(可以先不设) " ,
"Token" : " " ,
"//2" : "机器人Token " ,
"Lang" : " zh " ,
"//3" : "语言包名称"
}如果在前一步未設置管理員用戶ID,第一個對機器人發送/setadmin的用戶將成為管理員,之後可通過修改config.json修改管理員
Open config.json and configure
{
"Admin" : 0 ,
"//1" : " Admin ID (A digital ID) " ,
"Token" : " " ,
"//2" : " Bot Token " ,
"Lang" : " en " ,
"//3" : " Language Pack Name (Be careful! It's 'en'!) "
} If you didn't set admin's ID previously, the user who sends /setadmin to the bot first will become the admin. You can edit config.json to change admin later.
替換main.py和lang文件夾,重新運行即可
Replace main.py and folder lang , then run main.py
python main.py
直接回復機器人轉發過來的消息即可回复,支持文字、貼紙、圖片、文件、音頻和視頻
Reply directly to the message forwarded by the robot to reply. You can reply text, sticker, photo, file, audio, voice and video.
部分轉發來的消息不便於查看發送者身份,可以通過回复該消息/info查詢
You can reply /info to the message which you want to get its sender's info more clearly.
向機器人發送指令/togglenotification可開啟/關閉消息發送提示
效果:
Send the command /togglenotification to the bot to enable/disable the message sending notification
Effect:
向一條消息回复/ban可禁止其發送者再次發送消息
向一條消息回复/unban或發送/unban <数字ID>可解除對此用戶的封禁
Reply /ban to a message to block the sender of the message from sending messages to you
Reply unban to a message or send /unban <User ID> to unban a user
| Command | 用途 |
|---|---|
| /ping | 確認機器人是否正在運行 |
| /setadmin | 設置當前用戶為管理員 |
| /togglenotification | 切換消息發送提示開啟狀態 |
| /info | 查詢用戶身份 |
| /ban | 封禁用戶 |
| /unban <數字ID (可選)> | 解封用戶 |
| Command | Usage |
|---|---|
| /ping | Check if the bot is running |
| /setadmin | Set the current user as admin |
| /togglenotification | Toggle message sending notification status |
| /info | Inquire sender identity |
| /ban | Ban a user |
| /unban <ID (optional)> | Unban a user |