-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIRC.php
79 lines (67 loc) · 1.82 KB
/
IRC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?PHP
class IRC {
const CTCP = "\1";
const BOLD = "\2";
const COLOR = "\3";
const ORIGINAL = "\15";
const REVERSE = "\22";
const UNDERLINE = "\31";
const WHITE = 0;
const BLACK = 1;
const DARKBLUE = 2;
const GREEN = 3;
const RED = 4;
const MAROON = 5;
const PURPLE = 6;
const ORANGE = 7;
const YELLOW = 8;
const LIMEGREEN = 9;
const TEAL = 10;
const CYAN = 11;
const BLUE = 12;
const PINK = 13;
const GRAY = 14;
const LIGHTGRAY = 15;
public static function ctcp( $type, $data ) {
return IRC::CTCP . strtoupper( $type ) . ' ' . $data . IRC::CTCP;
}
public static function bold( $data ) {
return IRC::BOLD . $data . IRC::BOLD;
}
public static function color( $foreground, $background = null, $data ) {
$colorCode = str_pad( $foreground, '0', 2, STR_PAD_LEFT );
if( $background != null )
$colorCode .= ',' . str_pad( $background, '0', 2, STR_PAD_LEFT );
return IRC::COLOR . $colorCode . $data . IRC::COLOR;
}
public static function original( $data ) {
return IRC::ORIGINAL . $data;
}
public static function reverse( $data ) {
return IRC::REVERSE . $data . IRC::REVERSE;
}
public static function underline( $data ) {
return IRC::UNDERLINE . $data . IRC::UNDERLINE;
}
public static function atime( $time ) {
if( is_numeric( $time ) )
return $time;
$ret = 0;
$timePart = '';
for( $i = 0 ; $i < strlen( $time ) ; $i++ )
if( is_numeric( $time[ $i] ) )
$timePart .= $time[ $i ];
else {
switch( $time[ $i ] ) {
case 'd': $timePart *= 86400; break;
case 'h': $timePart *= 3600; break;
case 'm': $timePart *= 60; break;
}
$ret += $timePart;
$tmp = 0;
}
$ret += $timePart;
return $ret;
}
}
?>