bota

Bota - the ultimate Telegram bot hosting built with PHP, powered by NovaGram Library!

View the Project on GitHub Jobians/bota

Bot Methods


All the BOTApi’s methods can be used as methods of the Bot class.
——–

All Methods

How to use any BOTApi Method:

$Bot->METHOD_NAME([
    "field1_name" => "field1_value",
    "field2_name" => "field2_value"
])

Example:

$Bot->sendDice([
    "chat_id" => "@channelusername",
    "emoji" => "🎲"
])

Some Methods Examples

sendMessage

sendMessage can be used directly as a method of the main class, or as a method of a Chat Object.

Returns the sent Message object.

// main class
$Bot->sendMessage(01234567, "message_text");

// Chat object
$Chat->sendMessage("message_text");

forwardMessage

forwardMessage can be used directly as a method of the main class, as a method of a Message Object (just forwards that message) or as a method of a Chat Object, as forwardTo method, in order to forward in that Chat.

Returns the forwarded Message object.

// main class
$Bot->forwardMessage([
    "chat_id" => 01234567,
    "text" => "message_text"
]);

// Message object
$message->forward(01234567); // just the chat_id of the target chat

// Chat object (forwardTo)
$Chat->forwardTo([
    "from_chat_id" => 01234567,
    "message_id" => 0123456789
]);

deleteMessage

deleteMessage can be used directly as a method of the main class, as a method of a Message Object (just delete that message) or as a method of a Chat Object, in order to delete a message in that Chat.

// main class
$Bot->deleteMessage([
    "chat_id" => 01234567,
    "message_id" => 0123456789
]);

// Chat object
$Chat->deleteMessage(0123456789); // just the message_id of the target message

// Message object
$message->delete(); // just delete

answerCallbackQuery

answerCallbackQuery can be used directly as a method of the main class or as a method of a CallbackQuery Object, as answer method, in order to answer that CallbackQuery.

// main class
$Bot->answerCallbackQuery([
    "callback_query_id" => 012345678901234567,
    "text" => "some text"
]);

// CallbackQuery object
$CallbackQuery->answer(); // just answer
$CallbackQuery->answer("text"); // just text

$CallbackQuery->answer("text", [
    "show_alert" => true
]);

editMessageText

editMessageText can be used directly as a method of the main class or as a method of a Message Object, as editText method, in order to edit that Message.

// main class
$Bot->editMessageText([
    "chat_id" => 01234567,
    "message_id" => 0123456789,
    "text" => "new text"
]);

// Message object
$message->editText("new text"); // just text

$message->editText("<b>new text</b>", [
    "parse_mode" => "html"
]);

sendChatAction

sendChatAction can be used directly as a method of the main class or as a method of a Chat Object, as sendAction method, in order to send an Action that Chat.

Default Action if not specified is typing

// main class
$Bot->sendChatAction([
    "chat_id" => 01234567,
    "action" => "typing"
]);

// Chat object
$Chat->sendAction(); // same as below
$Chat->sendAction("typing"); // just action

getUserProfilePhotos

getUserProfilePhotos can be used directly as a method of the main class or as a method of a User Object, as getProfilePhotos method, in order to get Profile Photos of that User.

Returns a UserProfilePhotos object.

// main class
$Bot->getUserProfilePhotos([
    "user_id" => 01234567,
    "limit" => 10
]);

// User object
$User->getProfilePhotos(); // just nothing
$User->getProfilePhotos(10); // just limit

$User->getProfilePhotos(10, [
    "offset" => 5
]);

getUsernameDC

DC means DataCenter, that is the server where the user account is located

getUsernameDC is a static method of the main class but you can use it also as a method of a User Object, as getDC method, in order to get DC of that User.

In order to retrieve DC, user need to have username and profile photo.

getDC will throw a \NovaGram\Exception if Object is not an User, or if User hasn’t got an Username, and will return false if User hasn’t got a profile photo.

Returns an integer corresponding to User DC in case of success.

// main class
Bot::getUsernameDC("jobianstechie");

// User object
$User->getDC();