Send message to bot telegram php

Ratings   Unique User Downloads   Download Rankings
61%
Total: 1,282 All time: 2,993 This week: 67
Version   License   PHP version   Categories
telegram-php 1.0.25 GNU General Publi... 5 PHP 5, Web services, Chat
Description   Author

This package can send and receive messages to Telegram users.

It can connect to Telegram as a given user and send messages to a given user.

It can also register callback functions when the user receives a message matching some incoming message text pattern.

  Performance   Level  

Name:Classes:Country:Age:All time rank:Week rank:
David Gir�n <contact>
4 packages by David Gir�n
Spain
26
1681 42 in Spain
53
3 in Spain

Level 1

Innovation award

Nominee: 2x


Details

Telegram-PHP

Another library to use Telegram bots with PHP.

  • Include the src/Autoloader.php file.
  • Create a Telegram\Bot object.
  • Create a Telegram\Receiver object using the $bot.
$bot = new Telegram\Bot("11111111:AAAAAAAAAAzzzzzzzzzzzzzzzzzzz", "MyUserBot", "The Name of Bot"); $tg = new Telegram\Receiver($bot);

You can create as many Bots and Receivers or Senders as you want. Using Receiver includes a Sender.

Usage

Once the page is loaded (manually or via webhook), you can send or reply the requests.

To send a message to a user or group chat:

$tg->send ->chat("123456") ->text("Hello world!") ->send();

To reply a user command:

if($tg->text_command("start")){ $tg->send ->text("Hi!") ->send(); }

To reply a user message:

if($tg->text_has("are you alive")){ $tg->send ->text("Yes!") ->send(); }

NEW: To parse a string:

if($tg->text_regex("I'm {N:age}") and $tg->words() <= 4){ $num = $tg->input->age; $str = "So old..."; if($num < 18){ $str = "You're young!"; } $tg->send ->text($str) ->send(); }elseif($tg->text_regex("My name's {name}")){ $tg->send ->text("Nice to meet you, " .$tg->input->name ."!") ->send(); }

Send an Inline Keyboard and parse it:

if($tg->callback == "but 1"){ $tg->answer_if_callback(""); // Stop loading button. $tg->send ->message(TRUE) ->chat(TRUE) ->text("You pressed the first button!") ->edit("text"); }elseif($tg->callback == "but 2"){ $tg->answer_if_callback("You pressed the second button!", TRUE); // Display an alert and stop loading button. } if($tg->text_has("matrix") and $tg->words() <= 5){ $tg->send ->text("Red or blue. You choose.") ->inline_keyboard() ->row() ->button("Red", "but 1") ->button("Blue", "but 2") ->end_row() ->show() ->send(); }

Examples

  • Profesor Oak, an assistant for Pokemon GO.

 
Files
 

  Applications that use this package  

No pages of applications that use this class were specified.

If you know an application of this package, send a message to the author to add a link here.

Can I send message by bot in Telegram?

Getting Started Open the telegram app and search for @BotFather. Click on the start button or send “/start”. Then send “/newbot” message to set up a name and a username. After setting name and username BotFather will give you an API token which is your bot token.

How do I send a message to a bot channel?

Create a Telegram public channel. Create a Telegram BOT via BotFather. Set the bot as administrator in your channel..
BOT_API_KEY is the API Key generated by BotFather when you created your bot..
MY_CHANNEL_NAME is the handle of your channel (e.g. @my_channel_name).
MY_MESSAGE_TEXT is the message you want to send (URL-encoded).

How do you send bots on Telegram?

Open Telegram messenger, sign in to your account or create a new one..
Enter @Botfather in the search tab and choose this bot..
Choose or type the /newbot command and send it..
Choose a name for your bot — your subscribers will see it in the conversation. ... .
Go to the @BotFather bot and send the command /token ..

Is there an API for Telegram?

The Telegram API and TDLib allow you to build your own customized Telegram clients. You are welcome to use both APIs free of charge. You can also add Telegram Widgets to your website. Designers are welcome to create Animated Stickers or Custom Themes for Telegram.

Postingan terbaru

LIHAT SEMUA