mirkhamidov/yii2-bot-telegram

bot for telegram

Installs: 214

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

0.1.1 2024-01-06 16:21 UTC

This package is auto-updated.

Last update: 2024-10-06 17:57:34 UTC


README

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require mirkhamidov/yii2-bot-telegram "*"

or add

"mirkhamidov/yii2-bot-telegram": "*"

to the require section of your composer.json file.

Usage

first add to config.php

<?php
'components' => [
	'telegram' => [
        'class' => 'mirkhamidov\telegramBot\TelegramBot',
        'botToken' => 'TOKEN HERE',
    ]
]
?>

Once the extension is installed, simply use it in your code by :

<?php Yii::$app->telegram->sendMessage('Message'); ?>

send message width inline keyboard by:

<?php Yii::$app->telegram->sendMessage('Message with inline keyboard', $chatId, [
        'reply_markup' => json_encode([
            'inline_keyboard'=>[
                [
                    ['text'=>"refresh",'callback_data'=> time()]
                ]
            ]
        ]),
    ] ?>

send photo by :

<?php Yii::$app->telegram->sendPhoto('/app/pattern2.jpg', $chatId, [
    'caption' => 'some text',
]); ?>

TODO

  • Logging

PS: Inspired by aki/yii2-bot-telegram