mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 23:27:49 +01:00
Updated Frequently Asked Questions (markdown)
parent
3ec905e8aa
commit
382aa63c74
1 changed files with 10 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
- [Can I check, if a `ConversationHandler` is currently active for a user?](#can-i-check-if-a-conversationhandler-is-currently-active-for-a-user)
|
- [Can I check, if a `ConversationHandler` is currently active for a user?](#can-i-check-if-a-conversationhandler-is-currently-active-for-a-user)
|
||||||
- [How can I list all messages of a particular chat or search through them based on a search query?](#how-can-i-list-all-messages-of-a-particular-chat-or-search-through-them-based-on-a-search-query)
|
- [How can I list all messages of a particular chat or search through them based on a search query?](#how-can-i-list-all-messages-of-a-particular-chat-or-search-through-them-based-on-a-search-query)
|
||||||
- [How can I disable logging for the `APScheduler` module?](#how-can-i-disable-logging-for-the-apscheduler-module)
|
- [How can I disable logging for the `APScheduler` module?](#how-can-i-disable-logging-for-the-apscheduler-module)
|
||||||
|
- [How do I enforce users joining a specific channel before using my bot?](#how-do-i-enforce-users-joining-a-specific-channel-before-using-my-bot)
|
||||||
|
|
||||||
### What messages can my Bot see?
|
### What messages can my Bot see?
|
||||||
|
|
||||||
|
@ -136,3 +137,11 @@ import logging
|
||||||
aps_logger = logging.getLogger('apscheduler')
|
aps_logger = logging.getLogger('apscheduler')
|
||||||
aps_logger.setLevel(logging.WARNING)
|
aps_logger.setLevel(logging.WARNING)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### How do I enforce users joining a specific channel before using my bot?
|
||||||
|
|
||||||
|
After sending an (invite) link to the channel to the user, you can use [`Bot.get_chat_member`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot.get_chat_member) to check if the user is an that channel. If the method call fails with an error, it means that the user is not in that channel. Note that
|
||||||
|
* the bot needs to be admin in that channel
|
||||||
|
* the user must have started the bot for this approach to work. If you try to run `get_chat_member` for a user that has not started the bot, the bot can not find the user in a chat, even if it is a member of it.
|
||||||
|
|
||||||
|
If the user has not yet joined the channel, you can ignore incoming updates from that user or reply to them with a corresponding warning. A convenient way to do that is to add at [`TypeHandler(telegram.Update, callback)`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.typehandler.html) to a low group and have the `callback` raise [`DispatcherHandlerStop`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.dispatcherhandlerstop.html) if the user did not join yet. See the docs of [`Dispatcher.add_handler`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.dispatcherhandlerstop.html) for more info on handler groups and `DispatcherHandlerStop`.
|
Loading…
Reference in a new issue