定制 exan/fenrir 二次开发

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

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

exan/fenrir

Composer 安装命令:

composer require exan/fenrir

包简介

Discord API & WS wrapper

README 文档

README

Fenrir

PHP Discord Interface.

Fenrir Code Quality Fenrir Unit Tests

About

Fenrir is a mostly plain wrapper over Discords APIs/gateway. There is no caching built in, this is for the user to implement themselves.

If you're looking for something thats easier to use, has caching OOTB, you could consider Laracord

Fenrir heavily relies on ReactPHP for async operations. Knowing the basics of async PHP is recommended before diving in.

Join the Discord for discussion & support!

Install

composer require ragnarok/fenrir

Example bot

use Ragnarok\Fenrir\Bitwise\Bitwise;
use Ragnarok\Fenrir\Constants\Events;
use Ragnarok\Fenrir\Discord;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Gateway\Events\MessageCreate;
use Ragnarok\Fenrir\Rest\Helpers\Channel\MessageBuilder;

require './vendor/autoload.php';

$discord = new Discord('TOKEN');

$discord
    ->withGateway(Bitwise::from(
        Intent::GUILD_MESSAGES,
        Intent::DIRECT_MESSAGES,
        Intent::MESSAGE_CONTENT,
    ))
    ->withRest();

$discord->gateway->events->on(Events::MESSAGE_CREATE, function (MessageCreate $message) use ($discord) {
    if ($message->content === '!ping') {
        $discord->rest->channel->createMessage(
            $message->channel_id,
            (new MessageBuilder())
                ->setContent('pong!')
        );
    }
});

$discord->gateway->open(); // Nothing after this line is executed

REST-only example

use Ragnarok\Fenrir\Discord;
use Ragnarok\Fenrir\Rest\Helpers\Channel\MessageBuilder;

require './vendor/autoload.php';

$discord = new Discord('TOKEN');
$discord->withRest();

$discord->rest->channel->createMessage(
    'channel-id',
    (new MessageBuilder())
        ->setContent('Hi there!')
);

(Note: going with REST-only means you do NOT receive any events and your bot will appear offline)

For more examples, check out the examples directory

Support

Fenrir currently supports PHP 8.5+ Tests should pass nightly builds of newer versions, but this is not a supported usecase.

PHP Version Library version
8.5+ Current
8.2, 8.3, 8.4 < 1.2
8.1 < 1.0.1

Note: Bugfixes/features will not be backported to older versions. Older versions are as-is.

If you're using this in a Apache2/Nginx/etc webserver environment, you should probably limit yourself to only using Fenrir's REST capabilities. These environments typically don't allow long-running processes.

32-bit is not supported, though no hard limit is in place.

Contributing

Contributions are welcome. You can look for @todo to find something that requires attention. Please make sure to write tests where possible & make sure your code matches the phpcs configuration. Thanks!

Notice

The current underlying HTTP component is subject to change in the future. While the accesible API for it will remain similar, you should try to refrain from using it manually in your application.

exan/fenrir 适用场景与选型建议

exan/fenrir 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 523 次下载、GitHub Stars 达 9, 最近一次更新时间为 2023 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 exan/fenrir 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-20