modules/greeting.php
author Dan
Tue, 20 Jan 2009 22:08:07 -0500
changeset 51 508400fc5282
parent 48 d793361a27ec
permissions -rw-r--r--
Major change to permissions backend - performs whois check (only supported blitzed and freenode right now) and advanced permissions supported.
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_raw_message', 'greeting_event($chan, $message);');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
function greeting_event(&$chan, &$message)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
  static $part_list = array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
  switch($message['action'])
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
    case 'JOIN':
48
d793361a27ec Greeting: bot no longer greets itself
Dan
parents: 8
diff changeset
    12
      if ( $message['nick'] === $GLOBALS['nick'] )
d793361a27ec Greeting: bot no longer greets itself
Dan
parents: 8
diff changeset
    13
        break;
d793361a27ec Greeting: bot no longer greets itself
Dan
parents: 8
diff changeset
    14
      
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
      $wb = false;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
      if ( isset($part_list[$message['nick']]) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
        if ( $part_list[$message['nick']] + 1800 >= time() )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    20
          $chan->msg("Welcome back.");
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
          $wb = true;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
      if ( !$wb )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
        $append = '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
        eval(eb_fetch_hook('event_greeting'));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
        $chan->msg(eb_censor_words("Hi, {$message['nick']}.$append"));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    29
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
      break;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
    case 'PART':
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
      $part_list[$message['nick']] = time();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
      break;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
}