func MsTrans(clientID, clientSecret, in string) (out string) { t := microsoft.NewTranslator(clientID, clientSecret) from, err := MsDetect(clientID, clientSecret, in) if err != nil { return "警报!弹药系统过载!请放宽后重试" } switch from { case "zh-CHS", "zh-CHT": out, err = t.Translate(in, from, "en") default: out, err = t.Translate(in, from, "zh-CHS") } if err != nil { return "可怜的群组娘被母舰放逐了X﹏X" } return out }
func (m *MsTrans) New() { m.t = microsoft.NewTranslator( conf.GetItem("msTransId"), conf.GetItem("msTransSecret")) }
func MsDetect(clientID, clientSecret, in string) (string, error) { t := microsoft.NewTranslator(clientID, clientSecret) return t.Detect(in) }
func (m *MsTrans) New() { m.t = microsoft.NewTranslator(msID, msSecret) }