Telegram WebHook query string - php

I wonder if there is a possibility to pass GET query string to a telegram bot backend using Webhook.
For example, when i share a link to my bot, e.g. t.me/mybot?param=value
Is there any way i can access a param=>value pair when receive webhook requests from Telegram on my backend whe the user enters a channel or type any commands?
P.S. looking for conceptual answers not an actual code. Thanks!

Related

Bot replying to app_mention event in the wrong channel

I'm trying to work with the slack Event Subscription app_mention, but I'm having some issues.
My backend is PHP, and I'm using this class.
Basically, what's happening is, if I have my bot user in multiple channels and someone mentions the bot, it will only reply in a single channel.
For example;
I have the bot user in 2 channels
bot-testing
development
If I # mention the bot in the development channel, it will send it's reply in the bot-testing channel.
My code used to send the message:
$client->to('#' . $event['channel'])->send("Hi. I'm currently under development.");
and my $event variable looks like this:
{"type":"app_mention","text":"<#UFT4EG0Q7> test","user":"UAKTRFH41","ts":"1548783398.055200","channel":"GAMED4PK5","event_ts":"1548783398.055200"}
but decoded obviously.
Why is my bot not replying in the correct channel?
So based on my reading of the PHP client you're using, that's designed for use with Incoming Webhooks.
Incoming Webhooks have a 1:1 relationship with a conversation/channel, so you can't define the destination for your message in the payload you send to the API.
If you want to do that, you could try using one of the other PHP SDKs built by the community.

Create a new Telegram bot

I'm writing a Wordpress plugin using a Telegram Bot to send notification to a channel.
I can send a command to my already created BOT in this way:
https://api.telegram.org/bot[token]/[command]
Is it possible to create a new BOT by code?
e.g. sending the following command or similar
https://api.telegram.org/bot[#BotFather]/newbot
Thanks
Enzo
Creating bots using the Telegram Bot API is currently not possible.
However, you could use the Telegram API which is generally used to make clients, to interact with Botfather. This would be way more complicated than a single HTTP request though.

PHP telegram API read group chat messages

Is it possible to create a PHP script which allows me to receive telegram messages out of group chat. I am following a group channel on Telegram with my personal account. The messages I receive needs to be processed by PHP. I know it is possible to create a bot, but can a bot do this? Is it able to join a channel/group and read all new messages?
I cannot find an answer to do so.
For example I'm in telegram.me/thisgroup. All the messages needs to be received by PHP and in the end stored in a database. The database part is not hard, but receiving it is.
Does somebody know how to?
Thanks!
It's possible by using bot API.
By default bots can't recive all messages. but you can change this setting.
here is the document about this: https://core.telegram.org/bots#privacy-mode
Create bot.
Change Privacy Mode of the Bot.
Add bot to group
Setup webhook to recive messages or use getUpdates method.
Store messages to your database.

Telegram problems with updates

I'm trying to create a simple bot for Telegram, I have settled the webhook correctly.
My problem is that I'm not able to get updates using file_get_contents("php://input"). I obtain the JSON object only if I use file_get_contents($mywebsite."/getUpdates"); and in that way I'm able to obtain the info of the chat.
Anyway I can send messages only if I reload my web page and not directly from the Telegram app.
How can I fix this problem?

how to call main telegram api methods in php

I want to use main telegram api to sign in and manage telegram account from php code.
I read telegram documents and read all last topics and related questions like:
Calling Telegram API to create a feedreader bot
Accessing Telegram API via web-based client
Using telegram API with PHP
Using telegram API with PHP
Telegram API send messages with php or javascript?
and .....
if your answer is " ... use bot api " or " ... use telegram cli " I should say it's not good answer for my problem!
I want sign in as different users account and manage them.
tnx a lot
1) get familiar with telegram API by studying existing source code.
2) Also write your own code to generate your Auth_key (see telegram api site)
3) build your own parser to handle conversion of byte streams into telegram types. you will need this to be able to interact with telegram servers
4) download a copy of webogram and run it locally with console.logs embedded in the JavaScript, particularly in the mtproto.js and other here: webogram\app\js\lib\
This might help https://stackoverflow.com/a/32809138/44080

Categories