- Notifications
You must be signed in to change notification settings - Fork1
Phergie plugin for monitoring and providing access to user mode information
License
phergie/phergie-irc-plugin-react-usermode
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Phergie plugin for monitoring and providing access to user mode information.
The recommended method of installation isthrough composer.
{"require": {"phergie/phergie-irc-plugin-react-usermode":"~2" }}See Phergie documentation for more information oninstalling and enabling plugins.
new \Phergie\Irc\Plugin\React\UserMode\Plugin(array(// All configuration is optional'prefixes' =>array('@' =>'o','+' =>'v', ),))
When the bot joins a channel, it receives a343 RPL_NAMREPLY server eventcontaining user nicks prefixed with characters indicative of their respectivechannel-specific user modes.
This plugin's only configuration setting allowsthis mappingof prefix to user mode characters to be overridden in cases where a networkuses non-standard mappings. The plugin's default mapping includes severalstandard prefixes, which are shown in the example above, and several commonlyused non-standard prefixes.
usePhergie\Irc\Bot\React\PluginInterface;usePhergie\Irc\Bot\React\EventQueueInterface;usePhergie\Irc\Plugin\React\Command\CommandEvent;class FooPluginimplements PluginInterface{/** * @var \Phergie\Irc\Plugin\React\UserMode\Plugin */protected$userMode;publicfunction__construct(array$config) {// Validate $config['userMode']$this->userMode =$config['userMode']; }publicfunctiongetSubscribedEvents() {returnarray('command.foo' =>'handleFooCommand', ); }publicfunctionhandleFooCommand(CommandEvent$event,EventQueueInterface$queue) {$connection =$event->getConnection();$nick =$event->getNick();$params =$event->getParams();$source =$event->getCommand() ==='PRIVMSG' ?$params['receivers'] :$params['nickname'];// Ignore events sent directly to the bot rather than to a channelif ($connection->getNickname() ===$source) {return; }// Don't process the command if the user is not a channel operatorif (!$this->userMode->userHasMode($connection,$source,$nick,'o')) {return; }// The user is a channel operator, continue processing the command// ... }}
To run the unit test suite:
curl -s https://getcomposer.org/installer | phpphp composer.phar install./vendor/bin/phpunitReleased under the BSD License. SeeLICENSE.
About
Phergie plugin for monitoring and providing access to user mode information
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.
