예제 #1
0
        /// <summary>
        /// 指定机器人类型,创建、注册、返回新的机器人
        /// </summary>
        /// <param name="type"></param>
        /// <param name="isDefault"></param>
        /// <returns></returns>
        public RobotOfBase Register(Action <RobotOfBase> onRefreshContact, Action <RobotOfBase, WXMsg> onMsg, RobotEnum type, bool isDefault = false)
        {
            RobotOfBase rt = null;

            switch (type)
            {
            case RobotEnum.Tuling:
            {
                rt = new RobotOfTuling(idMgr.CurrentIdentity);
                break;
            }

            default:
            {
                rt = new RobotOfBase(idMgr.CurrentIdentity);
                break;
            }
            }
            if (rt != null)
            {
                robotList[rt.robotId] = rt;
                if (isDefault || this.DefaultRobot == null)
                {
                    DefaultRobot = rt;
                }
                //执行登录流程,等待用户扫描二维码登录
                rt.LoginCheck(onRefreshContact, onMsg);
            }
            return(rt);
        }
예제 #2
0
        public BaseContact(RobotOfBase _parent, string name)
        {
            JObject obj = new JObject();

            obj["UserName"] = name;

            this.parent = _parent;
            this.info   = obj;
            this.Id     = obj["UserName"].ToString();;
        }
예제 #3
0
        /// <summary>
        /// 根据网络数据,构造聊天室对象
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public BaseContact(RobotOfBase _parent, JObject obj)
        {
            this.parent = _parent;
            this.info   = obj;

            this.Id              = obj["UserName"].ToString();;
            this.RemarkName      = obj.GetValue("RemarkName") != null ? obj["RemarkName"].ToString() : "";
            this.NickName        = obj.GetValue("NickName") != null ? obj["NickName"].ToString() : "";
            this.DisplayName     = obj.GetValue("DisplayName") != null ? obj["DisplayName"].ToString() : "";
            this.City            = obj.GetValue("City") != null ? obj["City"].ToString() : "";
            this.HeadImgUrl      = obj.GetValue("HeadImgUrl") != null ? obj["HeadImgUrl"].ToString() : "";
            this.Province        = obj.GetValue("Province") != null ? obj["Province"].ToString() : "";
            this.PYQuanPin       = obj.GetValue("PYQuanPin") != null ? obj["PYQuanPin"].ToString() : "";
            this.RemarkPYQuanPin = obj.GetValue("RemarkPYQuanPin") != null ? obj["RemarkPYQuanPin"].ToString() : "";
            this.Sex             = obj.GetValue("Sex") != null ? obj["Sex"].ToString() : "";
            this.Signature       = obj.GetValue("Signature") != null ? obj["Signature"].ToString() : "";
        }
예제 #4
0
 private string tuling_auto_reply(string uid, string msg)
 {
     if (!String.IsNullOrEmpty(WXConfig.tuling_key))
     {
         string  url     = "http://www.tuling123.com/openapi/api";
         string  user_id = uid.Replace("@", "").Substring(0, 32);
         JObject body    = RobotOfBase.createJObject(new Dictionary <string, object>()
         {
             { "key", WXConfig.tuling_key },
             { "info", msg },
             { "userid", user_id },
         });
         string result   = "知道啦";
         string init_str = BaseService.fetchString(url, body);
         if (!String.IsNullOrEmpty(init_str))
         {
             JObject respond = JsonConvert.DeserializeObject(init_str) as JObject;
             if (respond["code"].ToString() == "100000")
             {
                 result = respond["text"].ToString().Replace("<br>", "  ");
             }
             else if (respond["code"].ToString() == "200000")
             {
                 result = respond["url"].ToString();
             }
             else if (respond["code"].ToString() == "302000")
             {
                 foreach (JObject k in respond["list"])
                 {
                     result = result + "【" + k["source"] + "】 " + k["article"] + "\t" + k["detailurl"] + "\n";
                 }
             }
             else
             {
                 result = respond["text"].ToString().Replace("<br>", "  ");
             }
         }
         return(result);
     }
     else
     {
         return("知道啦");
     }
 }
예제 #5
0
 public Chatroom(RobotOfBase _parent, string name) : base(_parent, name)
 {
     this.type = ContactTypeEnum.Group;
 }
예제 #6
0
 public Chatroom(RobotOfBase _parent, JObject obj) : base(_parent, obj)
 {
     this.type = ContactTypeEnum.Group;
 }
예제 #7
0
 public PublicContact(RobotOfBase _parent, JObject obj) : base(_parent, obj)
 {
     this.type = ContactTypeEnum.Public;
 }
예제 #8
0
 public SelfContact(RobotOfBase _parent, JObject obj) : base(_parent, obj)
 {
     this.type = ContactTypeEnum.Self;
 }
예제 #9
0
 public SpecialContact(RobotOfBase _parent, JObject obj) : base(_parent, obj)
 {
     this.type = ContactTypeEnum.Special;
 }
예제 #10
0
 public ChatroomManager(RobotOfBase _parent)
 {
     this.parent = _parent;
 }