-
Notifications
You must be signed in to change notification settings - Fork 0
/
mySmartIRC.php
51 lines (39 loc) · 1.22 KB
/
mySmartIRC.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
<?php
class mySmartIRC extends Net_SmartIRC
{
private $_irc_encoding;
private $_source_encoding;
private $_converter;
function init($irc_encoding, $source_encoding) {
$this->_irc_encoding = $irc_encoding;
$this->_source_encoding = $source_encoding;
if (strtolower($irc_encoding) == strtolower($source_encoding)) {
$this->_converter = false;
} else {
$this->_converter = true;
}
}
function _rawsend($data) {
$data = $this->_convertEncoding($data);
return parent::_rawsend($data);
}
function _handleactionhandler(&$ircdata) {
$ircdata->message = $this->_convertDecoding($ircdata->message);
parent::_handleactionhandler($ircdata);
}
private function _convertEncoding($string) {
if ($this->_converter) {
return mb_convert_encoding(
$string, $this->_irc_encoding, $this->_source_encoding);
}
return $string;
}
private function _convertDecoding($string) {
if ($this->_converter) {
return mb_convert_encoding(
$string, $this->_source_encoding, $this->_irc_encoding);
}
return $string;
}
}
?>