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
1
vote
0 answers

PHP - Bot Telegram - Post message in Channel and then post comment/reply to the linked Discussion group

Summary I want to achieve this scenario: My Telegram bot (written in PHP, using Telegram Bot API) posts a message in a Channel. the message is being autoposted at linked Discussion group THE TASK: I want my bot to auto post first comment (reply) to…
ram108
  • 41
  • 5
1
vote
2 answers

How I can send message at at a specific time in Telegram bots using PHP?

I want to program a telegram bot (using PHP) that sends messages at a specific time. So if I did this : $time = date('h:i a'); if($time == "12:00 pm"){ then send a message or audio or whatever is going to do } The question is will the file on my…
YK20
  • 11
  • 2
1
vote
1 answer

initialize Laravel project for Telegram Bot with sail

I created a project on the server using Laravel sail and I wanna use this project for Telegram Bot as a web hook. I have a domain and the domain is connected to the IP server. So far so good. But since I just started Docker and i'm newbie, I had…
Ho3inPgmer
  • 13
  • 3
1
vote
2 answers

Telegram bot keyboard resize_keyboard in php

I am working on a telegram bot using php, I want to resize my ReplyKeyboardMarkup button to fit each of the keyboards. I want the first button to take the full width of the keyboard and the second and fourth button takes the middle then I want the…
Emem Edem
  • 21
  • 1
  • 5
1
vote
0 answers

Longman telegram bot clone message

I'm trying to create a command replying a message. When you write /share replying a message the bot have to clone the message and send in to me in pvt. My problem is that I want to manage all type of messages [ also photos, documents, contact and…
Shyghar
  • 313
  • 4
  • 19
1
vote
0 answers

Parse error: Unexpected $THIS (T_VARIABLE)

I don`t now much about PHP and trying to run a Telegram bot but i get this error Parse error: syntax error, unexpected '$this' (T_VARIABLE) on line 101 $me = yield $this->get_self(); $userID = isset($update['message']['from_id']) ?…
AwJ
  • 33
  • 8
1
vote
1 answer

How to use editMessageCaption correctly in php Telegram Bot?

I want to edit caption of photo, but Im getting error Bad Request: message to edit not found Code : getData(); $text = $result['message']…
aman_49
  • 116
  • 10
1
vote
0 answers

Logging http error codes (500, 504) in telegram chat with bot

I have site that working with yii2 and nginx, send information from site pages to the chat in telegram with bot. Sometimes site can't load page or have troubles with something else. The task is that bot need text to chat, have problem HTTP:CODE, I…
Daizygod
  • 32
  • 1
  • 3
1
vote
1 answer

How to create inline URL button in telegram via telegram bot using PHP?

I want to send a message with url button to my telegram channel using telegram bot. I have string msg = "Hello, Welcome To My Telegram Channel" imageURL = "https://cdn.pixabay.com/photo/2020/08/11/14/34/greeting-5480092_1280.png" buttonUrl =…
rdbhandari
  • 71
  • 7
1
vote
1 answer

Fetching all participants of a Telegram channel

Using the Madelineproto PHP library how can one fetch the list of all participants. Here is a code snippet that fetches the list of recent participants. $participantsInfo = $telegramClient->channels->getParticipants([ 'channel' =>…
qwertynik
  • 118
  • 2
  • 10
1
vote
2 answers

how can i ban some numbers from checking on bot

like if someone type command "!user 123456" then send message "number banned" I tried this but won't worked... $ban = array('112233','123456'); if(strpos($message, "!user $ban") ===0){ sendMessage($chatId, "Number Banned!", $message_id); }
Wiker Bem
  • 29
  • 3
1
vote
0 answers

Handling users message input in row with callback query in telegram bot on pure php

I faced the problem with handling of user message inputs in telegram bot. I'm writing telegram bot on php without any libraries. Bot receives information from telegram via webhook and two switch-case are handling messages and callback_query. Short…
Akim
  • 41
  • 5
1
vote
1 answer

Automatic post comments on Telegram

I searched a lot but I didn't found what I'm looking for, Is that possible to make Telegram Bot that can detect some words in posts and attach comment if it's match the desired words??? If yes, plz provide some resources
1
vote
1 answer

catching event of deleting a groupe-chat in telegram bot api

I'm rellay happy with that community here. I found many answers in different cases. But this time I don't find one. So maybe someone can help me? I'm working on a telegram bot using php and webhook updates. I track if my bot is added in a group chat…
1
vote
2 answers

To send a message with a delay in PHP (without "sleep" function)

Trying to make a dice-roll function in my telegram bot. How it works right now: When a user sends "roll" bot replies with sendDice method and sends another message with result like "you rolled 5, you won and blah-blah .." > how it looks < The…