From 2365907fd772606bd8165241f482964995b4c8bb Mon Sep 17 00:00:00 2001 From: Alex Manatskyi Date: Sat, 14 Nov 2020 11:24:00 +0200 Subject: [PATCH] Pre-process input via mobile share (#32) --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index a043ebb..36ca49d 100644 --- a/main.go +++ b/main.go @@ -312,6 +312,14 @@ func main() { // tokenize the update tokens := strings.Split(update.Message.Text, " ") + + // preprocess message based on URL schema + // in case those were added from the mobile via "Share..." option + // when it is not possible to easily prepend it with "add" command + if strings.HasPrefix(tokens[0], "magnet") || strings.HasPrefix(tokens[0], "http") { + tokens = append([]string{"add"}, tokens...) + } + command := strings.ToLower(tokens[0]) switch command {