Beispiel #1
0
func (d *Default) auth(answer string) {
	qs := conf.GetQuestions()
	index := time.Now().Hour() % len(qs)
	answer = strings.ToLower(answer)
	answer = strings.TrimSpace(answer)
	if d.FromPrivate {
		if d.isAuthed() {
			d.NewMessage(d.ChatID,
				"已经验证过了,你还想验证,你是不是傻?⊂彡☆))д`)`").
				ReplyToMessageID(d.Message.MessageID).Send()
			return
		}

		if qs[index].A.Has(answer) {
			conf.Redis.SAdd("tgAuthUser", strconv.Itoa(d.Message.From.ID))
			log.Printf("%d --- %s Auth OK\n",
				d.Message.From.ID, d.Message.From.UserName)
			d.NewMessage(d.ChatID,
				"验证成功喵~!\n原来你不是外星人呢😊").Send()
			d.setStatus("")
			d.NewMessage(d.ChatID,
				conf.List2StringInConf("help")).Send()
		} else {
			log.Printf("%d --- %s Auth Fail\n",
				d.Message.From.ID, d.Message.From.UserName)
			d.NewMessage(d.ChatID,
				"答案不对不对!你一定是外星人!不跟你玩了喵!\n"+
					"重新验证一下吧\n请问:"+qs[index].Q).Send()
		}
	}
}
Beispiel #2
0
func (d *Default) sendQuestion() {
	qs := conf.GetQuestions()
	index := time.Now().Hour() % len(qs)
	d.NewMessage(d.Message.From.ID,
		"需要通过中文验证之后才能使用本功能哟~\n请问:"+
			qs[index].Q+"\n把答案发给奴家就可以了呢").
		Send()
	d.setStatus("auth")
}