package message

import (
	"regexp"
	"strings"
)

var chinaPhoneNoMatcher = regexp.MustCompile(`^(86|\+86)`)

func getReceiverType(id string) string {
	var idType string
	if len(id) == 0 {
		return "empty"
	}
	if strings.Contains(id, "ou_") {
		idType = "open_id"
	} else if strings.Contains(id, "oc_") {
		idType = "chat_id"
	} else if strings.Contains(id, "on_") {
		idType = "union_id"
	} else if strings.Contains(id, "@") {
		idType = "email"
	} else if strings.Contains(id, "https://") {
		idType = "webhook"
	} else {
		idType = "user_id"
	}
	return idType
}

func isDomestic(phoneNo string) bool {
	return chinaPhoneNoMatcher.MatchString(phoneNo)
}
