Node.js电报Bot API
与官方交互的Node.js模块。
安装
npm i node-telegram-bot-api
用法
const TelegramBot = require ( 'node-telegram-bot-api' ) ;
// replace the value below with the Telegram token you receive from @BotFather
const token = 'YOUR_TELEGRAM_BOT_TOKEN' ;
// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot ( token , { polling : true } ) ;
// Matches "/echo [whatever]"
bot . onText ( / \/ echo ( . + ) / , ( msg , match ) => {
// 'msg' is the received Message from Telegr
1