channelresponsechannel.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Extend the IMChannel class to allow commands to send messages
  6. * to a channel instead of PMing a user
  7. *
  8. * PHP version 5
  9. *
  10. * LICENCE: This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category Network
  24. * @package StatusNet
  25. * @author Luke Fitzgerald <lw.fitzgerald@googlemail.com>
  26. * @copyright 2010 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET') && !defined('LACONICA')) {
  31. exit(1);
  32. }
  33. class ChannelResponseChannel extends IMChannel {
  34. protected $ircChannel;
  35. /**
  36. * Construct a ChannelResponseChannel
  37. *
  38. * @param IMplugin $imPlugin IMPlugin
  39. * @param string $ircChannel IRC Channel to reply to
  40. * @return ChannelResponseChannel
  41. */
  42. public function __construct($imPlugin, $ircChannel) {
  43. $this->ircChannel = $ircChannel;
  44. parent::__construct($imPlugin);
  45. }
  46. /**
  47. * Send a message using the plugin
  48. *
  49. * @param User $user User
  50. * @param string $text Message text
  51. * @return void
  52. */
  53. public function output($user, $text) {
  54. $text = $user->nickname.': ['.common_config('site', 'name') . '] ' . $text;
  55. $this->imPlugin->sendMessage($this->ircChannel, $text);
  56. }
  57. }