Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接入wechaty AcceptUser接口需要改动的部分 #34

Open
xihuanhh opened this issue Sep 5, 2019 · 1 comment
Open

接入wechaty AcceptUser接口需要改动的部分 #34

xihuanhh opened this issue Sep 5, 2019 · 1 comment

Comments

@xihuanhh
Copy link
Collaborator

xihuanhh commented Sep 5, 2019

改动文件路径:
**server/chatbothub/chatbot.go**

改动:

type WechatFriendRequest struct {
	PayloadId	     string    `xml:"payloadid,attr" json:"payloadId"`
	PayloadType	     string    `xml:"payloadtype,attr" json:"payloadType"`
	FromUserName     string    `xml:"fromusername,attr" json:"fromUserName"`
	EncryptUserName  string    `xml:"encryptusername,attr" json:"encryptUserName"`
	FromNickName     string    `xml:"fromnickname,attr" json:"fromNickName"`
	Content          string    `xml:"content,attr" json:"content"`
	Fullpy           string    `xml:"fullpy,attr" json:"fullpy"`
	Shortpy          string    `xml:"shortpy,attr" json:"shortpy"`
	ImageStatus      string    `xml:"imagestatus,attr" json:"imageStatus"`
	Scene            string    `xml:"scene,attr" json:"scene"`
	Country          string    `xml:"country,attr" json:"country"`
	Province         string    `xml:"province,attr" json:"province"`
	City             string    `xml:"city,attr" json:"city"`
	Sign             string    `xml:"sign,attr" json:"sign"`
	Percard          string    `xml:"percard,attr" json:"percard"`
	Sex              string    `xml:"sex,attr" json:"sex"`
	Alias            string    `xml:"alias,attr" json:"alias"`
	Weibo            string    `xml:"weibo,attr" json:"weibo"`
	Albumflag        string    `xml:"albumflag,attr" json:"albumflag"`
	Albumstyle       string    `xml:"albumstyle,attr" json:"albumstyle"`
	Albumbgimgid     string    `xml:"albumbgimgid,attr" json:"albumbgimgid"`
	Snsflag          string    `xml:"snsflag,attr" json:"snsflag"`
	Snsbgimgid       string    `xml:"snsbgimgid,attr" json:"snsbgimgid"`
	Snsbgobjectid    string    `xml:"snsbgobjectid,attr" json:"snsbgobjectid"`
	Mhash            string    `xml:"mhash,attr" json:"mhash"`
	Mfullhash        string    `xml:"mfullhash,attr" json:"mfullhash"`
	Bigheadimgurl    string    `xml:"bigheadimgurl,attr" json:"bigheadimgurl"`
	Smallheadimgurl  string    `xml:"smallheadimgurl,attr" json:"smallheadimgurl"`
	Ticket           string    `xml:"ticket,attr" json:"ticket"`
	Opcode           string    `xml:"opcode,attr" json:"opcode"`
	Googlecontact    string    `xml:"googlecontact,attr" json:"googlecontact"`
	Qrticket         string    `xml:"qrticket,attr" json:"qrticket"`
	Chatroomusername string    `xml:"chatroomusername,attr" json:"chatroomusername"`
	Sourceusername   string    `xml:"sourceusername,attr" json:"sourceusername"`
	Sourcenickname   string    `xml:"sourcenickname,attr" json:"sourcenickname"`
	BrandList        BrandList `xml:"brandlist" json:"brandlist"`
}
func (bot *ChatBot) AcceptUser(actionType string, arId string, body string) error {
	o := &ErrorHandler{}
	if bot.ClientType == WECHATBOT {
		var msg WechatFriendRequest
		o.Err = json.Unmarshal([]byte(body), &msg)
		if o.Err != nil {
			return utils.NewClientError(utils.PARAM_INVALID, o.Err)
		}

		bot.Info("Action AcceptUser %s\n%s", msg.EncryptUserName, msg.Ticket)
		o.SendAction(bot, arId, AcceptUser, o.ToJson(map[string]interface{}{
			"stranger": msg.EncryptUserName,
			"ticket":   msg.Ticket,
			"payloadid": msg.PayloadId,
			"payloadtype": msg.PayloadType,
			"payloadcontactid": msg.FromUserName,
			"content": msg.Content,
		}))
	} else {
		return utils.NewClientError(utils.METHOD_UNSUPPORTED,
			fmt.Errorf("c[%s] not support %s", bot.ClientType, actionType))
	}

	return o.Err
}
@hawkwithwind
Copy link
Owner

{
  "friendship": {
    "domain": null,
    "_events": {},
    "_eventsCount": 0,
    "id": "d1567d5e-494e-4f23-b3e0-a9b8b5600e48",
    "payload": {
      "contactId": "keji_xihuanhh",
      "hello": "我是斩月",
      "id": "ef5f3999-792e-4299-bcc7-612758345933",
      "stranger": "v1_563fbf8c435f7a6fd79ae3f873eba4c5137ea34716292edb1f31e9bd36f2c5a1c65ac7593c7e09deaa4903428dc78777@stranger",
      "ticket": "v1_563fbf8c435f7a6fd79ae3f873eba4c5137ea34716292edb1f31e9bd36f2c5a1c65ac7593c7e09deaa4903428dc78777@stranger",
      "timestamp": 1567499415199,
      "type": 2
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants