Exemplo n.º 1
0
func (m *Admin) bot_status(cmd string, msg xmpp.Chat) {
	// cmd is "status chat 正在聊天中..."
	var info = ""
	tokens := strings.SplitN(cmd, " ", 3)
	if len(tokens) == 3 {
		info = tokens[2]
	}
	if utils.IsValidStatus(tokens[1]) {
		m.bot.SetStatus(tokens[1], info)
	} else {
		m.bot.ReplyAuto(msg, "设置状态失败,有效的状态为: away, chat, dnd, xa.")
	}
}
Exemplo n.º 2
0
func parseArgs() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: xmppbot [options]\n")
		flag.PrintDefaults()
		os.Exit(2)
	}

	flag.Parse()

	if cfg.Account.Username == "" || cfg.Account.Password == "" {
		if cfg.Setup.Debug && cfg.Account.Username == "" && cfg.Account.Password == "" {
			fmt.Fprintf(os.Stderr, "no Username or Password were given; attempting ANONYMOUS auth\n")
		} else if cfg.Account.Username != "" || cfg.Account.Password != "" {
			flag.Usage()
		}
	}
	if !utils.IsValidStatus(cfg.Setup.Status) {
		fmt.Fprintf(os.Stderr, "invalid status setup, allowed are: away, chat, dnd, xa.\n")
		os.Exit(1)
	}
}