Questions tagged [php-telegram-bot]

The telegram Bots are applications that can be used via telegram chat, the interaction is via Messages. The realization of these bots with PHP simplifies the work of a developer.

It is implemented by API and HTTP-based interface has all the methods of bot telegram (https://stackoverflow.com/tags/telegram-bot/info).

A simple way of use is:

define('BOT_TOKEN', '<YOUR-TOKEN>');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
define('FILE_URL', 'https://api.telegram.org/file/bot'.BOT_TOKEN.'/');

$content = file_get_contents("php://input");
$update = json_decode($content, true);

$message = isset($update['message']) ? $update['message'] : "";
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
$text = isset($message['text']) ? $message['text'] : "";

header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId, "text" => 'you wrote: '.$text);
$parameters["method"] = "sendMessage";
341 questions
3
votes
1 answer

Telegram Bot - Cannot remove custom keyboard using PHP

please help me. I added a custom keyboard via reply_markup like this: $reply_markup = array( 'keyboard' => array( array( array( 'text' => 'Click here to upload contact…
Dika
  • 2,213
  • 4
  • 33
  • 49
3
votes
1 answer

Can i detect my bot's groups with Telegram bot api

Can i detect if my bot was added to group or get list groups where my bot included? Is it possible? My version is forward message from group to my bot and get chat id from message, but I think it's not best solution
pembrock
  • 113
  • 1
  • 10
3
votes
1 answer

Do telegram chat IDs stay the same when converting to a supergroup?

On Telegram, every group has a chat-id that my bot saves whenever it is added to a group. If an owner of a group converts it to a supergroup, will the ID of the group change? And if it does, how can we get the new chat-id for the group? I've…
3
votes
0 answers

Telegram chat and welcome message

Could you tell me how to create welcome message in telegram chat, which visible only for invited user(newbie). Now bot is created and invited in group. When to login "newbie", chat-bot send welcome-message(for all users). $chat = $message['chat']; …
user2969890
  • 381
  • 1
  • 4
  • 11
3
votes
3 answers

Telegram api. Get all uploaded photos by media_group_id

I send to my telegram bot a few photos as group. How I can get the file_id all of my uploaded photos? I use webhooks, but response is not contain any data about all photos, just some data about last uploaded photo and media_group_id. How I can get…
3
votes
2 answers

Use session for Telegram bot webhook

I'm try to make a Telegram bot that'll connect to an RCON, but at the moment I'm stuck in the usage of the sessions, seems like they aren't saved. This is my code so far:
Mattia
  • 5,909
  • 3
  • 26
  • 41
3
votes
1 answer

Telegram sends lots of duplicates

I know this is a duplicate of Telegram sends duplicate POST JSON requests to webhook and Telegram sends duplicate POST JSON requests to webhook. However, there wasn't any adequate answer to this question, so: I have a PHP app handling webhook…
3
votes
2 answers

How to get message info by ID [Telegram API]

I'm writing bot for telegram to gather some stats from group chat. I need to get info about every message (from the beginning of chat). I know how can i do it, but it's a quite bad idea. I can use forwardMessage method, but i need second acc for it…
3
votes
1 answer

telegram botfather doesn't allow making more bots

I'm trying to make telegram bot .I have made 20 bot so far and now when I select newbot from bot father it says this : " That I cannot do. You come to me asking for more than 20 bots. But you don't ask with respect. You don't offer friendship. You…
tebodrithu
  • 31
  • 3
3
votes
4 answers

Can the Telegram bot API play sound from an online audio streaming URL?

Telegram BOT API has functions to send audio files and documents ,But can it play from an online sound streaming URL?
Codeformer
  • 2,060
  • 9
  • 28
  • 46
3
votes
2 answers

Why the file id, in telegram bot, not work after some days?

I am using telegram API and create php telegram bot. For sending video file with sendVideo method, use file_id like BAADBAADbwADhd7gCEpUooz4V5Q1Ag. But after some days this file_id not worked and I have to upload this video file again. What is the…
amin roshani
  • 389
  • 4
  • 11
3
votes
1 answer

How to get Chat ID & Text in Telegram?

When I use file_get_contents function in PHP to get UPDATES of my Telegram Bot, I know how to get first Chat ID or Text But this page is not just for a one user & every user that types a text, comes to this page. Also every user has its Chat ID &…
user6571878
2
votes
1 answer

How to handle inline keyboard click in irazasyed/telegram-bot-sdk?

I was building a Telegram bot on Laravel using the library irazasyed/telegram-bot-sdk. I created inline buttons, but couldn't know how to handle click events. Here is my code:
Ayenew Yihune
  • 1,059
  • 13
  • 19
2
votes
0 answers

Open chat and send message with tg://

I want open a telegram chat and send a designated message to a designated chat_id I tried this but it just opens chat without message : tg://openmessage?user_id=1315949751&msg?text=AnyText Is there a way to do that ?
MohAmMAD
  • 21
  • 1
  • 4
2
votes
0 answers

Telegram bot webhook returns user identifier id as null

I am working on a telegram bot and set up a webhook to store chat id of users into my laravel app's DB. I was getting the chat id previously but today, I getting NULL. I am using ngok for https to work with webhooks. When webhook is deleted and I…
1 2
3
22 23