Skip to content

Commit

Permalink
feat: remove check command
Browse files Browse the repository at this point in the history
  • Loading branch information
indes committed Feb 20, 2022
1 parent 80cc9ec commit 527f9a3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 209 deletions.
4 changes: 1 addition & 3 deletions internal/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ func setHandle() {
//B.Handle("/setfeedtag", setFeedTagCmdCtr)
//
//B.Handle("/setinterval", setIntervalCmdCtr)
//
//B.Handle("/check", checkCmdCtr)
//

//B.Handle("/activeall", activeAllCmdCtr)
//
//B.Handle("/pauseall", pauseAllCmdCtr)
Expand Down
207 changes: 1 addition & 206 deletions internal/bot/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,77 +88,7 @@ var (
// })
//}
//
//func startCmdCtr(m *tb.Message) {
//
//}
//

//
//func exportCmdCtr(m *tb.Message) {
//
//}
//

//
//func checkCmdCtr(m *tb.Message) {
// mention := GetMentionFromMessage(m)
// if mention != "" {
// channelChat, err := B.ChatByID(mention)
// if err != nil {
// _, _ = B.Send(m.Chat, "error")
// return
// }
// adminList, err := B.AdminsOf(channelChat)
// if err != nil {
// _, _ = B.Send(m.Chat, "error")
// return
// }
//
// senderIsAdmin := false
// for _, admin := range adminList {
// if m.Sender.ID == admin.User.ID {
// senderIsAdmin = true
// }
// }
//
// if !senderIsAdmin {
// _, _ = B.Send(m.Chat, fmt.Sprintf("非频道管理员无法执行此操作"))
// return
// }
//
// sources, _ := model.GetErrorSourcesByUserID(channelChat.ID)
// message := fmt.Sprintf("频道 [%s](https://t.me/%s) 失效订阅的列表:\n", channelChat.Title, channelChat.Username)
// if len(sources) == 0 {
// message = fmt.Sprintf("频道 [%s](https://t.me/%s) 所有订阅正常", channelChat.Title, channelChat.Username)
// } else {
// for _, source := range sources {
// message = message + fmt.Sprintf("[[%d]] [%s](%s)\n", source.ID, source.Title, source.Link)
// }
// }
//
// _, _ = B.Send(m.Chat, message, &tb.SendOptions{
// DisableWebPagePreview: true,
// ParseMode: tb.ModeMarkdown,
// })
//
// } else {
// sources, _ := model.GetErrorSourcesByUserID(m.Chat.ID)
// message := "失效订阅的列表:\n"
// if len(sources) == 0 {
// message = "所有订阅正常"
// } else {
// for _, source := range sources {
// message = message + fmt.Sprintf("[[%d]] [%s](%s)\n", source.ID, source.Title, source.Link)
// }
// }
// _, _ = B.Send(m.Chat, message, &tb.SendOptions{
// DisableWebPagePreview: true,
// ParseMode: tb.ModeMarkdown,
// })
// }
//
//}
//
//func setCmdCtr(m *tb.Message) {
//
// mention := GetMentionFromMessage(m)
Expand Down Expand Up @@ -371,138 +301,7 @@ var (
//func setToggleUpdateBtnCtr(c *tb.Callback) {
// toggleCtrlButtons(c, "toggleUpdate")
//}
//
//func unsubCmdCtr(m *tb.Message) {
//
// url, mention := GetURLAndMentionFromMessage(m)
//
// if mention == "" {
// if url != "" {
// //Unsub by url
// source, _ := model.GetSourceByUrl(url)
// if source == nil {
// _, _ = B.Send(m.Chat, "未订阅该RSS源")
// } else {
// err := model.UnsubByUserIDAndSource(m.Chat.ID, source)
// if err == nil {
// _, _ = B.Send(
// m.Chat,
// fmt.Sprintf("[%s](%s) 退订成功!", source.Title, source.Link),
// &tb.SendOptions{
// DisableWebPagePreview: true,
// ParseMode: tb.ModeMarkdown,
// },
// )
// zap.S().Infof("%d unsubscribe [%d]%s %s", m.Chat.ID, source.ID, source.Title, source.Link)
// } else {
// _, err = B.Send(m.Chat, err.Error())
// }
// }
// } else {
// //Unsub by button
//
// subs, err := model.GetSubsByUserID(m.Chat.ID)
//
// if err != nil {
// errorCtr(m, "Bot错误,请联系管理员!错误代码01")
// return
// }
//
// if len(subs) > 0 {
// unsubFeedItemBtns := [][]tb.InlineButton{}
//
// for _, sub := range subs {
//
// source, err := model.GetSourceById(sub.SourceID)
// if err != nil {
// errorCtr(m, "Bot错误,请联系管理员!错误代码02")
// return
// }
//
// unsubFeedItemBtns = append(unsubFeedItemBtns, []tb.InlineButton{
// tb.InlineButton{
// Unique: "unsub_feed_item_btn",
// Text: fmt.Sprintf("[%d] %s", sub.SourceID, source.Title),
// Data: fmt.Sprintf("%d:%d:%d", sub.UserID, sub.ID, source.ID),
// },
// })
// }
//
// _, _ = B.Send(m.Chat, "请选择你要退订的源", &tb.ReplyMarkup{
// InlineKeyboard: unsubFeedItemBtns,
// })
// } else {
// _, _ = B.Send(m.Chat, "当前没有订阅源")
// }
// }
// } else {
// if url != "" {
// channelChat, err := B.ChatByID(mention)
// if err != nil {
// _, _ = B.Send(m.Chat, "error")
// return
// }
// adminList, err := B.AdminsOf(channelChat)
// if err != nil {
// _, _ = B.Send(m.Chat, "error")
// return
// }
//
// senderIsAdmin := false
// for _, admin := range adminList {
// if m.Sender.ID == admin.User.ID {
// senderIsAdmin = true
// }
// }
//
// if !senderIsAdmin {
// _, _ = B.Send(m.Chat, fmt.Sprintf("非频道管理员无法执行此操作"))
// return
// }
//
// source, _ := model.GetSourceByUrl(url)
// sub, err := model.GetSubByUserIDAndURL(channelChat.ID, url)
//
// if err != nil {
// if err.Error() == "record not found" {
// _, _ = B.Send(
// m.Chat,
// fmt.Sprintf("频道 [%s](https://t.me/%s) 未订阅该RSS源", channelChat.Title, channelChat.Username),
// &tb.SendOptions{
// DisableWebPagePreview: true,
// ParseMode: tb.ModeMarkdown,
// },
// )
//
// } else {
// _, _ = B.Send(m.Chat, "退订失败")
// }
// return
//
// }
//
// err = sub.Unsub()
// if err == nil {
// _, _ = B.Send(
// m.Chat,
// fmt.Sprintf("频道 [%s](https://t.me/%s) 退订 [%s](%s) 成功", channelChat.Title, channelChat.Username, source.Title, source.Link),
// &tb.SendOptions{
// DisableWebPagePreview: true,
// ParseMode: tb.ModeMarkdown,
// },
// )
// zap.S().Infof("%d for [%d]%s unsubscribe %s", m.Chat.ID, source.ID, source.Title, source.Link)
// } else {
// _, err = B.Send(m.Chat, err.Error())
// }
// return
//
// }
// _, _ = B.Send(m.Chat, "频道退订请使用' /unsub @ChannelID URL ' 命令")
// }
//
//}
//

//func unsubFeedItemBtnCtr(c *tb.Callback) {
// if (c.Message.Chat.Type == tb.ChatGroup || c.Message.Chat.Type == tb.ChatSuperGroup) &&
// !userIsAdminOfGroup(c.Sender.ID, c.Message.Chat) {
Expand Down Expand Up @@ -1049,7 +848,3 @@ var (
// ParseMode: tb.ModeHTML,
// })
//}
//
//func errorCtr(m *tb.Message, errMsg string) {
// _, _ = B.Send(m.Chat, errMsg)
//}

0 comments on commit 527f9a3

Please sign in to comment.