Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
datahandler: add types
Browse files Browse the repository at this point in the history
  • Loading branch information
slmatthew committed Feb 13, 2020
1 parent 1e7ece0 commit d9f3de0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class DataHandler {
* @param string $type Type of data handling: "cb" (if you use Callback API) or "lp" (if you use Longpoll API). Default: "cb"
* @param BotEngine $be BotEngine class
* @throws TypeException
* @return void
* @return void
* @since v0.1
*/
public function __construct(string $type, $be) {
public function __construct(string $type, BotEngine $be) {
if($type == 'cb' && $GLOBALS['config']['type'] == 'community') {
// we need to handle request. Add in v0.2-alpha
ini_set('display_errors', 0);

$data = file_get_contents('php://input');
if(!is_null($data)) {
$data = @json_decode($data, true);
Expand All @@ -53,11 +55,11 @@ public function __construct(string $type, $be) {
* Longpolling
* @param BotEngine $be BotEngine class
* @param string $type Longpolling type: user or community
* @throws LongpollException
* @return void
* @throws LongpollException
* @return void
* @since v0.1
*/
public function startLp($be, string $type) {
public function startLp(BotEngine $be, string $type) {
if($type == 'community') {
$lp = call('groups.getLongPollServer', ['group_id' => $GLOBALS['config']['api_id']])['response'];
} elseif($type == 'user') {
Expand All @@ -81,7 +83,7 @@ public function startLp($be, string $type) {

if(!is_null($result)) {
if($li == 0) {
terminal("Started longpoll. Got first updates");
terminal("Longpoll successfuly started. Got first updates");
$li += 1;
}

Expand Down

0 comments on commit d9f3de0

Please sign in to comment.