Text() public method

\return the String users's text
public Text ( )
 * Telegram Cowsay Bot Example.
 * Add @cowmooobot to try it!
 * @author Gabriele Grillo <*****@*****.**>
 */
include "Telegram.php";
// Set the bot TOKEN
$bot_id = "bot_token";
// Instances the class
$telegram = new Telegram($bot_id);
/* If you need to manually take some parameters
*  $result = $telegram->getData();
*  $text = $result["message"] ["text"];
*  $chat_id = $result["message"] ["chat"]["id"];
*/
// Take text and chat_id from the message
$text = $telegram->Text();
$chat_id = $telegram->ChatID();
if ($text == "/start") {
    $option = array(array("🐮"), array("Git", "Credit"));
    // Create a permanent custom keyboard
    $keyb = $telegram->buildKeyBoard($option, $onetime = false);
    $content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to CowBot 🐮 \nPlease type /cowsay or click the Cow button !");
    $telegram->sendMessage($content);
}
if ($text == "/cowsay" || $text == "🐮") {
    $randstring = rand() . sha1(time());
    $cowurl = "http://bangame.altervista.org/cowsay/fortune_image_w.php?preview=" . $randstring;
    $content = array('chat_id' => $chat_id, 'text' => $cowurl);
    $telegram->sendMessage($content);
}
if ($text == "/credit" || $text == "Credit") {
示例#2
0
<?php

// This is the Beer Bot, which reads data from the MySQL DB and sends it to
// Telegram users.
// 01.02.2016 / Hannes Badertscher
include "TelegramBotPHP/Telegram.php";
$base = dirname(dirname(__FILE__));
include $base . '/settings/db_settings.php';
include $base . '/settings/bierbot_id.php';
// Setup chat
$telegram = new Telegram($bot_id);
$chat_id = $telegram->ChatID();
// Parse command and arguments
$rawstr = $telegram->Text();
preg_match("/\\/[^\\s\\z\$]*/", $rawstr, $cmd);
$cmd = array_values($cmd)[0];
$args = preg_split("/\\/[^\\s\\z\$]*/", $rawstr);
$args = strtolower(trim(implode(" ", $args)));
// Get sender info
$vorname = $telegram->FirstName();
$nachname = $telegram->LastName();
$username = $telegram->UserName();
switch ($cmd) {
    case "/start":
    case "/start@BierAktionBot":
    case "/help":
    case "/help@BierAktionBot":
        $content = array('chat_id' => $chat_id, 'text' => "Hello. I am BierAktionBot. I try to help you find good beers at cheap prices in Switzerland." . "Type /getBeers to get a list of all beers which are discounted at the moment.");
        $telegram->sendMessage($content);
        break;
    case "/getbeers":