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() } } }
func (s *Start) Run() { if !s.isAuthed() { s.sendQuestion() return } s.NewMessage(s.Message.From.ID, conf.List2StringInConf("help")).Send() }
func (r *Rule) Run() { chatIDStr := strconv.Itoa(r.ChatID) rule := conf.Redis.Get("tgGroupRule:" + chatIDStr).Val() if rule != "" { r.NewMessage(r.ChatID, rule).MarkdownMode().Send() } else { r.NewMessage(r.Message.From.ID, conf.List2StringInConf("rules")).MarkdownMode().Send() } }
func (d *Default) Run() { if d.FromPrivate { switch d.getStatus() { case "auth": d.auth(d.Message.Text) case "broadcast": d.bc(d.Message.Text) d.setStatus("") case "trans": result := d.translator(d.Message.Text) d.NewMessage(d.ChatID, result).Send() d.setStatus("") default: if conf.CategoriesSet.Has(d.Message.Text) { // custom keyboard reply if !d.isAuthed() { d.sendQuestion() return } d.NewMessage(d.ChatID, conf.List2StringInConf(d.Message.Text)).Send() } else { if len(d.Args) > 0 { d.turing(d.Message.Text) return } photo := d.Message.Photo if len(photo) > 0 { go d.NewChatAction(d.ChatID).UploadPhoto().Send() fileID := photo[len(photo)-1].FileID link, _ := d.GetLink(fileID) path := helper.Downloader(link, fileID) mime := helper.FileMime(path) size := helper.FileSize(path) bar := helper.BarCode(path) vcn := helper.Vim_cn_Uploader(path) os.Remove(path) s := fmt.Sprintf("%s %s\n%s\n%s", mime, size, vcn, bar) d.NewMessage(d.ChatID, s). DisableWebPagePreview(). ReplyToMessageID(d.Message.MessageID).Send() return } } } } }
func (o *OtherResources) Run() { o.NewMessage(o.Message.From.ID, conf.List2StringInConf("其他资源")).Send() }
func (a *About) Run() { a.NewMessage(a.Message.From.ID, conf.List2StringInConf("about")).Send() }