在phpmsnclass 中添加修改显示名称和个人签名的处理

修改方法:

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'];
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值