承接 ericsalerno/slzbot-irc 相关项目开发

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

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

ericsalerno/slzbot-irc

Composer 安装命令:

composer require ericsalerno/slzbot-irc

包简介

Simple event based irc bot written in PHP for fun.

README 文档

README

For fun and practice, I'm throwing together a super simple PHP based irc bot that runs from the command line (or a container).

The idea would be to make an event based Bot class that you can extend to add your own business logic to.

I hope it should go without saying, but never run this bot as root!

Usage

Include the library in your project with composer.

composer require ericsalerno/slzbot-irc

You can use the bot by including salernolabs/slzbot-irc with composer and activating it like this.

$bot = new \SlzBot\IRC\Bot();

$bot
    ->setServer('irc.efnet.org', 6667)
    ->setChannels('#ircphp')
    ->setUser('myBotNickname', 'SlzBot')
       //any events and commands you want to bind can go here
    ->connect();

Events

You can bind and respond to events that occur from the server. You can bind multiple event executors to a single event. For example, 376 is the IRC op code for the end of the MOTD. You can bind an event to autojoin channels like this.

$autoJoins = new \SlzBot\IRC\Events\AutoJoin();
$autoJoins->setAutoJoins(['#programming', '#irc', '#php']);

$bot
   ->addOpCodeEvent(376, $autoJoins)

There are some op codes and other events that Slzbot listens for in the \SlzBot\IRC\OpCodes class.

The event class must implement the \SlzBot\IRC\Events\EventInterface interface to work so feel free to create them in your project.

Commands

You can also bind commands to your bot so that it can listen for user requests. For example if a user types !uptime and you want to listen for that keyword, you can do something like this:

$command = new \SlzBot\IRC\Commands\Uptime();

$bot
    ->addCommand('uptime', $command);

This would make the bot listen for users to say "!uptime" and then it would execute the code within the class. In this case it would just say how long it was since the class was instantiated.

The command class must implement the \SlzBot\IRC\Commands\CommandInterface interface to work so feel free to create them in your project. You can also change the activation character from the default of '!' with setCommandActivationCharacter.

Sample

You can run a quick sample with the included generic bot. From the command line and assuming you are in the project's directory:

/path/to/php samples/generic/bot.php nickname #channel irc.yourservername

The generic bot expects several parameters. Run it without parameters to get usage info.

Usage: php samples/generic/bot.php <nickname> <channel> <server> [port]

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固