Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many replies to callback #403

Closed
Troodi opened this issue May 31, 2017 · 12 comments
Closed

Many replies to callback #403

Troodi opened this issue May 31, 2017 · 12 comments

Comments

@Troodi
Copy link

Troodi commented May 31, 2017

$keyboard = Keyboard::make()
->inline()
->row(
	Keyboard::inlineButton(['text' => 'Btn 1', 'callback_data' => 'test']),
	Keyboard::inlineButton(['text' => 'Btn 2', 'callback_data' => 'data_from_btn2'])
);
$response = $telegram->sendMessage([
	'chat_id' => $chat_id, 
	'text' => 'Hello World',
	'reply_markup' => $keyboard
]);
$update = $telegram->getWebhookUpdate();
	if ($update->isType('callback_query')) {
		$query = $update->getCallbackQuery();
		$data  = $query->getData();
		$chid = $query->getFrom()->getId();
		$telegram->sendMessage([ 'chat_id' => $chid, 'text' => $data]);
	}

screenshot_1

@ghost
Copy link

ghost commented Jun 1, 2017

@Troodi

I've got some problems on importing the keyboard class, could you show me your complete code?

@Troodi
Copy link
Author

Troodi commented Jun 1, 2017

Use 3.x-dev version

@Troodi
Copy link
Author

Troodi commented Jun 1, 2017

use Telegram\Bot\Api;
use Telegram\Bot\Keyboard\Keyboard;

@ghost
Copy link

ghost commented Jun 1, 2017

Sad to see, I tried to use it inside laravel, but it seems like the dev version is buggy as hell for laravel :/.

@Troodi
Copy link
Author

Troodi commented Jun 1, 2017

if ($result->isType('callback_query')) {
		$query = $result->getCallbackQuery();
		$data  = $query->getData();
		$chid = $query->getFrom()->getId();
		$json = json_decode($query->getMessage(), true);
		$telegram->sendMessage([ 'chat_id' => $chid, 'text' => 'Тестирование' ]);
		exit;
	}

It helped, but how to remove the time icon?
screenshot_1
The message was sent, but it still hangs.

@irazasyed
Copy link
Owner

@Troodi When you use webhook, you need to send header status code 200. If you don't do that, then Telegram assumes your server has not accepted their update.

You can just return something like "ok". And it should automatically send 200 code.

@Troodi
Copy link
Author

Troodi commented Jun 1, 2017

Thx, but clock icon not hide.

@jonnywilliamson
Copy link
Contributor

@ja-heller Sorry that you think that.

It really isn't. I'm using it live here for weeks and it's very stable. It is however undocumented, because so much changed in the code and so your 2.xx code just isn't going to work.

Either wait until 3 is released fully with docs, or install it dig into the code until we get it done.

@ghost
Copy link

ghost commented Jun 2, 2017

@jonnywilliamson

Take a look into this this.

@Troodi Troodi closed this as completed Feb 22, 2018
@illiamorkva
Copy link

Has anyone solved the problem with the clock icon?

@Rattone
Copy link

Rattone commented Sep 19, 2018

@illiamorkva you have to call answerCallbackQuery and pass callback_id to it

 $update = Telegram::getWebhookUpdates();
 $query = $update->getCallbackQuery();
 $this->callback_id = $query->getId();

Telegram::answerCallbackQuery([
    'callback_query_id' => $this->callback_id
]);

@illiamorkva
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants