定制 rtippin/messenger-faker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

rtippin/messenger-faker

Composer 安装命令:

composer require rtippin/messenger-faker

包简介

Messenger Faker Commands

README 文档

README

Latest Version on Packagist Total Downloads Tests StyleCI License

Preview

This package is an addon for rtippin/messenger

It is NOT advised to install this in a production app.

Features:

  • Commands to mock realtime events such as knocks, typing, and marking read.
  • Command to seed realtime messages with typing.
  • Commands to seed attachment messages (images, documents, audio, videos).
  • Commands to seed system messages and message reactions.
  • FakerBot pre-registered with Messenger that allows you to trigger our commands through chat-bots.

Installation

Via Composer

$ composer require rtippin/messenger-faker --dev

Config

  • Default values for local storage location of the files we use when seeding.
    • When seeding using local files, a random file from the message types specified folder will be used.
    • When seeding image files with no url/local flag specified, it will use the default image url from the config.
  • Flag to enable or disable registering our FakerBot.

Defaults

'paths' => [
    'images' => storage_path('faker/images'),
    'documents' => storage_path('faker/documents'),
    'audio' => storage_path('faker/audio'),
    'videos' => storage_path('faker/videos'),
],

'default_image_url' => 'https://source.unsplash.com/random',

'enable_bot' => true,

To override the file paths, please publish our config and edit accordingly

$ php artisan vendor:publish --tag=messenger-faker

Commands

php artisan messenger:faker:knock {thread?}

  • Send a knock to the given thread.

php artisan messenger:faker:message {thread?} | --count=5 | --delay=2 | --admins | --silent

  • Make participants send messages. Will also emit typing and mark read.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many messages are sent.
  • --delay=X flag to set delay in seconds between each message.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:react {thread?} | --count=5 | --messages=5 | --delay=1 | --admins | --silent

  • Make participants add reactions to the latest messages.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many reactions are added.
  • --messages=X flag to set how many latest messages are chosen at random to be reacted to.
  • --delay=X flag to set delay in seconds between each reaction.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:system {thread?} | --type= | --count=1 | --delay=2 | --admins | --silent

  • Make participants send system messages.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many system messages are sent.
  • --type=X flag to set the system message type. 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103
  • --delay=X flag to set delay in seconds between each system message.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:image {thread?} | --count=1 | --delay=2 | --admins | --local | --url= | --silent

  • Make participants send image messages. Will also emit typing and mark read. If --local or --url is not set, we pull images from the default image url in the config.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many images are sent.
  • --delay=X flag to set delay in seconds between each image.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --local flag will choose a random image from the directory specified for images in the config file.
  • --url=X flag lets you directly specify an image URL to download and emit.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:document {thread?} | --count=1 | --delay=2 | --admins | --url= | --silent

  • Make participants send document messages. Will also emit typing and mark read. If --url is not set, will choose a random document from the directory specified for documents in the config file.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many documents are sent.
  • --delay=X flag to set delay in seconds between each document.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --url=X flag lets you directly specify a document URL to download and emit.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:audio {thread?} | --count=1 | --delay=2 | --admins | --url= | --silent

  • Make participants send audio messages. Will also emit typing and mark read. If --url is not set, will choose a random audio file from the directory specified for audio in the config file.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many audio files are sent.
  • --delay=X flag to set delay in seconds between each audio file.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --url=X flag lets you directly specify an audio URL to download and emit.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:video {thread?} | --count=1 | --delay=2 | --admins | --url= | --silent

  • Make participants send video messages. Will also emit typing and mark read. If --url is not set, will choose a random video file from the directory specified for videos in the config file.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many video files are sent.
  • --delay=X flag to set delay in seconds between each video file.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --url=X flag lets you directly specify a video URL to download and emit.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:random {thread?} | --count=5 | --delay=2 | --admins | --silent

  • Send random commands using ['audio', 'document', 'image', 'knock', 'message', 'react', 'system', 'typing']
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --count=X flag to set how many messages are sent.
  • --delay=X flag to set delay in seconds between each message.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.
  • --silent flag that will suppress all broadcast and event dispatches.

php artisan messenger:faker:read {thread?} | --admins

  • Mark participants in the thread as read.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --admins flag will only use admin participants if using a group thread.

php artisan messenger:faker:typing {thread?} | --admins

  • Make participants in the thread type.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --admins flag will only use admin participants if using a group thread.
  • --bots flag will only use bots if using a group thread.

php artisan messenger:faker:unread {thread?} | --admins

  • Mark participants in the thread as unread.
  • {thread?} ID of the thread you want to seed. Random if not set.
  • --admins flag will only use admin participants if using a group thread.

FakerBot

  • Our service provider will have already registered FakerBot for you if enabled in our config.
  • You should ensure your main messenger.php config has the bots feature enabled.
  • When you use the messenger API to add handlers onto a bot, you will see our bot listed.
  • Once our FakerBot is attached to a thread's bot, you can trigger it by sending a message using the following syntax:
    • !faker {action} {count?} {delay?}
  • Available actions: audio, document, image, knock, message, random, react, system, typing, video

rtippin/messenger-faker 适用场景与选型建议

rtippin/messenger-faker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.75k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2021 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「faker」 「laravel」 「Messenger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rtippin/messenger-faker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rtippin/messenger-faker 我们能提供哪些服务?
定制开发 / 二次开发

基于 rtippin/messenger-faker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-17