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 (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 } groups := conf.List2SliceInConf(d.Message.Text) result := make([]string, len(groups)) for k, v := range groups { reg := regexp.MustCompile("^(.+) (http(s)?://(.*))$") strs := reg.FindAllStringSubmatch(v, -1) if !reg.MatchString(v) { result[k] = v } if len(strs) > 0 { result[k] = helper.ToMarkdownLink(strs[0][1], strs[0][2]) } } msgContent := strings.Join(result, "\n") msgContent = strings.Replace(msgContent, "\\n", "", -1) d.NewMessage(d.ChatID, msgContent). MarkdownMode().DisableWebPagePreview().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 } } } } }