修改方法:
1。修改phpmsnclass.class,添加两个处理
2。在机器人中添加调用函数my_nln_function
3。添加处理的函数
1。修改phpmsnclass.class,添加两个处理
case 'NLN':
// NS: <<< NLN IDL ihandy1@live.cn 1 live_ihandy 32 0
@list(/* NLN */, /* IDL */,$u_email,/* 1 */, $newname) = @explode(' ', $data);
//file_put_contents('/tmp/msn_prp.txt',$data);
$this->log_message("*** someone redisplay name: $data");
if ($my_nln_function && function_exists($my_nln_function) && is_callable($my_nln_function))
$my_nln_function($u_email,$newname,$this->user);
break;
case 'UBX':
//>>> UBX sender@email.com (Length)/r/n
if ($this->protocol == 'MSNP11' || $this->protocol == 'MSNP13')
@list(/* UBX */, $u_email, $size) = @explode(' ', $data);
// NS: <<< UBX source@mail.addr.ess networkid length
// NS: <<< UBX ihandy1@live.cn 1 427
if ($this->protocol == 'MSNP14'|| $this->protocol == 'MSNP15')
@list(/* UBX */, $u_email,/* 1 */, $size) = @explode(' ', $data);
$this->log_message("*** someone modify personal message: $data");
if(!empty($u_email) && !empty($size) ){
$data = $this->readdata($size);
$start = strpos($data, '<PSM>');
$end = strpos($data, '</PSM>');
if ($start === false || $end === false || $start > $end) break;
$start += 5;
$sPSM = substr($data, $start, $end - $start);
if ($my_nln_function && function_exists($my_nln_function) && is_callable($my_nln_function))
$my_nln_function($u_email,$sPSM,$this->user);
}
break;
2。在机器人中添加调用函数my_nln_function
'nln_user_function' => 'reDisplayname',
添加之后的调用
$msn->doLoop(array(
'user' => $msn_acct,
'password' => $msn_password,
'alias' => $msn_alias,
'psm' => $msn_psm,
'msg_function' => 'processMsg',
'add_user_function' => 'addContact',
'remove_user_function' => 'removeContact',
'nln_user_function' => 'reDisplayname',
'use_ping' => 600
)
);
3。添加处理的函数
另外添加一个处理函数
// your function to process message from someone
function reDisplayname($email, $newname, $msnbot)
{
$network = 1;
$from = $email;
$user = $msnbot;
global $aIgnoreAccts;
global $aCommand;
global $comandSign;
global $txtMsg;
global $adodb_include;
global $notify_db_type,$notify_db_host, $notify_db_user, $notify_db_pass, $notify_db_name,$notify_table_name ,$user_info_table_name,$interface_say8_set_path,$msnbot_path;
//return $adodb_include;
//include_once('notify_config.php');
if (!isset($adodb_include))
return $txtMsg['add_fail'];
//return "$adodb_include DB add notify Setting Error!";
include_once($adodb_include);
//checkAccount
// from myself? ignore it
//if ($from == $msn_acct) return '';
if ($from == $user) return '';
// also ignore other bot
if (is_array($aIgnoreAccts)) {
if (in_array($from, $aIgnoreAccts)) return '';
}
$msg = "NOTIFY:".date("YmdHis",time())."/n";
$msg .= "/n".$newname;
if (strncasecmp($msg, 'NOTIFY:', 7) == 0) {
// notfiy function
include_once('notify_add.php');
if (function_exists('addNotifyMsg') && is_callable('addNotifyMsg')) {
return addNotifyMsg(array('user' => $user,
'from' => $from,
'network' => $network,
'msg' => $msg,
'host' =>array($notify_db_type,$notify_db_host, $notify_db_user, $notify_db_pass, $notify_db_name,$notify_table_name ,$user_info_table_name,$interface_say8_set_path,$msnbot_path,$txtMsg)
));
}
}
exit;
//return $txtMsg['add_fail'];
}