my telegram bot keeps sending messages endlessly

Related searches

I Started programming a telegram bot and I've got a problem. when I send /start command it sends me a welcome message (as i programmed it) but it doesn't sends it once! it keeps sending it endlessly like loop! this is the source:


function makereq($method,$datas=[])
    $url = "".API_KEY."/".$method;
    $ch = curl_init();
    $res = curl_exec($ch);
        return json_decode($res);

$website = "".API_KEY;

$update = json_decode(file_get_contents('php://input'));

$chat_id = $update->message->chat->id;
$message_id = $update->message->message_id;
$from_id = $update->message->from->id;
$name = $update->message->from->first_name;
$username = $update->message->from->username;
$textmessage = isset($update->message->text)?$update->message->text:'';
$reply = $update->message->reply_to_message->forward_from->id;
$stickerid = $update->message->reply_to_message->sticker->file_id;
$messageEntity = $update->messageentity->type;

function SendMessage($ChatId, $TextMsg)
if($textmessage == '/start')
  SendMessage($chat_id,'<welcome message>');


You're probably using webhook. If you don't respond with a http status 200 the telegram bot API thinks something is wrong with your server and requests again every few seconds as mentioned in the API documentation:

In case of an unsuccessful request, we will give up after a reasonable amount of attempts.

So just add header("HTTP/1.1 200 OK"); to your script and voilà! (If your php version is greater than 5.4 you can use http_response_code(200); )

Bot server keeps sending same message � Issue #159 , Using webhook, bot server keeps sending same message over and over again. again, the messages started like the bot server is in an endless loop. Is there any way to send command through to delete cache of messages on so I'm hoping I'll be able to figure something out on my own. Getting your Chat id. On Telegram, search your bot (by the username you just created), press the “Start” button or send a “/start” message Open a new tab with your browser, enter https

If you are polling with getUpdates, you need to increment your offset.

offset = 1 + latest_update_id

IF you are using WebHooks ... update_id

The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order.

Message keeps sending � Issue #1429 � python-telegram-bot/python , run the bot using script above (replace the token with your personal); Open latest version of official telegram app on any iPhone; send message� In this tutorial, we’re going to build a telegram bot ,and send messages to a group with a simple HTTP request. to get start lets create a new telegram bot with, it's own API Botfather. One Bot To Rule Them All so go to telegram app on your phone, or log in with telegram web. and then search for bot father. create a new bot /newbot

As Yoily L said, you gotta return 200 before telegram thinks the request has failed.

You may use fastcgi_finish_request() to flush response data to the client.


// continue execution, send messages and whatever

Also, notice what tuxrampage commented in the docs:

The script will still occupy a FPM process after fastcgi_finish_request(). So using it excessively for long running tasks may occupy all your FPM threads up to pm.max_children. This will lead to gateway errors on the webserver.

Another important thing is session handling. Sessions are locked as long as they're active (see the documentation for session_write_close()). This means subsequent requests will block until the session is closed.

You should therefore call session_write_close() as soon as possible (even before fastcgi_finish_request()) to allow subsequent requests and a good user experience.

This also applies for all other locking techniques as flock or database locks for example. As long as a lock is active subsequent requests might bock.

You'll probably want to check

if (is_callable('fastcgi_finish_request')) {

More info in related question: continue processing php after sending http response

[PDF] Python Telegram Bot Documentation, 0 - retry indefinitely (default) Holds the handlers per group. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width toxt to show bold, italic, fixed-width toxt or URLs in your bot's message. Cool Tip: Send emails through SMTP server using telnet from the Linux command-line interface! Read more → Telegram Bot API: Send Message. Below i will show the examples of how to send a message through the Telegram API using a web-browser, curl and a Bash script. Web-Browser. To send the “Hello World” message using a web-browser, just

When my Telegram-bot keeped sending messages, I created a table of recording posts in the database. When I am sending a post in my Telegram-bot, written in PHP alghorythm checks if a new post already exists in the database: * if it does, we stop the process of sending the post; * if it doesn't, we continue sending it in Telegram. The described method allows to stop cycle of sending the post again and again.

Anonymous telegram bot, Choose from the below telegram bitcoin bots list and click on link the link to join directly. Receive anonymous messages from your friends. io, An Instant Crypto -crypto This is a free opt-in feature that will send some data to our server . io is a altcoin intelligence bot that constantly monitors altcoin markets and generates� If you want to schedule reminders, due date warnings, or timed blessing messages, there's an easy way to do this. The scheduling feature is fast and simple to learn. When you know how to do it, you can start batch-sending messages on Telegram. Don't Miss: Send Silent Telegram Messages to Avoid Disturbing Friends; Scheduling Texts

Telegram robot due to the structure of hooks and sending and receiving messages in specified time formats It is very sensitive to time. I had the same problem and found that using the date_default_timezone_set function This will solve the problem after deleting this function. If you have changed time templates in your code, delete them.

Developing Secure Bots Using The Telegram APIs, Telegram bots are almost endlessly open-ended. This is how Telegram keeps track of code written for a particular bot. or adding some kind of randomized texts to make your bot more interesting. set.php: registers your link to hook.php so that Telegram knows where to send your updates; unset.php:� However, the steps to delete a Telegram bot might not be that straightforward and many Telegram users decide to delete Telegram account to get rid of these bots! One thing that you might have faced as a Telegram user is that these bots keep on sending message and inviting you to channels even if you no longer use them.

Here’s a practical example how to send a message to a Telegram channel using a Telegram Bot and the HTTP bot sendMessage API. In order to be able to do so, you will have to the following: Create a Telegram public channel (we’ll make this private later) Create a Telegram BOT via BotFather; Set the bot as administrator in your channel

Q: A bot is sending me messages, how do I make it stop? If you don't want a bot to send you messages, feel free to block it – same as you would block a human user. Some Telegram clients have a 'Stop Bot' button right in the bot's profile. That said, most bot developers offer commands that silence the bot, check its /help for clues. Q: Are

Messages that start with a slash are always passed to the bot (along with replies to its messages and messages that @mention the bot by username). Telegram apps will: Suggest a list of supported commands with descriptions when the user enters a '/' (for this to work, you need to have provided a list of commands to the BotFather ).

  • are you using webhooks or are you polling?
  • I'm using webhooks
  • ok so for webhook how should I do the increment ? just $result ['update_id'] = ++$update; ? @CharlesOkwuagwu
  • you can ignore repeated update ids Telegram will simply send you latest set of updates. you don't need to do anything, if you get a repeated update_id, simply ignore