modules/echo.php
author Dan
Tue, 20 Jan 2009 22:08:17 -0500
changeset 52 a8f0e99883d1
parent 51 508400fc5282
permissions -rw-r--r--
Web interface can now update with AJAX
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     1
<?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     2
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     3
eb_hook('event_channel_msg', 'echo_event_channel_msg($chan, $message);');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
eb_hook('event_privmsg', 'echo_event_privmsg($message);');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
function echo_event_channel_msg(&$chan, &$message)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
  global $privileged_list;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
  
51
508400fc5282 Major change to permissions backend - performs whois check (only supported blitzed and freenode right now) and advanced permissions supported.
Dan
parents: 42
diff changeset
    10
  if ( preg_match('/^\!echo /', $message['message']) && check_permissions($message['nick'], array('context' => 'echo')) )
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
    $chan->msg(eb_censor_words(preg_replace('/^\!echo /', '', $message['message'])), true);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
}
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
function echo_event_privmsg($message)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
  global $privileged_list;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
  
51
508400fc5282 Major change to permissions backend - performs whois check (only supported blitzed and freenode right now) and advanced permissions supported.
Dan
parents: 42
diff changeset
    20
  if ( preg_match("/^(?:\!echo-|\/msg )([#&][^\007, \r\n\a\t]+) (.+)/", $message['message'], $match) && check_permissions($message['nick'], array('context' => 'echo')) )
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
    global $libirc_channels;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
    $channel_name =& $match[1];
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
    if ( isset($libirc_channels[$channel_name]) && is_object($libirc_channels[$channel_name]) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
    {
41
1d854f22ac5a Fixed: echo module was echoing back commands
Dan
parents: 40
diff changeset
    26
      $libirc_channels[$channel_name]->msg(eb_censor_words($match[2]), true);
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
  }
51
508400fc5282 Major change to permissions backend - performs whois check (only supported blitzed and freenode right now) and advanced permissions supported.
Dan
parents: 42
diff changeset
    29
  else if ( preg_match("/^(?:\!pm|\/msg) ([^\007, \r\n\a\t]+) (.+)/", $message['message'], $match) && check_permissions($message['nick'], array('context' => 'pm'), false) )
39
4027a5b47db5 echo: added ability to PM people with !pm [nick] [message]
Dan
parents: 8
diff changeset
    30
  {
4027a5b47db5 echo: added ability to PM people with !pm [nick] [message]
Dan
parents: 8
diff changeset
    31
    global $irc;
4027a5b47db5 echo: added ability to PM people with !pm [nick] [message]
Dan
parents: 8
diff changeset
    32
    $irc->privmsg($match[1], eb_censor_words($match[2]));
4027a5b47db5 echo: added ability to PM people with !pm [nick] [message]
Dan
parents: 8
diff changeset
    33
  }
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
}