Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Telegram Bot Javascript
#3
Natürlich Big Grin 
Hier ein ein paar ausschnitte , leider nicht von allen Dateien ^^ wäre sonst zu viel:

package-lock.json:

"name": "product_googlesheets",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "@types/node": {
      "version": "14.14.21",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.21.tgz",
      "integrity": "sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A==",
      "optional": true
    },
    "@types/yauzl": {
      "version": "2.9.1",
      "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz",
      "integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==",
      "optional": true,
      "requires": {
        "@types/node": "*"
      }
    },
    "abort-controller": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",




index.js:

const util = require('util')

require('dotenv').config()

process.on('uncaughtException', function (err) {
    console.log('Caught exception: ', err)
})

process.on('unhandledRejection', (error, promise) => {
    console.log('Forgot to handle a promise rejection here: ', promise)
    console.log(error)
})

var log_file = fs.createWriteStream(__dirname + '/main.log', {
    flags: 'w'
})
var log_stdout = process.stdout

let getDateTime = () => {
    let date = new Date()
    let hour = date.getHours()
    hour = (hour < 10 ? "0" : "") + hour

    let min = date.getMinutes()
    min = (min < 10 ? "0" : "") + min

    let sec = date.getSeconds()
    sec = (sec < 10 ? "0" : "") + sec

    let year = date.getFullYear()

    let month = date.getMonth() + 1
    month = (month < 10 ? "0" : "") + month

    let day = date.getDate()
    day = (day < 10 ? "0" : "") + day

    return year + "." + month + "." + day + ". " + hour + ":" + min + ":" + sec
}

console.log = function (d) {
    let currentTime = '[' + getDateTime() + '] '



bot.js:

const Telegraf = require('telegraf')
const Telegram = require('telegraf/telegram')
const session = require('telegraf/session')
const block = require('./manager/block')


const bot = new Telegraf(process.env.token)

const telegram = new Telegram(process.env.token)

bot.use(session())

bot.launch()
console.log('Bot started.')

bot.use(async (ctx, next) => {
    //if(!ctx?.from?.username) return
    if (ctx.from && ctx.from.id && block.isBlocked(ctx.from.id)) return
    next()
})

module.exports = {
    bot,
    telegram


wie gesagt , sind nur ein paar Auszüge , bin für jede Hilfe SEHR SEHR DANKBAR Wink Wink
Zitieren


Nachrichten in diesem Thema
Telegram Bot Javascript - von PalaAzab - 04.11.2022, 02:40
RE: Telegram Bot Javascript - von rzscout - 04.11.2022, 18:54
RE: Telegram Bot Javascript - von PalaAzab - 04.11.2022, 19:02
RE: Telegram Bot Javascript - von rzscout - 05.11.2022, 19:19
RE: Telegram Bot Javascript - von PalaAzab - 06.11.2022, 04:32

Gehe zu:


Benutzer, die gerade dieses Thema anschauen:
1 Gast/Gäste