Pre-process input via mobile share (#32)

This commit is contained in:
Alex Manatskyi 2020-11-14 11:24:00 +02:00 committed by GitHub
parent 7e4d1b7989
commit 2365907fd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,6 +312,14 @@ func main() {
// tokenize the update // tokenize the update
tokens := strings.Split(update.Message.Text, " ") 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]) command := strings.ToLower(tokens[0])
switch command { switch command {