Skip to main content

Commands

Telepath comes with its own CLI helper tool called telepathy to help you run simple Telegram API commands from the command line.

Usage

If you call telepathy without any arguments, it will show you the available commands:

Global options

There are global options that are available for all commands. They can be specified as command line arguments or in a .env file.

cli optioncli shortcut.env variabledescription
--token-tTELEGRAM_API_TOKENTelegram Bot API Token for your bot to use.
--api-urlTELEGRAM_API_URLIf you want to use a local bot api server, this is the URL. Defaults to the official Telegram API server.
--proxyTELEPATH_PROXYSends requests through a specified proxy address. Defaults to no proxy.

Commands

./telepathy bot:info

This corresponds to the getMe API function and will return information about the bot. You can test your API token with this command.

./telepathy server:close

This corresponds to the close API function and will close the bot instance if you want to move from one local server to another.

./telepathy server:logout

This corresponds to the logout API function and will log out the bot from the cloud Bot API server before moving it to a local server.

./telepathy webhook:delete

This corresponds to the deleteWebhook API function and will delete the webhook if you want to switch back to long polling.

OptionDescription
--drop-pending-updates or -dDrop all pending updates.

./telepathy webhook:info

This corresponds to the getWebhookInfo API function and will return the current webhook status.

./telepathy webhook:set

This corresponds to the setWebhook API function and will set the webhook to the specified URL.

ArgumentOptionalDescription
urlnoThe hostname the webhook should be set to.
OptionShortcutDescription
--certificate-cPath to your public key certificate
--ip-address-iThe fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
--max-connections-mThe maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
--allowed-updates-aA list of the update types you want your bot to receive. For example, specify --allowed-updates message --allowed-updates edited_channel_post --allowed-updates callback_query
--drop-pending-updates-dDrop all pending updates
--secret-token-sA secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request

Laravel Commands

If you're using the telepath/laravel package you can use the following php artisan commands:

####php artisan telepath:fetch

Fetches Telegram updates periodically (using long polling) and dispatches them to the Laravel application.

OptionShortcutDescription
--bot-bIdentifier of the bot to use. Uses the default bot, if not specified.
Important

Remember to restart this command after any code changes so they take effect.

php artisan telepath:install

Installs the package. This command publishes the configuration file, ensures the existence of the app/Telepath folder and appends the possible environment variables to your .env file.

OptionShortcutDescription
--force-fOverwrite existing files

php artisan telepath:set-webhook

ArgumentOptional?Description
hostnameyesThe hostname the webhook should be set to.
OptionShortcutDescription
--bot-bIdentifier of the bot to use. If not specified the default bot is used.
--drop-pending-updates-dDrop all pending updates.