Telegraph - a Laravel package for fluently interaction with Telegram Bots

Overview

Pest Laravel Expectations

Latest Version on Packagist Tests Code Style Static Analysis Total Downloads

Telegraph is a Laravel package for fluently interaction with Telegram Bots

Telegraph::message('hello world')
    ->keyboard(Keyboard::make()->buttons([
            Button::make('Delete')->action('delete')->param('id', '42'),
            Button::make('open')->url('https://test.it'),
    ]))->send();

Installation

You can install the package via composer:

composer require defstudio/telegraph

Publish and launch required migrations:

php artisan vendor:publish --tag="telegraph-migrations"
php artisan migrate

Optionally, you can publish the config file with:

php artisan vendor:publish --tag="telegraph-config"

Usage

After a new bot is created and added to a chat/group/channel (as described in our documentation), the Telegraph facade can be used to easily send messages and interact with it:

Telegraph::message('this is great')->send();

An extensive documentation is available at

https://def-studio.github.io/telegraph

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Change Base url

    Change Base url

    Hello I have (self host) in server and I use http://localhost:8000 instead of https://api.telegram.org and I need to a method in send message, send document &... before method send() that I can specify the base url method And I can specify its default value in config this method just change the base url Thanks

    opened by ahr1384 13
  • Bot sends message to the same chat

    Bot sends message to the same chat

    👋

    Hi believe I found a problem but I cant understand where the problem is.

    The following fode when in a controller will always send all the messages to the first chat.

    /** @var TelegraphChat $chats */
    $chats = TelegraphChat::all();
    
    foreach ($chats as $chat) {
        $chat->markdown("*Hello!*\n\nI'm here!")->send();
    }
    
    bug 
    opened by nacr 12
  • Add long pulling support for getUpdates() method

    Add long pulling support for getUpdates() method

    It is very handy sometimes to use long pooling instead of webhook. Telegram documentation states that it is ok to use getUpdates() method.

    This PR adds two parameters to updates() method: offset and timeout, so one can use them to implement long pooling.

    This PR does not introduce any BC.

    opened by zim32 10
  • implement sendMediaGroup [InputMediaPhoto]

    implement sendMediaGroup [InputMediaPhoto]

    Use sample:

    Telegraph::mediaGroup([
                (new InputMediaPhoto($url),
                (new InputMediaPhoto($fileId)),
                (new InputMediaPhoto(Storage::path('image.jpg'))),
            ])
                ->send();
    
    opened by YSRoot 6
  • New anonymous chats created

    New anonymous chats created

    Hello,

    With the latest upgrade, the package started to create chats from webhooks that can not be identified which group they belong to because the name is null.

    I have two questions:

    1. Is it possible to fill in the name in the database with the chat title instead it being null?
    2. Is it possible to disable storing unknown chats like the previous behavior was with a config change?

    Thank you!

    opened by keyur555 6
  • /chatid command not work

    /chatid command not work

    In documentation exists command /chat_id but in code is /chatid /chatid command not work

    you need replace this line src\Handlers\WebhookHandler.php:141

    $chat = $this->bot->chats()->where('chat_id', $this->request->input('message.chat.id'))->firstOrNew();
    

    on this code:

            $chat = $this->bot->chats()->firstOrNew([
                'chat_id' => $this->request->input('message.chat.id')
            ]);
    

    for fix problem

    opened by arhx 6
  • Custom WebHook URL

    Custom WebHook URL

    I use a local Telegram Bot server. When registering, the WebHook is installed based on the APP_URL configuration variable. But my URL inside the server starts with http://127.0.0.1:8080 (for example).

    As an option, make a separate option in the configuration.

    opened by alglyzin 5
  • Added sendVoice feature

    Added sendVoice feature

    • Added ENDPOINT_SEND_VOICE const to Telegraph
    • Added Voice DTO
    • Added voice() function to Message DTO
    • Added $voice property to Message DTO
    • Updated fromArray function of Message DTO
    • Updated toArray function of Message DTO
    • Added voice() function to SendsAttachments trait
    opened by alessiovietri 5
  • How to perform two WebHook actions at the same time?

    How to perform two WebHook actions at the same time?

    Hello! I've been using your package very heavily recently. Great job!

    I have a question: I have a method called setRole that's hooked to a Telegram action. This is an example of the contents:

    $this->chat->message("You selected $role_id.")->send();
    $this->chat->deleteMessage($the_action_message_id);
    

    Only the first command gets executed, if I swap send message for delete message, then the message gets deleted. Is there a way to make them both work?

    Thanks!

    opened by marcovega 4
  • Unknown command when in groups

    Unknown command when in groups

    👋

    The solution in #47 works very well 👍

    But it raises an issue.

    When any command is used in the group that does not exist in our bot it will respond with Unknown command

    this would be expected if one uses the command like /command@my_super_botbut I don't believe it's the best way when one is just using /command

    Thank you for all the work ❤️

    bug 
    opened by nacr 4
  • [fix] chat_ids greater than 2147483647 in 32 bit systems

    [fix] chat_ids greater than 2147483647 in 32 bit systems

    An integer data type is a non-decimal number between -2147483648 and 2147483647 in 32 bit systems. Currently, Telegram assigns chat_ids greater than 2147483647 to new accounts, so they cannot be treated as int data by PHP without being distorted in 32 bit systems. Using the string data type instead of int to handle the chat_id could be a work around to this limitation and solve this issue #284

    opened by evrard-c 3
  • Payloads refactor + [feat] sendAudio + fix doc

    Payloads refactor + [feat] sendAudio + fix doc

    payload refactor for available methods. For each method created the payload, the payloadFake, updated the test and the snapshots. Implemented sendAudio method with relative test, payload and snapshots. Implemented "message_thread_id" and "allow_sending_without_reply " in general message's methods. Updated DOCS and fixed "dto" doc with correct reference. Added Audio test file. Locked "sendAttachment" trait as "@internal" .

    opened by MarioGattolla 0
  • How to get updates from webhook?

    How to get updates from webhook?

    I have created telelgram bot, installed webhook and added chat as writen in documentation

    https://defstudio.github.io/telegraph/quickstart/new-bot/

    So how to get data that comes from bot? How to get updates from webhook? Maybe I need add some routes?

    opened by Odilbukh 1
  • Conversations

    Conversations

    I need to collect information from the user using a conversation. So that the bot remembers the input context for a while. Example: https://botman.io/2.0/conversations

    planned 
    opened by alglyzin 1
Releases(v1.28.0)
  • v1.28.0(Dec 21, 2022)

    What's Changed

    • [feat] Model-less mode by @fabio-ivona in https://github.com/defstudio/telegraph/pull/294

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.27.0...v1.28.0

    Source code(tar.gz)
    Source code(zip)
  • v1.27.0(Dec 17, 2022)

    What's Changed

    • [feat] sendAnimation method by @MarioGattolla in https://github.com/defstudio/telegraph/pull/295

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.26.2...v1.26.3

    Source code(tar.gz)
    Source code(zip)
  • v1.26.2(Dec 14, 2022)

  • v1.26.1(Dec 14, 2022)

  • v1.26.0(Dec 14, 2022)

    What's Changed

    • Bump decode-uri-component from 0.2.0 to 0.2.2 in /docs by @dependabot in https://github.com/defstudio/telegraph/pull/283
    • Change caption of button by @ChillMouse in https://github.com/defstudio/telegraph/pull/287
    • Issue #268 implement editMessageMedia method by @MarioGattolla in https://github.com/defstudio/telegraph/pull/277
    • [feat] login_url for keyboards by @MarioGattolla in https://github.com/defstudio/telegraph/pull/291
    • [docs] added suggestion on contact verification by @ChillMouse in https://github.com/defstudio/telegraph/pull/286
    • [fix] chat_ids greater than 2147483647 in 32 bit systems by @evrard-c in https://github.com/defstudio/telegraph/pull/288

    New Contributors

    • @ChillMouse made their first contribution in https://github.com/defstudio/telegraph/pull/287

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.24.4...v1.26.0

    Source code(tar.gz)
    Source code(zip)
  • v1.24.4(Dec 7, 2022)

    What's Changed

    • [feat] model storage by @fabio-ivona in https://github.com/defstudio/telegraph/pull/271
    • [fix] disable telegraph facade caching by @MarioGattolla in https://github.com/defstudio/telegraph/pull/279
    • [fix] bug in DTO/Location by @ahr1384 in https://github.com/defstudio/telegraph/pull/282

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.24.3...v1.24.4

    Source code(tar.gz)
    Source code(zip)
  • v1.24.3(Nov 25, 2022)

    What's Changed

    • fix #274 by @fabio-ivona in https://github.com/defstudio/telegraph/pull/275

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.24.2...v1.24.3

    Source code(tar.gz)
    Source code(zip)
  • v1.24.2(Nov 24, 2022)

    What's Changed

    • [revert] upgrade to markdown V2 by @fabio-ivona in https://github.com/defstudio/telegraph/pull/272
    • [fix] markdown-v2 opt-in through configs or markdownV2 ()method by @fabio-ivona in https://github.com/defstudio/telegraph/pull/273

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.24.1...v1.24.2

    Source code(tar.gz)
    Source code(zip)
  • v1.24.1(Nov 20, 2022)

    What's Changed

    • [fix] add missing dice method in TelegraphChat by @fabio-ivona in https://github.com/defstudio/telegraph/pull/266

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.24.0...v1.24.1

    Source code(tar.gz)
    Source code(zip)
  • v1.24.0(Nov 19, 2022)

    What's Changed

    • [feat] storage system by @fabio-ivona in https://github.com/defstudio/telegraph/pull/263
    • [feat] upgrade to markdown V2 by @fabio-ivona in https://github.com/defstudio/telegraph/pull/265

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.23.1...v1.24.0

    Source code(tar.gz)
    Source code(zip)
  • v1.23.1(Nov 16, 2022)

    What's Changed

    • implemented the getChatMenuButton function, doc and test(with relativ… by @MarioGattolla in https://github.com/defstudio/telegraph/pull/252
    • chatMember method implemented by @reza305z in https://github.com/defstudio/telegraph/pull/261
    • implemented the sendDice method , doc and test(with relative snapshot) by @MarioGattolla in https://github.com/defstudio/telegraph/pull/253

    New Contributors

    • @reza305z made their first contribution in https://github.com/defstudio/telegraph/pull/261

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.23.0...v1.23.1

    Source code(tar.gz)
    Source code(zip)
  • v1.23.0(Nov 13, 2022)

    What's Changed

    • [feat] custom webhook domain by @fabio-ivona in https://github.com/defstudio/telegraph/pull/256

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.22...v1.23.0

    Source code(tar.gz)
    Source code(zip)
  • v1.22(Nov 10, 2022)

    What's Changed

    • Setup chat by @YSRoot in https://github.com/defstudio/telegraph/pull/246
    • implement showAlert for replyWebhook by @YSRoot in https://github.com/defstudio/telegraph/pull/245
    • fix chatInfo error by @MarioGattolla in https://github.com/defstudio/telegraph/pull/249
    • Bump loader-utils from 1.4.0 to 1.4.1 in /docs by @dependabot in https://github.com/defstudio/telegraph/pull/250
    • implement switch inline query type in button with relative test and doc by @MarioGattolla in https://github.com/defstudio/telegraph/pull/247
    • Implement get user profile photos by @MarioGattolla in https://github.com/defstudio/telegraph/pull/251

    New Contributors

    • @YSRoot made their first contribution in https://github.com/defstudio/telegraph/pull/246

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.21.4...v1.22

    Source code(tar.gz)
    Source code(zip)
  • v1.21.4(Oct 28, 2022)

    What's Changed

    • [Fix] queued requests by @fabio-ivona in https://github.com/defstudio/telegraph/pull/240

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.21.3...v1.21.4

    Source code(tar.gz)
    Source code(zip)
  • v1.21.3(Oct 26, 2022)

    What's Changed

    • Screenshot problem solved! by @Mrjavaci in https://github.com/defstudio/telegraph/pull/234
    • added InlineQueryResultLocation + test + snapshots + fix other inline… by @MarioGattolla in https://github.com/defstudio/telegraph/pull/235

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.21.2...v1.21.3

    Source code(tar.gz)
    Source code(zip)
  • v1.21.2(Oct 25, 2022)

    What's Changed

    • Documentation fix by @Mrjavaci in https://github.com/defstudio/telegraph/pull/233

    New Contributors

    • @Mrjavaci made their first contribution in https://github.com/defstudio/telegraph/pull/233

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.21.1...v1.21.2

    Source code(tar.gz)
    Source code(zip)
  • v1.21.1(Oct 24, 2022)

    What's Changed

    • docs: Fix typo in messages section by @nikosid in https://github.com/defstudio/telegraph/pull/230
    • Added Russian translation by @andrey-helldar in https://github.com/defstudio/telegraph/pull/231

    New Contributors

    • @nikosid made their first contribution in https://github.com/defstudio/telegraph/pull/230
    • @andrey-helldar made their first contribution in https://github.com/defstudio/telegraph/pull/231

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.21.0...v1.21.1

    Source code(tar.gz)
    Source code(zip)
  • v1.21.0(Oct 13, 2022)

    What's Changed

    • [feat] leaveChat method by @adevade in https://github.com/defstudio/telegraph/pull/206
    • [feat] deleteChatPhoto method by @adevade in https://github.com/defstudio/telegraph/pull/205
    • [feat] poll and quiz methods by @fabio-ivona in https://github.com/defstudio/telegraph/pull/211
    • [feat] forced replies by @fabio-ivona in https://github.com/defstudio/telegraph/pull/212
    • [feat] InlineQueryResultContact class by @MarioGattolla in https://github.com/defstudio/telegraph/pull/213
    • Fix issue #196 by @MarioGattolla in https://github.com/defstudio/telegraph/pull/214
    • Fix issue #197 by @MarioGattolla in https://github.com/defstudio/telegraph/pull/215
    • Fix issue #198 by @MarioGattolla in https://github.com/defstudio/telegraph/pull/218
    • Fix issue #199 by @MarioGattolla in https://github.com/defstudio/telegraph/pull/219
    • Fix issue #200 by @MarioGattolla in https://github.com/defstudio/telegraph/pull/220
    • Fix issue #201 by @MarioGattolla in https://github.com/defstudio/telegraph/pull/221
    • [feat] Php 8.2 support by @fabio-ivona in https://github.com/defstudio/telegraph/pull/222
    • Add validate error to config by @GhostWalkers in https://github.com/defstudio/telegraph/pull/223
    • [feat] translations by @fabio-ivona in https://github.com/defstudio/telegraph/pull/225
    • [feat] forwardMessage method #184 by @nicola-posa in https://github.com/defstudio/telegraph/pull/216

    New Contributors

    • @adevade made their first contribution in https://github.com/defstudio/telegraph/pull/206
    • @MarioGattolla made their first contribution in https://github.com/defstudio/telegraph/pull/213
    • @GhostWalkers made their first contribution in https://github.com/defstudio/telegraph/pull/223
    • @nicola-posa made their first contribution in https://github.com/defstudio/telegraph/pull/216

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.20.1...v1.21.0

    Source code(tar.gz)
    Source code(zip)
  • v1.20.1(Sep 23, 2022)

    What's Changed

    • update urls by @fabio-ivona in https://github.com/defstudio/telegraph/pull/183

    Full Changelog: https://github.com/defstudio/telegraph/compare/v1.20.0...v1.20.1

    Source code(tar.gz)
    Source code(zip)
  • v1.20.0(Sep 22, 2022)

    What's Changed

    • [feat] users activity handling by @fabio-ivona in https://github.com/def-studio/telegraph/pull/182

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.19.3...v1.20.0

    Source code(tar.gz)
    Source code(zip)
  • v1.19.3(Sep 19, 2022)

    What's Changed

    • [fix] missing user first_name in message by @fabio-ivona in https://github.com/def-studio/telegraph/pull/176

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.19.2...v1.19.3

    Source code(tar.gz)
    Source code(zip)
  • v1.19.2(Sep 12, 2022)

  • v1.19.1(Sep 3, 2022)

    What's Changed

    • [fix] keyboard buttons width computation by @fabio-ivona in https://github.com/def-studio/telegraph/pull/169

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.19.0...v1.19.1

    Source code(tar.gz)
    Source code(zip)
  • v1.19.0(Aug 31, 2022)

    What's Changed

    • [feat] invite links by @fabio-ivona in https://github.com/def-studio/telegraph/pull/163
    • [feat] chat member count by @fabio-ivona in https://github.com/def-studio/telegraph/pull/164
    • [feat] chat permissions by @fabio-ivona in https://github.com/def-studio/telegraph/pull/165
    • [feat] chat members management by @fabio-ivona in https://github.com/def-studio/telegraph/pull/166

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.18.1...v1.19.0

    Source code(tar.gz)
    Source code(zip)
  • v1.18.1(Aug 30, 2022)

    What's Changed

    • [feat] unknown chats webhook handling by @fabio-ivona in https://github.com/def-studio/telegraph/pull/161

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.18.0...v1.18.1

    Source code(tar.gz)
    Source code(zip)
  • v1.18.0(Aug 30, 2022)

    What's Changed

    • [feat] set chat title, description and photo by @fabio-ivona in https://github.com/def-studio/telegraph/pull/159

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.17.3...v1.18.0

    Source code(tar.gz)
    Source code(zip)
  • v1.17.3(Aug 28, 2022)

    What's Changed

    • Update create_telegraph_chats_table.php.stub by @evrard-c in https://github.com/def-studio/telegraph/pull/157

    New Contributors

    • @evrard-c made their first contribution in https://github.com/def-studio/telegraph/pull/157

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.17.2...v1.17.3

    Source code(tar.gz)
    Source code(zip)
  • v1.17.2(Aug 25, 2022)

  • v1.17.1(Aug 25, 2022)

    What's Changed

    • [fix] ReplyKeyboard resize by @fabio-ivona in https://github.com/def-studio/telegraph/pull/155

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.17.0...v1.17.1

    Source code(tar.gz)
    Source code(zip)
  • v1.17.0(Aug 25, 2022)

    What's Changed

    • [feat] attachments remote url and file_id by @fabio-ivona in https://github.com/def-studio/telegraph/pull/153

    Full Changelog: https://github.com/def-studio/telegraph/compare/v1.16.0...v1.17.0

    Source code(tar.gz)
    Source code(zip)
Owner
def:studio
def:studio
TeleBot - Easy way to create Telegram-bots in PHP. Rich Laravel support out of the box.

TeleBot is a PHP library for telegram bots development. Rich Laravel support out of the box. Has an easy, clean, and extendable way to handle telegram Updates.

WeStacks 206 Jan 6, 2023
SDK for latest version of Telegram bots API

SDK for latest version of Telegram bots API (from April 24, 2020) Using Examples Installing composer require "DiyorbekUz/Telelib: dev-master" Init bot

Diyorbek 2 Sep 5, 2021
Create modern Telegram Bots with PHP.

Telepath Create Telegram Bots with this modern PHP library Explore the docs » Report Bug · Request Feature Table of Contents About The Project Before

Telepath 5 Nov 7, 2022
PHP Telegram Bot based on the official Telegram Bot API with iTelegram Class.

iTelegram PHP Telegram Bot based on the official Telegram Bot API Bots: An introduction for developers Bots are special Telegram accounts designed to

iNeoTeam | آی نئو 5 Nov 9, 2022
Robot increase telegram post 👁‍🗨Telegram Fake Posts Viewer👁‍🗨

Program Features - ?? Very and stylish design. - ?? It has glass buttons. - ?? Has a professional management panel. - ?? Has a user area. - ?? Free di

hack4lx 4 Nov 25, 2022
PHP Telegram Bot based on the official Telegram Bot API

PHP Telegram Bot based on the official Telegram Bot API

null 4 Dec 8, 2021
A framework agnostic PHP library to build chat bots

BotMan If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course. About BotMa

BotMan 5.8k Jan 3, 2023
The best PHP library for VK Users Longpoll Api (Page Bots).

vk-page-bot-lib Description: There are 2 commands and a logger. There is a logger of new messages and a logger that a friend has entered/left in/from

KirillChimbur 6 Jul 25, 2022
laravel package untuk memudahkan penggunaan MCA dengan Telegram Bot USDI di aplikasi Universitas Udayana.

MCA KubeMQ Laravel laravel package untuk memudahkan penggunaan MCA dengan Telegram Bot USDI di aplikasi Universitas Udayana. Motivasi Proyek ini berfu

Ristek USDI 1 Nov 17, 2021
A telegram bot to check credit cards. written in php & py

MRBANKER BOT A telegram bot to check credit cards. written in php & py. You can find me on telegram STEP1: goto botfather create a bot copy the token

Nitin1818 48 Dec 30, 2022
NovaGram - An elegant, Object-Oriented, reliable PHP Telegram Bot Library

An elegant, Object-Oriented, reliable PHP Telegram Bot Library Full Documentation • Public support group Examples • Features • Installation ?

Gaetano 165 Jan 6, 2023
A tool for sending fast and managed messages to Telegram bot users

???? HiToAll A tool for sending fast and managed messages to Telegram bot users About In some telegram bots programmed with php language, if there are

Matin Najafi 3 Oct 3, 2021
can be found on telegram as https://t.me/ZedgeImagesBot

Zedge Images Bot Installation Instruction copy the PHP files to your webhost. Rename config.sample.php to config.php Edit config.php Now, go to https:

Shrimadhav U K 12 Aug 26, 2022
telegram bot for sell virtual number

Telefake Telegram bot for sell virtual number (fully automatic) Installation create bot in telegram upload script in website with php and ssl (https)

reza malekpour 4 Aug 20, 2022
Telegram bot for CC Checker with hella lotta features.

SDMN CHECKER BOT Telegram bot for CC Checker with hella lotta features. ?? Table of Contents Dependencies / Limitations Future Scope Setting up a Hero

Rohithaditya 5 Dec 19, 2022
Telegram API made for php (Simple usage)

Telegram Telegram API made for php (Simple usage) How to use? Download the project & place Telegram folder tp your project directory (For example i se

null 0 Apr 4, 2022
Integrate Your PHP Code With Telegram Bot API for Beginner

Documentation[https://core.telegram.org/bots/api] Resource[https://github.com/bachors/KBBI.sql] Integrate Your PHP Code With Telegram Bot API for Begi

Nova Andre Saputra 1 Oct 19, 2021
Create and manage advanced polls with this Telegram Bot which has many features available!

MasterPollBot Create and manage advanced polls with this Telegram Bot which has many features available! Requirements Local Telegram Bot API or a webh

NeleB54Gold 7 Oct 21, 2022
Simple telegram auto reminder BOT with PHP

Telebot Script Telegram BOT Auto Reminder Dibuat pake PHP OOP Sebenernya bukan buat dipublish sih, ini cuma buat praktek PHP OOP sama praktek Commit &

its Galih 4 Nov 7, 2022