From 2900b75323f29f4b9b5ec34e0cc380000136cad8 Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Tue, 31 Dec 2019 16:46:28 +0800 Subject: [PATCH 1/2] check admin on receiving doc --- bot/controller.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bot/controller.go b/bot/controller.go index 8f8c9394..303a968d 100644 --- a/bot/controller.go +++ b/bot/controller.go @@ -806,6 +806,17 @@ func textCtr(m *tb.Message) { func docCtr(m *tb.Message) { + if m.FromChannel() { + if !UserIsAdminChannel(m.ID, m.Chat) { + return + } + } + if m.FromGroup() { + if !userIsAdminOfGroup(m.ID, m.Chat) { + return + } + } + url, _ := B.FileURLByID(m.Document.FileID) opml, err := GetOPMLByURL(url) From d2b27719ebbdad7eb58f7595aa16fd602b438227 Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Tue, 31 Dec 2019 16:57:52 +0800 Subject: [PATCH 2/2] filter files .opml --- bot/controller.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bot/controller.go b/bot/controller.go index 303a968d..d2cd112e 100644 --- a/bot/controller.go +++ b/bot/controller.go @@ -805,21 +805,24 @@ func textCtr(m *tb.Message) { } func docCtr(m *tb.Message) { - - if m.FromChannel() { - if !UserIsAdminChannel(m.ID, m.Chat) { + if m.FromGroup() { + if !userIsAdminOfGroup(m.ID, m.Chat) { return } } - if m.FromGroup() { - if !userIsAdminOfGroup(m.ID, m.Chat) { + + if m.FromChannel() { + if !UserIsAdminChannel(m.ID, m.Chat) { return } } url, _ := B.FileURLByID(m.Document.FileID) - opml, err := GetOPMLByURL(url) + if !strings.HasSuffix(url, ".opml") { + return + } + opml, err := GetOPMLByURL(url) if err != nil { if err.Error() == "fetch opml file error" { _, _ = B.Send(m.Chat,