Skip to content

madmagestelegram/Types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Types

Representaion of telegram bot types in php classes. Generated by madmagestelegram/TypesGenerator.

Install

composer require madmagestelegram/types

Usage

Simplest usage is getting and setting data

$message = new Message();
$message->setText('Hello world!');

echo $message->getText(); // "Hello world!"
// as assoc array
print_r($message->_getData());// ['text' => 'Hello world!']

more fields

$message = ( new Message() )
        ->setMessageId(1)
        ->setDate(time())
        ->setChat(( new Chat() )->setId(1)->setType('channel'))
        ->setText('Hello world!')
        ->setAudio(
            ( new Audio() )
                ->setFileId("1")
                ->setDuration(60)
                ->setTitle('Some title')
                ->setThumb(( new PhotoSize() )
                    ->setFileId("1")
                    ->setHeight(100)
                    ->setWidth(100)
                )
        )->setLocation(
            ( new Location() )
                ->setLatitude(60.60)
                ->setLongitude(60.60)
        );

    print_r($message->_getData());
    
/*
    
Array
(
    [message_id] => 1
    [date] => 1570945477
    [chat] => Array
        (
            [id] => 1
            [type] => channel
        )

    [text] => Hello world!
    [audio] => Array
        (
            [file_id] => 1
            [duration] => 60
            [title] => Some title
            [thumb] => Array
                (
                    [file_id] => 1
                    [width] => 100
                    [height] => 100
                )

        )

    [location] => Array
        (
            [longitude] => 60.6
            [latitude] => 60.6
        )

)
*/