Make Filters.text accept leading slash (#1680)

Fixes #1678
This commit is contained in:
Bibo-Joshi 2020-01-26 22:19:38 +01:00 committed by Noam Meltzer
parent 0b87f4b274
commit 3eb2cef600
2 changed files with 6 additions and 6 deletions

View file

@ -243,7 +243,7 @@ class Filters(object):
self.name = 'Filters.text({})'.format(iterable)
def filter(self, message):
if message.text and not message.text.startswith('/'):
if message.text:
return message.text in self.iterable
return False
@ -257,7 +257,7 @@ class Filters(object):
return self._TextIterable(update)
def filter(self, message):
return bool(message.text and not message.text.startswith('/'))
return bool(message.text)
text = _Text()
"""Text Messages. If an iterable of strings is passed, it filters messages to only allow those

View file

@ -45,11 +45,11 @@ class TestFilters(object):
update.message.text = 'test'
assert (Filters.text)(update)
update.message.text = '/test'
assert not (Filters.text)(update)
assert (Filters.text)(update)
def test_filters_text_iterable(self, update):
update.message.text = 'test'
assert Filters.text({'test', 'test1'})(update)
update.message.text = '/test'
assert Filters.text({'/test', 'test1'})(update)
assert not Filters.text(['test1', 'test2'])(update)
def test_filters_caption(self, update):
@ -630,7 +630,7 @@ class TestFilters(object):
update.message.forward_date = datetime.datetime.utcnow()
assert (Filters.text & Filters.forwarded)(update)
update.message.text = '/test'
assert not (Filters.text & Filters.forwarded)(update)
assert (Filters.text & Filters.forwarded)(update)
update.message.text = 'test'
update.message.forward_date = None
assert not (Filters.text & Filters.forwarded)(update)