From 7669781737e3b007fbc411da21cd30b7d6559216 Mon Sep 17 00:00:00 2001 From: DrBomb Date: Thu, 17 Mar 2016 00:48:08 -0430 Subject: [PATCH 1/3] Update util.py Added a regexp method that returns all the text after the command. --- telebot/util.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/telebot/util.py b/telebot/util.py index 5030acf..a6e18e9 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -224,3 +224,19 @@ def OrEvent(*events): or_event.wait = busy_wait changed() return or_event + +def extract_arguments(text): + """ + Returns the argument after the command. + + Examples: + extract_arguments("/get name"): 'name' + extract_arguments("/get"): '' + extract_arguments("/get@botName name"): 'name' + + :param text: String to extract the arguments from a command + :return: the arguments if `text` is a command (according to is_command), else None. + """ + regexp = re.("\/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE) + result = regexp.match(text) + return result.group(2) if if is_command(text) else None From 78d86752fbee233c3b92f08612156586236b3407 Mon Sep 17 00:00:00 2001 From: DrBomb Date: Thu, 17 Mar 2016 00:51:02 -0430 Subject: [PATCH 2/3] Update util.py Typo --- telebot/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telebot/util.py b/telebot/util.py index a6e18e9..fa0e51b 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -239,4 +239,4 @@ def extract_arguments(text): """ regexp = re.("\/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE) result = regexp.match(text) - return result.group(2) if if is_command(text) else None + return result.group(2) if is_command(text) else None From 17184697ea2c11ff05b2b8d115d2b736071dd405 Mon Sep 17 00:00:00 2001 From: DrBomb Date: Thu, 17 Mar 2016 22:17:06 -0430 Subject: [PATCH 3/3] Update util.py Another typo --- telebot/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telebot/util.py b/telebot/util.py index fa0e51b..d4dd542 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -237,6 +237,6 @@ def extract_arguments(text): :param text: String to extract the arguments from a command :return: the arguments if `text` is a command (according to is_command), else None. """ - regexp = re.("\/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE) + regexp = re.compile("\/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE) result = regexp.match(text) return result.group(2) if is_command(text) else None