Overview

Packages

  • None
  • WxRobot
    • Admin
    • Cmd
    • CoreFunctions
    • Exends
    • Install
    • Table
    • Uninstall
    • WxSDK

Classes

  • ErrorCode
  • PKCS7Encoder
  • Prpcrypt
  • SHA1
  • Weixin_BaseCore
  • WeiXin_SDK
  • Weixin_Template
  • WXBizMsgCrypt
  • WxRobot_Admin
  • WxRobot_Admin_Menu_Extends
  • WxRobot_Admin_Menu_Instro
  • WxRobot_Admin_Menu_Menu
  • WxRobot_Admin_Menu_Records
  • WxRobot_Admin_Menu_Reply
  • WxRobot_Admin_Menu_Setting
  • WxRobot_Admin_Menu_Statistics
  • WxRobot_Cmd
  • WxRobot_Cmd_Event
  • WxRobot_Cmd_Event_User
  • WxRobot_Cmd_Text
  • WxRobot_Extends
  • WxRobot_Install
  • WxRobot_Robot
  • WxRobot_SDK
  • WxRobot_Table_Extends
  • WxRobot_Table_Menu
  • WxRobot_Table_Records
  • WxRobot_Table_Reply
  • WxRobot_Uninstall
  • WxRobot_Wp
  • XMLParse

Functions

  • wx_admin_log
  • wx_is_xml
  • wx_notice_msg
  • wx_parse_xml
  • wx_random_big_pic
  • wx_random_small_pic
  • wx_request_array
  • wx_request_decode
  • wx_request_is_encode
  • wx_request_xml
  • wx_send_encode
  • Overview
  • Package
  • Class
  1: <?php
  2: /**
  3:  *  WxRobot 命令响应类
  4:  *  
  5:  *  @author     midoks
  6:  *  @category   WxRobot
  7:  *  @package    WxRobot/Cmd
  8:  *  @since      5.3.0
  9:  */
 10: 
 11: /**
 12:  * WxRobot_Cmd_Event_User 自定义事件响应类
 13:  */
 14: class WxRobot_Cmd_Event_User{   
 15:     
 16:     /**
 17:      * WxRobot_Cmd_Text Instance
 18:      */
 19:     public static $_instance = null;
 20: 
 21:     public $callback = array('today','n', 'h', 'r', '?');
 22: 
 23:     /**
 24:      * 构造函数
 25:      *
 26:      * @return void
 27:      */
 28:     public function __construct(){
 29:         $this->extends = WxRobot_Extends::instance();
 30:         $this->wxSdk   = WxRobot_SDK::instance();
 31:     }
 32: 
 33:     /**
 34:      * WxRobot 文本消息处理类实例化
 35:      * 
 36:      * @return WxRobot_Cmd_Text instance
 37:      */
 38:     public static function instance(){
 39:         if( is_null (self::$_instance)){
 40:             self::$_instance = new self();
 41:         }
 42:         return self::$_instance;
 43:     }
 44: 
 45:     /**
 46:      * 设置对象
 47:      *  
 48:      * @param object $obj 模板引用对象
 49:      * @return xml
 50:      */
 51:     public function setValue($obj){
 52:         $this->obj = $obj;
 53:     }
 54: 
 55:     /**
 56:      * 事件响应
 57:      *
 58:      * @param string $key 键值
 59:      * @return mixed
 60:      */
 61:     public function go($key){
 62:         $data = WxRobot_Table_Menu::instance()->weixin_get_menu_data();
 63: 
 64:         if($data){
 65:             foreach($data as $k=>$v){
 66:                 if($key == $v['menu_key']){
 67:                     return $this->choose($v['menu_callback'], $v['menu_name']);
 68:                 }
 69:             }
 70:         }
 71: 
 72:         return  $this->obj->help_info('key:'.$key."\n".'用户自定菜单响应未定义?');
 73:     }   
 74: 
 75:     /**
 76:      * 事件选择
 77:      * 
 78:      * @param string $case 时间的回调值
 79:      * @param string $name 菜单名
 80:      * @return xml
 81:      */
 82:     public function choose($case, $name){
 83:         if($wp_plugins = $this->extends->dealwith('menu', $name)){
 84:             return $wp_plugins;
 85:         }
 86: 
 87:         include_once('class-wx-cmd-text.php');
 88:         if(in_array($case, $this->callback) || in_array(substr($case, 0, 1), $this->callback)){//预定义
 89:             $text = WxRobot_Cmd_Text::instance();
 90:             $text->setValue($this->obj, $case);
 91:             $case = $text->replay();
 92:             return $case;
 93:         }else{
 94:             $reply =  $this->wxSdk->toMsgText($case);
 95:             return $reply;
 96:         }
 97:     }
 98: }
 99: ?>
100: 
API documentation generated by ApiGen