Nehmen Sie die Eingabe vom Python -Skript zum Node.js Telegram Bot einPython

Python-Programme
Anonymous
 Nehmen Sie die Eingabe vom Python -Skript zum Node.js Telegram Bot ein

Post by Anonymous »

Ich möchte Eingaben aus dem Python -Skript im Telegramm -Bot eingeben, wenn der Benutzer ihn verlangt. Ich habe den Code geschrieben, um Eingaben aus dem Python -Skript zu nehmen, aber ich kann nicht herausfinden, wie man ihn in Telegram -Bot verwendet, umMessage < /p>
zu verwenden

Code: Select all

const TelegramBot = require('node-telegram-bot-api');
const token = process.env.TELEGRAM_TOKEN;
const bot = new TelegramBot(token, {polling: true});
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.listen(process.env.PORT);
app.post('/' + bot.token, (req, res) => {
bot.processUpdate(req.body);
res.sendStatus(200);
});
const {PythonShell} = require('python-shell');

let pyshell = new PythonShell('insight.py');

pyshell.on('message', function(message) {
console.log(message);
})

pyshell.end(function (err) {
if (err){
throw err;
};
});
bot.on('message', (msg) => {
var sendme = "Random Insight For Me";
if (msg.text.toString().toLowerCase().includes(sendme)){
bot.sendMessage(msg.chat.id, "I want To Trigger Output Here");
}
});

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post