Skip to content

Commit

Permalink
踢出被举报人并删除消息
Browse files Browse the repository at this point in the history
  • Loading branch information
IJNKAWAKAZE committed Apr 3, 2024
1 parent 6503f7f commit 26464d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/plugins/system/callback_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ func Report(callBack tgbotapi.Update) error {
data := callBack.CallbackData()
d := strings.Split(data, ",")

if len(d) < 3 {
if len(d) < 4 {
return nil
}

userId := callbackQuery.From.ID
chatId := callbackQuery.Message.Chat.ID
messageId := callbackQuery.Message.MessageID
target, _ := strconv.ParseInt(d[2], 10, 64)
targetMessageId, _ := strconv.Atoi(d[3])

if !utils.IsAdmin(chatId, userId) {
answer := tgbotapi.NewCallbackWithAlert(callbackQuery.ID, "无使用权限!")
Expand All @@ -38,7 +39,9 @@ func Report(callBack tgbotapi.Update) error {
RevokeMessages: true,
}
bot.Arknights.Send(banChatMemberConfig)
delMsg := tgbotapi.NewDeleteMessage(chatId, messageId)
delMsg := tgbotapi.NewDeleteMessage(chatId, targetMessageId)
bot.Arknights.Send(delMsg)
delMsg = tgbotapi.NewDeleteMessage(chatId, messageId)
bot.Arknights.Send(delMsg)
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/system/report_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func ReportHandle(update tgbotapi.Update) error {
}

buttons = append(buttons, tgbotapi.NewInlineKeyboardRow(
tgbotapi.NewInlineKeyboardButtonData("🚫封禁", fmt.Sprintf("report,%s,%d", "BAN", target)),
tgbotapi.NewInlineKeyboardButtonData("❌关闭", fmt.Sprintf("report,%s,%d", "CLOSE", target)),
tgbotapi.NewInlineKeyboardButtonData("🚫封禁", fmt.Sprintf("report,%s,%d,%d", "BAN", target, replyMessageId)),
tgbotapi.NewInlineKeyboardButtonData("❌关闭", fmt.Sprintf("report,%s,%d,%d", "CLOSE", target, replyMessageId)),
))

inlineKeyboardMarkup := tgbotapi.NewInlineKeyboardMarkup(
Expand Down

0 comments on commit 26464d1

Please sign in to comment.