Conversation
examples/conversationbot.py
Outdated
| bot. | ||
| """ | ||
|
|
||
| from examples.settings import TOKEN |
There was a problem hiding this comment.
I don't like the examples folder treated as a package.
I also like the simplicity of each example looking its own token.
Please revert this.
To make my thought a bit more clear:
- The examples should be simple enough and maintain the concept of "code locality".
- The examples folder is by no mean to be treated as a python package which can be imported. These are all stand alone files each of them representing an example.
examples/conversationbot.py
Outdated
| # Create the EventHandler and pass it your bot's token. | ||
| updater = Updater("TOKEN") | ||
| # Create the Updater and pass it your bot's token as a string. | ||
| updater = Updater(TOKEN) |
There was a problem hiding this comment.
see comment about not treating examples/ folder as a package.
examples/conversationbot2.py
Outdated
| bot. | ||
| """ | ||
|
|
||
| from examples.settings import TOKEN |
There was a problem hiding this comment.
see comment about not treating examples/ folder as a package.
examples/conversationbot2.py
Outdated
| # Create the Updater and pass it your bot's token. | ||
| updater = Updater("TOKEN") | ||
| # Create the Updater and pass it your bot's token as a string. | ||
| updater = Updater(TOKEN) |
There was a problem hiding this comment.
see comment about not treating examples/ folder as a package.
examples/deeplinking.py
Outdated
|
|
||
| import logging | ||
|
|
||
| from examples.settings import TOKEN |
There was a problem hiding this comment.
see comment about not treating examples/ folder as a package.
| self.name = 'Filters.regex({})'.format(self.pattern) | ||
|
|
||
| def filter(self, message): | ||
| return bool(re.search(self.pattern, message.text)) |
There was a problem hiding this comment.
Is there a reason not to do:
return bool(self.pattern.search(message.text))There was a problem hiding this comment.
self.pattern can either be a regex compiled pattern or a string. You're solutions doesn't work for strings.
telegram/ext/filters.py
Outdated
| def filter(self, message): | ||
| return bool(re.search(self.pattern, message.text)) | ||
|
|
||
|
|
| command = _Command() | ||
| """:obj:`Filter`: Messages starting with ``/``.""" | ||
|
|
||
| class regex(BaseFilter): |
There was a problem hiding this comment.
Code for regex filter is good (regardless of some nitpicking).
However, it has nothing to do with the deep linking PR.
Please open a separate PR for it.
tests/test_helpers.py
Outdated
| assert expected == helpers.create_deep_linked_url(username, payload) | ||
| assert expected == helpers.create_deep_linked_url(username) | ||
|
|
||
| try: |
There was a problem hiding this comment.
Please use pytest.raises() instead of the entire try...except... block
tests/test_helpers.py
Outdated
| except Exception as e: | ||
| assert isinstance(e, ValueError) | ||
|
|
||
| try: |
There was a problem hiding this comment.
Please use pytest.raises() instead of the entire try...except... block
|
Hi @tsnoam, please have a look at the example. I will remove the other example token stuff however, that was more of an experiment and you're right, it doesn't have anything to do with the rest. Cheers |
|
@JosXa |
|
Status: Waiting for merge of #1028 |
|
@jh0ker Neat! |
create_deep_linked_urlFilters.regexand documented that it is not yet compliant with Expand Filters and remove unwanted parameters from Handlers #835 (i.e. not passing groups or groupdict)settings.py. That way, you can set your token once and access all of the example bots. Added documentation to this in the appropriate places, especially thatUpdater(TOKEN), where TOKEN stems from thesettings.py, requires you to replace the constant with a string if you users want to use the example standalone. This might be controversial, so please respond if you think it is a good addition.