承接 snip404/symfony-max-notifier 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

snip404/symfony-max-notifier

最新稳定版本:1.0.6

Composer 安装命令:

composer require snip404/symfony-max-notifier

包简介

Symfony Max Notifier Bridge

README 文档

README

Provides MAX integration for Symfony Notifier.

Register as a symfony service

services:
  ...
  Symfony\Component\Notifier\Bridge\Max\MaxTransportFactory:
    tags: [ texter.transport_factory ]

DSN example

MAX_DSN=max://TOKEN@default

where:

  • TOKEN is your MAX token

Adding Interactions to a Message

With a Max message, you can use the MaxOptions class to add message options.

use Symfony\Component\Notifier\Bridge\Max\Markup\Button\KeyboardButton;
use Symfony\Component\Notifier\Bridge\Max\Markup\InlineKeyboardMarkup;
use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('');

// Create MAX options
$maxOptions = (new MaxOptions())
    ->chatId('222222')
    ->parseMode('markdown')
    ->keyboard((new InlineKeyboardMarkup())
        ->addButton((new KeyboardButton("Visit symfony.com"))->link("https://symfony.com"))
        )
    );

// Add the custom options to the chat message and send the message
$chatMessage->options($maxOptions);

$chatter->send($chatMessage);

Adding files to a Message

With a Max message, you can use the MaxOptions class to add message options.

⚠️ WARNING In one message you can send only one file

  • You can send files by passing public http url to option:

    • Photo
      $maxOptions = (new MaxOptions())
           ->image('https://localhost/photo.mp4');
  • You can send files by passing local path to option, in this case file will be sent via multipart/form-data:

    • Image
      $maxOptions = (new MaxOptions())
           ->uploadImage('./photo.mp4');
      • Images
      $maxOptions = (new MaxOptions())
           ->uploadImages(['./photo.mp4']);
    • Video
      $maxOptions = (new MaxOptions())
           ->uploadVideo('./video.mp4');
    • Audio
      $maxOptions = (new MaxOptions())
           ->uploadAudio('./audio.ogg');
    • File
      $maxOptions = (new MaxOptions())
           ->document('./document.odt');

Full example:

use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('Photo Caption');

// Create MAX options
$maxOptions = (new MaxOptions())
    ->chatId('1111111')
    ->parseMode('html')
    ->image('https://symfony.com/favicons/android-chrome-192x192.png');

// Add the custom options to the chat message and send the message
$chatMessage->options($maxOptions);

$chatter->send($chatMessage);

Adding Location to a Message

With a MAX message, you can use the MaxOptions class to add message options.

use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('');

// Create Max options
$maxOptions = (new MaxOptions())
    ->chatId('111111')
    ->parseMode('html')
    ->location(48.8566, 2.3522);

// Add the custom options to the chat message and send the message
$chatMessage->options($maxOptions);

$chatter->send($chatMessage);

Adding Contact to a Message

With a Max message, you can use the MaxOptions class to add message options.

use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('');
// Create MAX options
$maxOptions = (new MaxOptions())
    ->chatId('111111')
    ->parseMode('html');

// Via vCard 
$vCard = 'BEGIN:VCARD
VERSION:3.0
N:Doe;John;;;
FN:John Doe
EMAIL;type=INTERNET;type=WORK;type=pref:johnDoe@example.org
TEL;type=WORK;type=pref:+330186657200
END:VCARD';
$maxOptions->contact(null, vcfInfo: $vCard);
    
// Via contactId (userId from MAX) 
$maxOptions->contact(null, contactId: 222222);

// Add the custom options to the chat message and send the message
$chatMessage->options($maxOptions);

$chatter->send($chatMessage);

Updating Messages

When working with interactive callback buttons, you can use the MaxOptions to reference a previous message to edit.

use Symfony\Component\Notifier\Bridge\Max\Reply\Markup\Button\InlineKeyboardButton;
use Symfony\Component\Notifier\Bridge\Max\Reply\Markup\InlineKeyboardMarkup;
use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('Are you really sure?');

$maxOptions = (new MaxOptions())
    ->chatId($chatId)
    ->edit($messageId) // extracted from callback payload or SentMessage
    ->keyboard((new InlineKeyboardMarkup())
        ->addButton((new KeyboardButton("Absolutely"))->callback("yes"))
        ->addRow()
        ->addButton((new KeyboardButton("open symfony"))->link("https://symfony.com"))
    );

Deleting Messages

When working with interactive callback buttons, you can use the MaxOptions to reference a previous message to delete.

use Symfony\Component\Notifier\Bridge\Max\Reply\Markup\Button\InlineKeyboardButton;
use Symfony\Component\Notifier\Bridge\Max\Reply\Markup\InlineKeyboardMarkup;
use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('Are you really sure?');

$maxOptions = (new MaxOptions())
    ->chatId($chatId)
    ->delete($messageId); // extracted from callback payload or SentMessage

Answering Callback Queries

The MaxOptions::answerCallbackQuery() method was introduced in Symfony 6.3.

When sending message with inline keyboard buttons with callback data, you can use MaxOptions to answer callback queries.

use Symfony\Component\Notifier\Bridge\Max\MaxOptions;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('Thank you!');
$maxOptions = (new MaxOptions())
    ->chatId($chatId)
    ->answerCallbackQuery(
        callbackQueryId: '12345', // extracted from callback
        notification: true
    );

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固