PHP code example of sanf / rush

1. Go to this page and download the library: Download sanf/rush library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sanf / rush example snippets


// Loading the classes
Sanf\Tools\Message;

// Entering login information and setting up the client
$self = new Client('rush');

// Creating an anonymous function
$action = function (Message $update) use ($self) {
    // Receiving text updates
    $text = $update->text();

    // Creating a command for reacting to a message, for example:
    if ($text == "hello") {
        // Sending the response to the user using the reply command
        $update->reply("Hello, nice to meet you!\nMy name is Sanf.!!!!!");
    }
};

// Connecting to the WebSocket
$self->on_message($action);

// Use your custom session name instead of Sanf
$self = new Client("Sanf");

// Use your custom session name instead of Sanf
$self = new Client("Sanf");

/*
To manually enter the information, you need to provide 4 parameters:

1. auth        | Account ID
2. key         | Private Key
3. platform    | Platform (Web, Android, PWA - PWA is not available for Shad, default is Web)
4. application | Application
*/

// For example, our data will be as follows
$option = [
    "auth" => "your Auth key",
    "key" => "your Private key",
    "platform" => "select Platform",
    "application" => "select Application"
];

// For Rubika
$option = [
    "auth" => "your Auth key",
    "key" => "your Private key",
    "platform" => Platform::PWA, // Can be changed to Web or Android
    "application" => Application::Rubika // Choosing an application
];

// For Shad
$option = [
    "auth" => "your Auth key",
    "key" => "your Private key",
    "platform" => Platform::Web, // Can be changed to Android - PWA is not available for Shad
    "application" => Application::Shad // Choosing an application
];

// Now we provide the information to the client
// Note that you must set the first value to null
$self = new Client(null, $option);

// Use your custom session name instead of Sanf
$self = new Rubino("Sanf");

/*
In this section, you have 1 mandatory parameter and 1 optional parameter:
1. auth        | Account ID (mandatory)
2. profile_id  | Custom Profile ID (optional, if not entered, the bot will automatically retrieve all profile IDs and you will choose which account it will operate on)
*/

// For example, our data will be as follows
$option = [
    "auth" => "your auth key", // Mandatory
    "profile_id" => "custom profile id" // Optional
];

// Now we provide the information to the client
$self = new Rubino(null, $option);