| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
class Phergie_Plugin_Ctcp extends Phergie_Plugin_Abstract_Base |
|---|
| 7 |
{ |
|---|
| 8 |
public function onTime() |
|---|
| 9 |
{ |
|---|
| 10 |
$source = $this->event->getSource(); |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
$this->doTimeReply($source); |
|---|
| 14 |
} |
|---|
| 15 |
|
|---|
| 16 |
public function onVersion() |
|---|
| 17 |
{ |
|---|
| 18 |
$source = $this->event->getSource(); |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
$this->doVersionReply($source); |
|---|
| 22 |
} |
|---|
| 23 |
|
|---|
| 24 |
public function onPing() |
|---|
| 25 |
{ |
|---|
| 26 |
$source = $this->event->getSource(); |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
$handshake = $this->event->getArgument(1); |
|---|
| 30 |
if ($handshake) { |
|---|
| 31 |
$this->doPingReply($source, $handshake); |
|---|
| 32 |
} |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
public function onCtcp() |
|---|
| 36 |
{ |
|---|
| 37 |
$source = $this->event->getSource(); |
|---|
| 38 |
|
|---|
| 39 |
$ctcp = strtoupper($this->event->getArgument(1)); |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
if ($ctcp == 'PING') { |
|---|
| 43 |
$this->doCtcpReply($source, 'pong'); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
else if ($ctcp == 'SOURCE') { |
|---|
| 47 |
$this->doCtcpReply($source, 'source', 'svn2.assembla.com:/svn/phergie/trunk/Phergie/:'); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
else if ($ctcp == 'FINGER') { |
|---|
| 51 |
$name = $this->getIni('nick'); |
|---|
| 52 |
$realname = $this->getIni('realname'); |
|---|
| 53 |
$username = $this->getIni('username'); |
|---|
| 54 |
|
|---|
| 55 |
$finger = (!empty($realname) ? $realname : $name) . ' (' . (!empty($username) ? $username : $name) . ')'; |
|---|
| 56 |
$this->doCtcpReply($source, 'finger', $finger); |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
else if ($ctcp == 'UPTIME') { |
|---|
| 60 |
$uptime = $this->getCountdown(time() -$this->getStartTime()); |
|---|
| 61 |
$this->doCtcpReply($source, 'uptime', $uptime); |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
} |
|---|
| 65 |
?> |
|---|
| 66 |
|
|---|