Bot
in package
Tags
Table of Contents
Constants
- DB_LOCATION = __DIR__ . "/../db"
Properties
- $db_stores : array<string|int, mixed>
- $instance : Bot
- $api_url : string
- $bot_token : string
- $callback : array<string|int, mixed>|null
Methods
- __construct() : mixed
- check_for_messages() : void
- get_file() : string|null
- has_access_to_chat() : bool
- send_audio() : bool
- send_custom_request() : mixed
- send_document() : bool
- send_message() : bool
- send_photo() : bool
- send_video() : bool
- send_voice() : bool
- set_callback() : void
- unset_callback() : array<string|int, mixed>|null
- get_updates() : array<string|int, mixed>
- store_message() : void
- call_message_callback() : void
- get_message_type() : string
- is_token_valid() : bool
- process_updates() : void
- save_chat_to_db() : void
- setup_database() : bool
- store_user() : void
Constants
DB_LOCATION
public
mixed
DB_LOCATION
= __DIR__ . "/../db"
Properties
$db_stores
public
static array<string|int, mixed>
$db_stores
= array()
$instance
public
static Bot
$instance
$api_url
protected
string
$api_url
$bot_token
protected
string
$bot_token
$callback
protected
array<string|int, mixed>|null
$callback
= null
Methods
__construct()
public
__construct(string $bot_token) : mixed
Parameters
- $bot_token : string
check_for_messages()
public
check_for_messages() : void
Tags
get_file()
public
get_file(string $file_id) : string|null
Parameters
- $file_id : string
Tags
Return values
string|nullhas_access_to_chat()
public
has_access_to_chat(string $chat_id) : bool
Parameters
- $chat_id : string
Tags
Return values
boolsend_audio()
public
send_audio(string $chat_id, string $audio[, array<string|int, mixed> $params = array() ]) : bool
Parameters
- $chat_id : string
- $audio : string
-
Audio url or audio id.
- $params : array<string|int, mixed> = array()
-
(Optional) Additional parameters.
Tags
Return values
boolsend_custom_request()
public
send_custom_request(string $method, array<string|int, mixed> $params) : mixed
Parameters
- $method : string
- $params : array<string|int, mixed>
Tags
send_document()
public
send_document(string $chat_id, string $file[, array<string|int, mixed> $params = array() ]) : bool
Parameters
- $chat_id : string
- $file : string
-
File url or file id. Sending a file url is not recommended and only works with GIF, PDF, and ZIP files.
- $params : array<string|int, mixed> = array()
-
(Optional) Additional parameters.
Tags
Return values
boolsend_message()
public
send_message(string $chat_id, string $message[, array<string|int, mixed> $params = array() ]) : bool
Parameters
- $chat_id : string
- $message : string
- $params : array<string|int, mixed> = array()
-
(Optional) Additional parameters.
Tags
Return values
boolsend_photo()
public
send_photo(string $chat_id, string $photo[, array<string|int, mixed> $params = array() ]) : bool
Parameters
- $chat_id : string
- $photo : string
-
Photo url or photo id.
- $params : array<string|int, mixed> = array()
-
(Optional) Additional parameters.
Tags
Return values
boolsend_video()
public
send_video(string $chat_id, string $video[, array<string|int, mixed> $params = array() ]) : bool
Parameters
- $chat_id : string
- $video : string
-
Video url or video id.
- $params : array<string|int, mixed> = array()
-
(Optional) Additional parameters.
Tags
Return values
boolsend_voice()
public
send_voice(string $chat_id, string $voice[, array<string|int, mixed> $params = array() ]) : bool
Parameters
- $chat_id : string
- $voice : string
-
Voice url or voice id.
- $params : array<string|int, mixed> = array()
-
(Optional) Additional parameters.
Tags
Return values
boolset_callback()
public
set_callback(string|array<string|int, mixed> $callable[, string|null $criteria = null ]) : void
Parameters
- $callable : string|array<string|int, mixed>
- $criteria : string|null = null
Tags
unset_callback()
public
unset_callback([string|null $criteria = null ]) : array<string|int, mixed>|null
Parameters
- $criteria : string|null = null
Tags
Return values
array<string|int, mixed>|nullget_updates()
protected
get_updates([int $offset = null ][, int $limit = 100 ][, int $timeout = 0 ][, array<string|int, mixed> $allowed_updates = array("message") ]) : array<string|int, mixed>
Parameters
- $offset : int = null
-
Defaults to only new updates
- $limit : int = 100
- $timeout : int = 0
- $allowed_updates : array<string|int, mixed> = array("message")
-
Check https://core.telegram.org/bots/api#update for more information.
Tags
Return values
array<string|int, mixed>store_message()
protected
store_message( $message) : void
Parameters
Tags
call_message_callback()
private
call_message_callback(stdClass $message) : void
Parameters
- $message : stdClass
Tags
get_message_type()
private
get_message_type( $message) : string
Parameters
Tags
Return values
stringis_token_valid()
private
is_token_valid() : bool
Tags
Return values
boolprocess_updates()
private
process_updates(array<string|int, mixed> $updates) : void
Parameters
- $updates : array<string|int, mixed>
Tags
save_chat_to_db()
private
save_chat_to_db(stdClass $message) : void
Parameters
- $message : stdClass
Tags
setup_database()
private
setup_database() : bool
Tags
Return values
boolstore_user()
private
store_user(mixed $from) : void
Parameters
- $from : mixed