0
0
0xbadc0ffee2020-09-03 06:55:30
Python
0xbadc0ffee, 2020-09-03 06:55:30

Is it possible to make more than 1 pytelegrambotapi webhook?

There is a tg bot. One part of it is implemented through winwinbot (the webhook responsible for the mailing), and the other needs to be written. Since the bot already has a webhook, the bot cannot receive server responses via bot.polling(), an error pops up

Conflict: can\'t use getUpdates method while webhook is active
.

Is it possible to make a bot with two webhooks?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shurshur, 2020-09-04
@shurshur

It is forbidden. And how do you imagine it? Will a user receive two contradictory responses to one message?

A
Albert Zuev, 2020-09-05
@nalinor

You can use a crutch: set the address of a webhook that will send messages to other addresses. PHP code example:

<?php
$webhooks = array(
    'https://example.com/webhook1',
    'https://example.com/webhook2',
    // Здесь указываете адреса других вебхуков
);

$data = file_get_contents('php://input');
$lendata = strlen(data);

foreach ($webhooks as $url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . $lendata,
    ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_exec($ch);
    curl_close($ch);
}

?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question