@@ -754,15 +754,23 @@ func (h *Handler) setCfg(CallbackQuery *tgbotapi.CallbackQuery, data *tgbotapi.C
754
754
msg .WriteByte ('\n' )
755
755
}
756
756
}
757
- if showPreview && h .DB .DBType () == db .T_POSTGRESQL {
758
- photo , err := h .DB .FindImg (db.FindConfig {
759
- Deadline : time .Now (),
760
- Order : "id desc" ,
761
- Limit : 1 ,
762
- KeywordsRe : []string {fmt .Sprintf ("<lora:%s:(-?\\ d+)(\\ .\\ d+)?>" , l .Name )},
763
- })
764
- if err == nil && len (photo ) == 1 {
765
- msg .WriteString (fmt .Sprintf ("\n # <a href=\" %s://%s/api/images/%s.png\" >Preview</a>" , parseflag .ApiScheme , parseflag .ApiHost , photo [0 ].FileID ))
757
+ if showPreview {
758
+ var url string
759
+ if l .Preview != "" {
760
+ url = l .Preview
761
+ } else if h .DB .DBType () == db .T_POSTGRESQL {
762
+ photo , err := h .DB .FindImg (db.FindConfig {
763
+ Deadline : time .Now (),
764
+ Order : "id desc" ,
765
+ Limit : 1 ,
766
+ KeywordsRe : []string {fmt .Sprintf ("<lora:%s:(-?\\ d+)(\\ .\\ d+)?>" , l .Name )},
767
+ })
768
+ if err == nil && len (photo ) == 1 {
769
+ url = fmt .Sprintf ("%s://%s/api/images/%s.png" , parseflag .ApiScheme , parseflag .ApiHost , photo [0 ].FileID )
770
+ }
771
+ }
772
+ if url != "" {
773
+ msg .WriteString (fmt .Sprintf ("\n # <a href=\" %s\" >Preview</a>" , url ))
766
774
}
767
775
}
768
776
tgMsg := tgbotapi .NewEditMessageText (CallbackQuery .Message .Chat .ID , CallbackQuery .Message .MessageID , msg .String ())
@@ -850,15 +858,23 @@ func (h *Handler) setCfg(CallbackQuery *tgbotapi.CallbackQuery, data *tgbotapi.C
850
858
msg .WriteByte ('\n' )
851
859
}
852
860
}
853
- if showPreview && h .DB .DBType () == db .T_POSTGRESQL {
854
- photo , err := h .DB .FindImg (db.FindConfig {
855
- Deadline : time .Now (),
856
- Order : "id desc" ,
857
- Limit : 1 ,
858
- KeywordsRe : []string {fmt .Sprintf ("<%s:%s:(-?\\ d+)(\\ .\\ d+)?>" , l .Type , l .Name )},
859
- })
860
- if err == nil && len (photo ) == 1 {
861
- msg .WriteString (fmt .Sprintf ("\n # <a href=\" %s://%s/api/images/%s.png\" >Preview</a>" , parseflag .ApiScheme , parseflag .ApiHost , photo [0 ].FileID ))
861
+ if showPreview {
862
+ var url string
863
+ if l .Preview != "" {
864
+ url = l .Preview
865
+ } else if h .DB .DBType () == db .T_POSTGRESQL {
866
+ photo , err := h .DB .FindImg (db.FindConfig {
867
+ Deadline : time .Now (),
868
+ Order : "id desc" ,
869
+ Limit : 1 ,
870
+ KeywordsRe : []string {fmt .Sprintf ("<lora:%s:(-?\\ d+)(\\ .\\ d+)?>" , l .Name )},
871
+ })
872
+ if err == nil && len (photo ) == 1 {
873
+ url = fmt .Sprintf ("%s://%s/api/images/%s.png" , parseflag .ApiScheme , parseflag .ApiHost , photo [0 ].FileID )
874
+ }
875
+ }
876
+ if url != "" {
877
+ msg .WriteString (fmt .Sprintf ("\n # <a href=\" %s\" >Preview</a>" , url ))
862
878
}
863
879
}
864
880
tgMsg := tgbotapi .NewEditMessageText (CallbackQuery .Message .Chat .ID , CallbackQuery .Message .MessageID , msg .String ())
0 commit comments