Async button click
This commit is contained in:
parent
fc5f2920a1
commit
d44e35f514
@ -60,13 +60,13 @@ trait CallHandler
|
|||||||
$this->datacenter->sockets[$new_datacenter]->writer->resume();
|
$this->datacenter->sockets[$new_datacenter]->writer->resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public function method_call($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false])
|
public function method_call($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false])
|
||||||
{
|
{
|
||||||
$promise = $this->method_call_async_read($method, $args, $aargs);
|
$promise = $this->method_call_async_read($method, $args, $aargs);
|
||||||
|
|
||||||
return $this->wait($promise);
|
return $this->wait($promise);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public function method_call_async_read($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false]): Promise
|
public function method_call_async_read($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false]): Promise
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@ namespace danog\MadelineProto\TL\Types;
|
|||||||
class Button implements \JsonSerializable, \ArrayAccess
|
class Button implements \JsonSerializable, \ArrayAccess
|
||||||
{
|
{
|
||||||
use \danog\Serializable;
|
use \danog\Serializable;
|
||||||
|
use \danog\MadelineProto\Tools;
|
||||||
private $info = [];
|
private $info = [];
|
||||||
private $data = [];
|
private $data = [];
|
||||||
|
|
||||||
@ -38,20 +39,30 @@ class Button implements \JsonSerializable, \ArrayAccess
|
|||||||
return ['data', 'info'];
|
return ['data', 'info'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function click($donotwait = false)
|
public function click($donotwait = false, $params = [])
|
||||||
{
|
{
|
||||||
|
if (is_array($donotwait)) {
|
||||||
|
$async = $donotwait;
|
||||||
|
} else {
|
||||||
|
$async = $params;
|
||||||
|
}
|
||||||
|
$async = isset($async['async']) ? $async['async'] : (isset($this->info['API']->wrapper) ? $this->info['API']->wrapper->async : true);
|
||||||
switch ($this->data['_']) {
|
switch ($this->data['_']) {
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
case 'keyboardButtonUrl':
|
case 'keyboardButtonUrl':
|
||||||
return $this->data['url'];
|
return $this->data['url'];
|
||||||
case 'keyboardButton':
|
case 'keyboardButton':
|
||||||
return $this->info['API']->method_call('messages.sendMessage', ['peer' => $this->info['peer'], 'message' => $this->data['text'], 'reply_to_msg_id' => $this->info['id']], ['datacenter' => $this->info['API']->datacenter->curdc]);
|
$res = $this->info['API']->method_call_async_read('messages.sendMessage', ['peer' => $this->info['peer'], 'message' => $this->data['text'], 'reply_to_msg_id' => $this->info['id']], ['datacenter' => $this->info['API']->datacenter->curdc]);
|
||||||
|
break;
|
||||||
case 'keyboardButtonCallback':
|
case 'keyboardButtonCallback':
|
||||||
return $this->info['API']->method_call('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'data' => $this->data['data']], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
$res = $this->info['API']->method_call_async_read('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'data' => $this->data['data']], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
||||||
|
break;
|
||||||
case 'keyboardButtonGame':
|
case 'keyboardButtonGame':
|
||||||
return $this->info['API']->method_call('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'game' => true], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
$res = $this->info['API']->method_call_async_read('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'game' => true], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return $async ? $res : $this->wait($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __debugInfo()
|
public function __debugInfo()
|
||||||
|
Loading…
Reference in New Issue
Block a user