elwahab/telegram

For telegram bot package

v1.1.3 2020-05-09 21:32 UTC

This package is auto-updated.

Last update: 2024-11-10 07:39:09 UTC


README

This package will help you simplify your work with Telegram Api.

Telegram Api package

Installation

Installation takes place in the console using the command:

composer require elwahab/telegram

It may be noted that you must have a composer.

How I can use this? Quick start

After installing the package, you just need to connect the packages as follows

<?php

use ELWAHAB\Telegram;


$telegram = new Telegram(BOT_TOKEN);

$telegram->sendMessage(CHAT_ID, 'Message');

What method can I use?

sendMessage

Method for send message to your peer. This method get paraments:

  • chat_id integer | id user what get message;
  • text _string | message to chat_id_;
  • markdown option string | Send message with markdown or html (Default null, but if you want use markdown, you should input markdown or html).

You get result from this method: result json from Telegram API

forwardMessage

Method for forwardMessage from one chat to other chat. Params: chat_id integer | id chat where you want send message

  • from_chat_id integer | id chat where you get message to send
  • message_id integer | id message what you want send

You get result from this method: result json from Telegram API

deleteMessage

Method for delete message from chat. Params:

  • chat_id integer | id chat where you want delete message
  • message_id integer | id message what you want delete

sendPhoto

Method for send photo in chat. Params:

  • chat_id integer | id chat where you want send photo
  • path string | path to photo what you want send

You get result from this method: result json from Telegram API

sendMessageParams (customer, for send message)

Function for sending telegram messages by bot, customer params send. Params:

  • params array | array with field to send message
$telegram = new Telegram(BOT_TOKEN);
   
 $params = [
          'chat_id'   => PEER,
          'text'      => 'Message'
      ];

$telegram->sendMessageParams($params);

answerCallbackQuery

Method for answer callback query. Params:

  • params array | array with field to send callback Params can be this array:

$telegram = new Telegram(BOT_TOKEN);
   
      $params = [
          'callback_query_id'     => $callback_id, // id callback for answer
          'text'                  => $answer // text answer
       ];

$telegram->answerCallbackQuery($params);