Browse Source

Trim spaces when parsing seum command

Camille Masset 5 years ago
parent
commit
6ca0732f00
1 changed files with 2 additions and 2 deletions
  1. 2 2
      bot/views/telegram.py

+ 2 - 2
bot/views/telegram.py

@@ -123,7 +123,7 @@ def webhook(request):
123 123
     if not 'text' in data['message']:
124 124
         return HttpResponse(201)
125 125
 
126
-    text = data['message']['text']
126
+    text = data['message']['text'].strip()
127 127
     if text == '/notify_every_seum_or_not' or text == '/notify_every_seum_or_not@' + telegram_bot_name:
128 128
         tchat = TelegramChat.objects.get(chat_id=chat['id'])
129 129
         tchat.notify_only_members = not tchat.notify_only_members
@@ -148,7 +148,7 @@ def webhook(request):
148 148
             requests.post(telegram_url + 'sendMessage', json={'chat_id': chat['id'], 'text': 'Hello ' + telegram_user.counter.name + ' :-)', 'reply_to_message_id': data['message']['message_id']})
149 149
             return HttpResponse('')
150 150
 
151
-        seum_cmd = r"^/seum((@" + telegram_bot_name + ")?) (.+)$"
151
+        seum_cmd = r"^/seum((@" + telegram_bot_name + ")?)\s+(.+)$"
152 152
         if re.match(seum_cmd, text) is not None:
153 153
             # it's a /seum cmd
154 154
             m = re.sub(seum_cmd, r"\3", text)