Skip to content

Commit a3be31d

Browse files
committed
feat: set r18 when posting
1 parent 4e35979 commit a3be31d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

bot/handlers_admin.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ func postArtwork(ctx context.Context, bot *telego.Bot, query telego.CallbackQuer
216216
})
217217
return
218218
}
219-
dataID := strings.Split(query.Data, " ")[2]
219+
queryDataSlice := strings.Split(query.Data, " ")
220+
asR18 := queryDataSlice[0] == "post_artwork_r18"
221+
dataID := queryDataSlice[1]
220222
sourceURL, err := service.GetCallbackDataByID(ctx, dataID)
221223
if err != nil {
222224
bot.AnswerCallbackQuery(&telego.AnswerCallbackQueryParams{
@@ -279,6 +281,9 @@ func postArtwork(ctx context.Context, bot *telego.Bot, query telego.CallbackQuer
279281
return
280282
}
281283
}
284+
if asR18 {
285+
artwork.R18 = true
286+
}
282287
if err := fetcher.PostAndCreateArtwork(ctx, artwork, bot, storage.GetStorage(), query.From.ID); err != nil {
283288
Logger.Errorf("发布失败: %s", err)
284289
go bot.EditMessageCaption(&telego.EditMessageCaptionParams{
@@ -305,7 +310,7 @@ func postArtwork(ctx context.Context, bot *telego.Bot, query telego.CallbackQuer
305310
Caption: "发布成功: " + artwork.Title + "\n\n发布时间: " + artwork.CreatedAt.Format("2006-01-02 15:04:05"),
306311
ReplyMarkup: telegoutil.InlineKeyboard(
307312
[]telego.InlineKeyboardButton{
308-
telegoutil.InlineKeyboardButton("去查看").WithURL(telegram.GetArtworkPostMessageURL(artwork.Pictures[0].TelegramInfo.MessageID)),
313+
telegoutil.InlineKeyboardButton("查看").WithURL(telegram.GetArtworkPostMessageURL(artwork.Pictures[0].TelegramInfo.MessageID)),
309314
telegoutil.InlineKeyboardButton("原图").WithURL(telegram.GetDeepLinkForFile(artwork.Pictures[0].TelegramInfo.MessageID)),
310315
},
311316
),

bot/handlers_common.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ func getArtworkInfo(ctx context.Context, bot *telego.Bot, message telego.Message
249249
}
250250
photo.WithReplyMarkup(telegoutil.InlineKeyboard(
251251
[]telego.InlineKeyboardButton{
252-
telegoutil.InlineKeyboardButton("发布到频道").WithCallbackData("admin post_artwork " + id),
252+
telegoutil.InlineKeyboardButton("发布").WithCallbackData("post_artwork " + id),
253+
telegoutil.InlineKeyboardButton("设为R18并发布").WithCallbackData("post_artwork_r18 " + id),
253254
},
254255
))
255256
}

cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
Version string = "0.6.6"
10+
Version string = "0.6.7"
1111
)
1212

1313
var VersionCmd = &cobra.Command{

0 commit comments

Comments
 (0)