amohamed/telegram-atm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amohamed/telegram-atm

Composer 安装命令:

composer require amohamed/telegram-atm

包简介

This is a custom Telegram Service bot

README 文档

README

A custom Laravel package for interacting with the Telegram API.

Installation

Install the package via composer:

composer require amohamed/telegram-atm:dev-main

Configuration

Publish the package configuration file using:

php artisan vendor:publish --provider="Amohamed\TelegramAtm\TelegramAtmServiceProvider" --tag=migrations

Then, you can modify the published configuration file located at config/telegramatm.php with your Telegram bot's details.

Usage

Inject Amohamed\TelegramAtm\TelegramAtmService in your service or controller:

use Amohamed\TelegramAtm\TelegramAtmService;

class MyController extends Controller
{
    protected $telegramAtmService;

    public function __construct(TelegramAtmService $telegramAtmService)
    {
        $this->telegramAtmService = $telegramAtmService;
    }

    public function someMethod()
    {
        // Use the telegramAtmService instance
    }
}

Available Methods

Here are the available methods you can use:

getApiUrl($method)

This method returns the Telegram API URL for the given method.

  • $method (string): The Telegram API method.

sendRequest($url, $params = [])

This method sends a request to the Telegram API.

  • $url (string): The Telegram API URL.
  • $params (array): The request parameters.

getMe()

This method returns information about the bot.

sendMessage($chat_id, $text, $parse_mode = null, $disable_web_page_preview = null, $disable_notification = null, $reply_to_message_id = null, $reply_markup = null)

This method sends a text message to a chat.

  • $chat_id (int|string): The chat ID.
  • $text (string): The message text.
  • $parse_mode (string|null): The parse mode of the message text.
  • $disable_web_page_preview (bool|null): Whether to disable the web page preview.
  • $disable_notification (bool|null): Whether to disable the notification.
  • $reply_to_message_id (int|null): The ID of the message being replied to.
  • $reply_markup (array|null): The reply markup.

forwardMessage($chat_id, $from_chat_id, $message_id, $disable_notification = null)

This method forwards a message from one chat to another.

  • $chat_id (int|string): The chat ID.
  • $from_chat_id (int|string): The chat ID of the source chat.
  • $message_id (int): The message ID.
  • $disable_notification (bool|null): Whether to disable the notification.

sendPhoto($chat_id, $photo, $caption = null, $parse_mode = null, $disable_notification = null, $reply_to_message_id = null, $reply_markup = null)

This method sends a photo to a chat.

  • $chat_id (int|string): The chat ID.
  • $photo (string): The photo file path or URL.
  • $caption (string|null): The photo caption.
  • $parse_mode (string|null): The parse mode of the photo caption.
  • $disable_notification (bool|null): Whether to disable the notification.
  • $reply_to_message_id (int|null): The ID of the message being replied to.
  • $reply_markup (array|null): The reply markup.

sendAudio($chat_id, $audio, $caption = null, $parse_mode = null, $duration = null, $performer = null, $title = null, $disable_notification = null, $reply_to_message_id = null, $reply_markup = null)

This method sends an audio file to a chat.

  • $chat_id (int|string): The chat ID.
  • $audio (string): The audio file path or URL.
  • $caption (string|null): The audio caption.
  • $parse_mode (string|null): The parse mode of the audio caption.
  • $duration (int|null): The duration of the audio file.
  • $performer (string|null): The performer of the audio file.
  • $title (string|null): The title of the audio file.
  • $disable_notification (bool|null): Whether to disable the notification.
  • $reply_to_message_id (int|null): The ID of the message being replied to.
  • $reply_markup (array|null): The reply markup.

getUserSession($chat_id)

This method returns the user session data for the given chat ID.

  • $chat_id (int|string): The chat ID.

getCommand($text)

This method returns the command from the given text.

  • $text (string): The text.

getCommandParams($text)

This method returns the command parameters from the given text.

  • $text (string): The text.

deleteUserSession($chatId)

This method deletes the user session data for the given chat ID.

  • $chatId (int|string): The chat ID.

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 54
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2023-07-09