mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
Use relative links to other wiki pages via the MediaWiki syntax
parent
4247c3a59a
commit
733d784595
19 changed files with 71 additions and 71 deletions
|
@ -50,7 +50,7 @@ Again, please try to be precise and include all relevant information. This means
|
|||
* What kind of handler did you set up to handle this? What is it supposed to do?
|
||||
2. What is actually happening?
|
||||
* If you're encountering an exception, please provide the full [traceback](https://realpython.com/python-traceback/)
|
||||
* Make sure that you activate [logging](https://github.com/python-telegram-bot/python-telegram-bot/#logging) or an [error handler](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Exception-Handling) so that you can actually see the traceback!
|
||||
* Make sure that you activate [logging](https://github.com/python-telegram-bot/python-telegram-bot/#logging) or an [[error handler|Exception-Handling]] so that you can actually see the traceback!
|
||||
3. Where exactly are things going south? If you can locate the line/s of code that are misbehaving, please include them in your question.
|
||||
|
||||
If you have a hard time laying your finger on where exactly things go south, it might be helpful to provide a [minimal working example](https://telegra.ph/Minimal-Working-Example-for-PTB-07-18).
|
||||
|
|
|
@ -33,7 +33,7 @@ If you need more details on MQ implementation, [follow its docs](http://python-t
|
|||
### Using MQ with @queuedmessage decorator
|
||||
[`MessageQueue`](http://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.messagequeue.html) module includes a convenient `@queuedmessage` decorator, which allows to delegate the required send method calls to MQ. However, it requires you to do a little work by hand, mainly create a [`telegram.Bot`](http://python-telegram-bot.readthedocs.io/en/latest/telegram.bot.html) subclass and decorate those methods.
|
||||
|
||||
Below is listed the example of its usage, which is based on echo bot from our [Tutorial](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Your-first-Bot#your-first-bot-step-by-step). Trace through it (it's self-explanatory enough) and try experimenting with it on your own. Don't forget to look at the [`MessageQueue` docs](http://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.messagequeue.html) at the same time to clarify the dark corners. It's important that you properly understand how MQ works before using it.
|
||||
Below is listed the example of its usage, which is based on echo bot from our [[Tutorial|Extensions-%E2%80%93-Your-first-Bot#your-first-bot-step-by-step]]. Trace through it (it's self-explanatory enough) and try experimenting with it on your own. Don't forget to look at the [`MessageQueue` docs](http://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.messagequeue.html) at the same time to clarify the dark corners. It's important that you properly understand how MQ works before using it.
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
This page can be read on its own to find the code snippet you need right now.
|
||||
|
||||
It is also a follow-up to the page [Introduction to the API](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API). If you come from there, you can leave your command line open and just try out a few of these snippets.
|
||||
It is also a follow-up to the page [[Introduction to the API|Introduction-to-the-API]]. If you come from there, you can leave your command line open and just try out a few of these snippets.
|
||||
|
||||
- [Pure API](#pure-api)
|
||||
+ [Fetch updates](#fetch-updates)
|
||||
|
@ -53,7 +53,7 @@ It is also a follow-up to the page [Introduction to the API](https://github.com/
|
|||
#### Fetch updates
|
||||
To fetch messages sent to your Bot, you can use the [getUpdates](https://core.telegram.org/bots/api#getupdates) API method.
|
||||
|
||||
**Note:** You don't have to use `get_updates` if you are writing your bot with the `telegram.ext` submodule, since `telegram.ext.Updater` takes care of fetching all updates for you. Read more about that [here](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Your-first-Bot).
|
||||
**Note:** You don't have to use `get_updates` if you are writing your bot with the `telegram.ext` submodule, since `telegram.ext.Updater` takes care of fetching all updates for you. Read more about that [[here|Extensions-%E2%80%93-Your-first-Bot]].
|
||||
|
||||
```python
|
||||
updates = bot.get_updates()
|
||||
|
@ -555,7 +555,7 @@ def hello(update, context):
|
|||
context.bot.send_message(chat_id=update.effective_chat.id, text="Hello world!")
|
||||
```
|
||||
|
||||
**Note**: You can modify this decorator in order to register any type of handler (see [Types Of Handlers](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Types-Of-Handlers)). Please also note that PTB deliberately does not provide such functionality out of the box due to the reasons mentioned in [#899](https://github.com/python-telegram-bot/python-telegram-bot/issues/899).
|
||||
**Note**: You can modify this decorator in order to register any type of handler (see [[Types Of Handlers|Types-Of-Handlers]]). Please also note that PTB deliberately does not provide such functionality out of the box due to the reasons mentioned in [#899](https://github.com/python-telegram-bot/python-telegram-bot/issues/899).
|
||||
|
||||
---
|
||||
#### Restrict access to a handler (decorator)
|
||||
|
@ -761,7 +761,7 @@ if __name__ == '__main__':
|
|||
---
|
||||
#### Store ConversationHandler States
|
||||
|
||||
Version 12 and up includes tools for [making your bot persistent](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Making-your-bot-persistent).
|
||||
Version 12 and up includes tools for [[making your bot persistent|Making-your-bot-persistent]].
|
||||
|
||||
---
|
||||
#### Save and load jobs using pickle
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
In `python-telegram-bot`, all Telegram-related errors are encapsulated in the `TelegramError` exception class and its subclasses, located in [`telegram.error`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.error.html) module.
|
||||
|
||||
Any error, including `TelegramError`, that is raised in one of your handlers (or while calling `get_updates` in the `Updater`), is forwarded to all registered error handlers, so you can react to them. You can register an error handler by calling `Dispatcher.add_error_handler(callback)`, where `callback` is a function that takes the `update` and `context`. `update` will be the update that caused the error (or `None` if the error wasn't caused by an update, e.g. for [Jobs](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-–-JobQueue)) and `context.error` the error that was raised.
|
||||
Any error, including `TelegramError`, that is raised in one of your handlers (or while calling `get_updates` in the `Updater`), is forwarded to all registered error handlers, so you can react to them. You can register an error handler by calling `Dispatcher.add_error_handler(callback)`, where `callback` is a function that takes the `update` and `context`. `update` will be the update that caused the error (or `None` if the error wasn't caused by an update, e.g. for [[Jobs|Extensions-–-JobQueue]]) and `context.error` the error that was raised.
|
||||
|
||||
**Example:** You're trying to send a message, but the user blocked the bot. An `Unauthorized` exception, a subclass of `TelegramError`, will be raised and delivered to your error handler, so you can delete it from your conversation list, if you keep one.
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ The `Updater` class continuously fetches new updates from telegram and passes th
|
|||
If you create an `Updater` object, it will create a `Dispatcher` for you and link them together with a `Queue`.
|
||||
You can then register handlers of different types in the `Dispatcher`, which will sort the updates fetched by the `Updater` according to the handlers you registered, and deliver them to a callback function that you defined.
|
||||
|
||||
Every handler is an instance of any subclass of the [`telegram.ext.Handler`](https://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.handler.html#telegram.ext.Handler) class. The library provides [handler classes for almost all use cases](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Types-of-Handlers), but if you need something very specific, you can also subclass `Handler` yourself.
|
||||
Every handler is an instance of any subclass of the [`telegram.ext.Handler`](https://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.handler.html#telegram.ext.Handler) class. The library provides [[handler classes for almost all use cases|Types-of-Handlers]], but if you need something very specific, you can also subclass `Handler` yourself.
|
||||
|
||||
To begin, you'll need an Access Token. If you have already read and followed [Introduction to the API](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API), you can use the one you generated then. If not: To generate an Access Token, you have to talk to [@BotFather](https://telegram.me/botfather) and follow a few simple steps (described [here](https://core.telegram.org/bots#6-botfather)). You should really read the introduction first, though.
|
||||
To begin, you'll need an Access Token. If you have already read and followed [[Introduction to the API|Introduction-to-the-API]], you can use the one you generated then. If not: To generate an Access Token, you have to talk to [@BotFather](https://telegram.me/botfather) and follow a few simple steps (described [here](https://core.telegram.org/bots#6-botfather)). You should really read the introduction first, though.
|
||||
|
||||
|
||||
## Your first Bot, step-by-step
|
||||
|
@ -39,7 +39,7 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
|||
level=logging.INFO)
|
||||
```
|
||||
|
||||
**Note:** Read the article on [Exception Handling](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Exception-Handling) if you want to learn more.
|
||||
**Note:** Read the article on [[Exception Handling|Exception-Handling]] if you want to learn more.
|
||||
|
||||
Now, you can define a function that should process a specific type of update:
|
||||
|
||||
|
@ -83,7 +83,7 @@ From now on, your bot should echo all non-command messages it receives.
|
|||
|
||||
**Note:** As soon as you add new handlers to `dispatcher`, they are in effect.
|
||||
|
||||
**Note:** The `Filters` class contains a number of so called filters that filter incoming messages for text, images, status updates and more. Any message that returns `True` for at least one of the filters passed to `MessageHandler` will be accepted. You can also write your own filters if you want. See more in [Advanced Filters](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Advanced-Filters).
|
||||
**Note:** The `Filters` class contains a number of so called filters that filter incoming messages for text, images, status updates and more. Any message that returns `True` for at least one of the filters passed to `MessageHandler` will be accepted. You can also write your own filters if you want. See more in [[Advanced Filters|Extensions-%E2%80%93-Advanced-Filters]].
|
||||
|
||||
Let's add some actual functionality to your bot. We want to implement a `/caps` command that will take some text as an argument and reply to it in CAPS. To make things easy, you can receive the arguments (as a `list`, split on spaces) that were passed to a command in the callback function:
|
||||
|
||||
|
@ -149,6 +149,6 @@ updater.stop()
|
|||
#### What to read next?
|
||||
Have a look at the ready-to-run [examples](https://github.com/python-telegram-bot/python-telegram-bot/tree/master/examples).
|
||||
|
||||
Learn about the library exceptions and best practices in [Exception Handling](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Exception-Handling).
|
||||
Learn about the library exceptions and best practices in [[Exception Handling|Exception-Handling]].
|
||||
|
||||
You want *more features*? Check out [Extensions – JobQueue](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue)!
|
||||
You want *more features*? Check out [[Extensions – JobQueue|Extensions-%E2%80%93-JobQueue]]!
|
|
@ -80,7 +80,7 @@ Anything *not* listed there can not be done with bots. Here is a short list of f
|
|||
* Adding members to a group/channel (note that you can just send an invite link, which is also less likely to be seen as spam)
|
||||
* Clearing the chat history for a user
|
||||
* Getting a message by its `message_id` (For the interested reader: see [here](https://github.com/tdlib/telegram-bot-api/issues/62))
|
||||
* Getting the last sent message in a chat (you can keep track of that by using [`chat_data`](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Storing-bot,-user-and-chat-related-data))
|
||||
* Getting the last sent message in a chat (you can keep track of that by using [[`chat_data`|Storing-bot,-user-and-chat-related-data]])
|
||||
|
||||
In some cases, using a userbot can help overcome restrictions of the Bot API. Please have a look at this [article](http://telegra.ph/How-a-Userbot-superacharges-your-Telegram-Bot-07-09) about userbots.
|
||||
Note that userbots are not what python-telegram-bot is for.
|
||||
|
@ -92,7 +92,7 @@ If your handlers callback returns `None` instead of the next state, you will sta
|
|||
### I want to handle updates from an external service in addition to the Telegram updates. How do I do that?
|
||||
|
||||
Receiving updates from an external service, e.g. updates about your GitHub repo, is a common use case.
|
||||
How exactly you get them sadly is beyond the scope of PTB, as that depends on the service. For many cases a simple approach is to check for updates every x seconds. You can use the [`JobQueue`](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-–-JobQueue) for that.
|
||||
How exactly you get them sadly is beyond the scope of PTB, as that depends on the service. For many cases a simple approach is to check for updates every x seconds. You can use the [[`JobQueue`|Extensions-–-JobQueue]] for that.
|
||||
|
||||
If you have a setup for getting the updates, you can put them in your bots update queue via `updater.update_queue.put(your_update)`. The `update_queue` is also available as `dispatcher.update_queue` and `context.update_queue`.
|
||||
Note that `your_update` does *not* need to be an instance of `telegram.Update` - on the contrary! You can e.g. write your own custom class to represent an update from your external service.
|
||||
|
@ -197,4 +197,4 @@ If you didn't keep track of your users from the beginning, you may have a chance
|
|||
|
||||
Even if you have all the IDs, you can't know if a user has blocked your bot in the meantime. Therefore, you should make sure to wrap your send request in a `try-except` clause checking for `telegram.error.Unauthorized` errors.
|
||||
|
||||
Finally, note that Telegram imposes some limits that restrict you to send ~30 Messages per second. If you have a huge user base and try to notify them all at once, you will get flooding errors. To prevent that, try spreading the messages over a long time range. A simple way to achieve that is to leverage the [`JobQueue`](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-–-JobQueue).
|
||||
Finally, note that Telegram imposes some limits that restrict you to send ~30 Messages per second. If you have a huge user base and try to notify them all at once, you will get flooding errors. To prevent that, try spreading the messages over a long time range. A simple way to achieve that is to leverage the [[`JobQueue`|Extensions-–-JobQueue]].
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
### Introduction
|
||||
You will need a VPS (or dedicated server) first. Check out the list at [Where to host Telegram Bots](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Where-to-host-Telegram-Bots#vps) if you don't have one already.
|
||||
You will need a VPS (or dedicated server) first. Check out the list at [[Where to host Telegram Bots|Where-to-host-Telegram-Bots#vps]] if you don't have one already.
|
||||
|
||||
### First login
|
||||
Your login details should contain
|
||||
|
@ -82,6 +82,6 @@ screen -d -r mybot
|
|||
## What to read next?
|
||||
If you plan on hosting multiple bots on your server, it's recommended to use `virtualenv`. It allows you to install and upgrade Python modules via `pip` for one project, without worrying how it affects other projects on the server. Read [this external article](http://docs.python-guide.org/en/latest/dev/virtualenvs/) for more information.
|
||||
|
||||
Learn about how to use a webhook for your bot in [this article](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks).
|
||||
Learn about how to use a webhook for your bot in [[this article|Webhooks]].
|
||||
|
||||
You might also read the article on [Performance Optimizations](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Performance-Optimizations) if you didn't read it yet.
|
||||
You might also read the article on [[Performance Optimizations|Performance-Optimizations]] if you didn't read it yet.
|
|
@ -44,4 +44,4 @@ bot.send_message(text='Hi John!', chat_id=1234567890)
|
|||
|
||||
## Beyond the pure API
|
||||
|
||||
That's all very nice, but usually you want your bot to actually react to more complex user input. That is, you want to build a chat-bot. `python-telegram-bot` offers a powerful extension module called `telegram.ext` that takes a lot of work off your shoulders. You can find an introduction at the [Tutorial: Your first bot](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Your-first-Bot).
|
||||
That's all very nice, but usually you want your bot to actually react to more complex user input. That is, you want to build a chat-bot. `python-telegram-bot` offers a powerful extension module called `telegram.ext` that takes a lot of work off your shoulders. You can find an introduction at the [[Tutorial: Your first bot|Extensions-–-Your-first-Bot]].
|
2
MWE.md
2
MWE.md
|
@ -6,7 +6,7 @@ So here is what that means:
|
|||
|
||||
##Example
|
||||
|
||||
When trying to help you with a problem, it's often helpful to see your code instead of a vague description of the issue. Of course, a better description often also helps (see [this article](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Ask-Right) on asking good technical questions).
|
||||
When trying to help you with a problem, it's often helpful to see your code instead of a vague description of the issue. Of course, a better description often also helps (see [[this article|Ask-Right]] on asking good technical questions).
|
||||
|
||||
## Working
|
||||
In order for the example to actually be helpful, it must work. This means that it:
|
||||
|
|
|
@ -44,7 +44,7 @@ If your persistence reads the data from an external database, the entries in thi
|
|||
|
||||
As of v13, persistence will automatically try to replace `telegram.Bot` instances by [`REPLACED_BOT`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.basepersistence.html#telegram.ext.BasePersistence.REPLACED_BOT) and
|
||||
insert the bot set with [`set_bot`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.basepersistence.html#telegram.ext.BasePersistence.set_bot) upon loading of the data. This is to ensure that
|
||||
changes to the bot apply to the saved objects, too. For example, you might change the [default values](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Adding-defaults-to-your-bot) used by the bot. If you change the bots token, this may
|
||||
changes to the bot apply to the saved objects, too. For example, you might change the [[default values|Adding-defaults-to-your-bot]] used by the bot. If you change the bots token, this may
|
||||
lead to e.g. `Chat not found` errors. For the limitations on replacing bots see
|
||||
[`replace_bot`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.basepersistence.html#telegram.ext.BasePersistence.replace_bot) and [`insert_bot`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.basepersistence.html#telegram.ext.BasePersistence.insert_bot).
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ The result should look similar to this:
|
|||
|
||||
**Note:** When choosing a server for the sole purpose of hosting a Telegram bot, these (ping and cURL) are the only relevant timings. Even if you are the only user of the bot, there is no advantage in choosing a server close to *you.*
|
||||
|
||||
If you need some suggestions on where to host your bot, read [Where to host Telegram Bots](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Where-to-host-Telegram-Bots).
|
||||
If you need some suggestions on where to host your bot, read [[Where to host Telegram Bots|Where-to-host-Telegram-Bots]].
|
||||
|
||||
## What to read next?
|
||||
Learn [how to use webhooks](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks) to get every last bit of performance from your bot.
|
||||
Learn [[how to use webhooks|Webhooks]] to get every last bit of performance from your bot.
|
|
@ -1,6 +1,6 @@
|
|||
A list of projects that are somehow related to `python-telegram-bot`. This includes integrations with other projects like django, projects that are built on top of this library for specific use-cases and potentially others.
|
||||
|
||||
**Note:** For *bots* that are built with this library, please use the [Examples](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Examples) page and not this one.
|
||||
**Note:** For *bots* that are built with this library, please use the [[Examples|Examples]] page and not this one.
|
||||
|
||||
If you are developing a project that fits this description, please add it here in alphabetical order. If you found a project that project that fits this description, please suggest to the maintainer of the project to add it here.
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ As of **version 12.4**, `Filters.command` checks for `MessageEntity.BOT_COMMAND`
|
|||
|
||||
***
|
||||
# Persistence
|
||||
In version 12 we introduce persistence to the bot's mechanics. If you want to use this please read the [wiki page](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Making-your-bot-persistent) dedicated to persistence.
|
||||
In version 12 we introduce persistence to the bot's mechanics. If you want to use this please read the [[wiki page|Making-your-bot-persistent]] dedicated to persistence.
|
||||
***
|
||||
# Return UTC from from_timestamp()
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ But what does this mean for you in detail? If you're scheduling tasks vanilla st
|
|||
context.job_queue.run_once(callback, when)
|
||||
```
|
||||
|
||||
you will only have to change the handling of time zones, or likely nothing at all. In fact, everything covered in this [wiki article](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-–-JobQueue) will work unchanged except for time zones. So before bothering to read on, just try to run you bot - in most cases it will still work. However, there are some more advanced things which changed.
|
||||
you will only have to change the handling of time zones, or likely nothing at all. In fact, everything covered in this [[wiki article|Extensions-–-JobQueue]] will work unchanged except for time zones. So before bothering to read on, just try to run you bot - in most cases it will still work. However, there are some more advanced things which changed.
|
||||
|
||||
## Handling of time zones
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
## JobQueue
|
||||
We did some serious work on the `telegram.ext.JobQueue` class. The changes are similar to the changes made to the `telegram.ext.Dispatcher` class in version 4. The [Extensions – JobQueue](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue) article has been updated with the changes.
|
||||
We did some serious work on the `telegram.ext.JobQueue` class. The changes are similar to the changes made to the `telegram.ext.Dispatcher` class in version 4. The [[Extensions – JobQueue|Extensions-%E2%80%93-JobQueue]] article has been updated with the changes.
|
||||
|
||||
## Botan
|
||||
Botan was moved from `telegram.utils.botan` to `telegram.contrib.botan`
|
||||
|
|
|
@ -26,7 +26,7 @@ The special thing about `MessageHandler` is that there is such a vast variety of
|
|||
* `update.channel_post`
|
||||
* `update.edited_channel_post`
|
||||
|
||||
You can use the different filters to narrow down which updates your `MessageHandler` will handle. See also [this article](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Advanced-Filters) for advanced usage of filters.
|
||||
You can use the different filters to narrow down which updates your `MessageHandler` will handle. See also [[this article|Extensions-–-Advanced-Filters]] for advanced usage of filters.
|
||||
|
||||
Because bot commands are another special part of the user interface of bots, there is the dedicated `CommandHandler`, which allows you to easily handle messages like `/start` or `/help`. Of course those messages can also be handled with `MessageHandler`, if needed.
|
||||
|
||||
|
@ -63,7 +63,7 @@ Also, since this is an URL parameter, you have to pay attention on how to correc
|
|||
|
||||
For more complex inputs you can employ the [`telegram.ext.MessageHandler`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.messagehandler.html) with [`telegram.ext.Filters.regex`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.filters.html#telegram.ext.filters.Filters.regex), which internally uses the `re`-module to match textual user input with a supplied pattern.
|
||||
|
||||
Keep in mind that for extracting URLs, #Hashtags, @Mentions, and other Telegram entities, there's no need to parse them with a regex filter because the Bot API already sends them to us with every update. Refer to [this snippet](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets#message-entities) to learn how to work with entities instead.
|
||||
Keep in mind that for extracting URLs, #Hashtags, @Mentions, and other Telegram entities, there's no need to parse them with a regex filter because the Bot API already sends them to us with every update. Refer to [[this snippet|Code-snippets#message-entities]] to learn how to work with entities instead.
|
||||
|
||||
This tutorial only covers some of the available handlers (for now). Refer to the documentation for all other types: https://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.html#handlers
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ The general difference between polling and a webhook is:
|
|||
There's a number of things you need to retrieve updates via a webhook.
|
||||
|
||||
### A public IP address or domain
|
||||
Usually this means you have to run your bot on a server, either a dedicated server or a VPS. Read [Where to host Telegram Bots](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Where-to-host-Telegram-Bots) to find a list of options.
|
||||
Usually this means you have to run your bot on a server, either a dedicated server or a VPS. Read [[Where to host Telegram Bots|Where-to-host-Telegram-Bots]] to find a list of options.
|
||||
|
||||
Make sure you can connect to your server from the **public internet**, either by IP or domain name. If `ping` works, you're good to go.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Look at [Hosting your bot](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Hosting-your-bot) if you've decided to get a server.
|
||||
Look at [[Hosting your bot|Hosting-your-bot]] if you've decided to get a server.
|
||||
|
||||
### Cloud
|
||||
* [Amazon Web Services](https://aws.amazon.com/)
|
||||
|
@ -12,7 +12,7 @@ Look at [Hosting your bot](https://github.com/python-telegram-bot/python-telegra
|
|||
* **[Hosting Telegram bots on Cloud Run for free](https://nullonerror.org/2021/01/08/hosting-telegram-bots-on-google-cloud-run/)** by [skhaz](https://github.com/skhaz/)
|
||||
* [Heroku](https://www.heroku.com/)
|
||||
* **[Heroku getting started with Python](https://devcenter.heroku.com/articles/getting-started-with-python#introduction)**
|
||||
* **[Webhooks on Heroku](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks#heroku)**
|
||||
* **[[Webhooks on Heroku|Webhooks#heroku]]**
|
||||
* **[Skeleton repository](https://github.com/Bibo-Joshi/ptb-heroku-skeleton)**
|
||||
* [OpenShift](https://www.openshift.com/)
|
||||
* **[How to run a Bot on Openshift v2](https://github.com/lufte/python-telegram-bot-openshift)**
|
||||
|
|
76
_Sidebar.md
76
_Sidebar.md
|
@ -1,53 +1,53 @@
|
|||
## Must read
|
||||
1. [Introduction to the API](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API)
|
||||
2. [Tutorial: Your first bot](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Your-first-Bot)
|
||||
3. [FAQ](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-Asked-Questions)
|
||||
4. [How to ask good questions](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Ask-Right)
|
||||
5. [How to write an MWE](https://github.com/python-telegram-bot/python-telegram-bot/wiki/MWE)
|
||||
1. [[Introduction to the API|Introduction-to-the-API]]
|
||||
2. [[Tutorial: Your first bot|Extensions-%E2%80%93-Your-first-Bot]]
|
||||
3. [[FAQ|Frequently-Asked-Questions]]
|
||||
4. [[How to ask good questions|Ask-Right]]
|
||||
5. [[How to write an MWE|MWE]]
|
||||
|
||||
## PTB Features
|
||||
1. [Types of Handlers](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Types-Of-Handlers)
|
||||
2. [Advanced Filters](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Advanced-Filters)
|
||||
3. [Storing data](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Storing-bot,-user-and-chat-related-data)
|
||||
4. [Making your bot persistent](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Making-your-bot-persistent)
|
||||
5. [Adding Defaults](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Adding-defaults-to-your-bot)
|
||||
6. [Exception Handling](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Exception-Handling)
|
||||
7. [Job Queue](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue)
|
||||
8. [Arbitrary `callback_data`](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data)
|
||||
9. [Avoiding flood limits](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Avoiding-flood-limits)
|
||||
1. [[Types of Handlers|Types-Of-Handlers]]
|
||||
2. [[Advanced Filters|Extensions-%E2%80%93-Advanced-Filters]]
|
||||
3. [[Storing data|Storing-bot,-user-and-chat-related-data]]
|
||||
4. [[Making your bot persistent|Making-your-bot-persistent]]
|
||||
5. [[Adding Defaults|Adding-defaults-to-your-bot]]
|
||||
6. [[Exception Handling|Exception-Handling]]
|
||||
7. [[Job Queue|Extensions-%E2%80%93-JobQueue]]
|
||||
8. [[Arbitrary `callback_data`|Arbitrary-callback_data]]
|
||||
9. [[Avoiding flood limits|Avoiding-flood-limits]]
|
||||
|
||||
## Code Resources
|
||||
1. [Code snippets](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets)
|
||||
2. [Performance Optimizations](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Performance-Optimizations)
|
||||
3. [Webhooks](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks)
|
||||
4. [Telegram Passport](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport)
|
||||
5. [Bots built with PTB](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Bots-built-with-PTB)
|
||||
6. [Automated Bot Tests](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Writing-Tests)
|
||||
1. [[Code snippets|Code-snippets]]
|
||||
2. [[Performance Optimizations|Performance-Optimizations]]
|
||||
3. [[Webhooks|Webhooks]]
|
||||
4. [[Telegram Passport|Telegram-Passport]]
|
||||
5. [[Bots built with PTB|Bots-built-with-PTB]]
|
||||
6. [[Automated Bot Tests|Writing-Tests]]
|
||||
|
||||
## Examples explained
|
||||
1. [InlineKeyboard Example](https://github.com/python-telegram-bot/python-telegram-bot/wiki/InlineKeyboard-Example)
|
||||
1. [[InlineKeyboard Example|InlineKeyboard-Example]]
|
||||
|
||||
## Networking
|
||||
1. [Working Behind a Proxy](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Working-Behind-a-Proxy)
|
||||
2. [Handling network errors](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Handling-network-errors)
|
||||
1. [[Working Behind a Proxy|Working-Behind-a-Proxy]]
|
||||
2. [[Handling network errors|Handling-network-errors]]
|
||||
|
||||
## Other resources
|
||||
1. [Where to host Telegram Bots](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Where-to-host-Telegram-Bots)
|
||||
2. [How to host your bot](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Hosting-your-bot)
|
||||
3. [Local API Server](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Local-Bot-API-Server)
|
||||
4. [Type Checking with PTB](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Type-Checking)
|
||||
5. [Press](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Press)
|
||||
6. [Notes on GAE](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Notes-about-GAE---Google-App-Engine)
|
||||
7. [Related Projects](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Related-Projects)
|
||||
8. [Emoji](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Emoji)
|
||||
1. [[Where to host Telegram Bots|Where-to-host-Telegram-Bots]]
|
||||
2. [[How to host your bot|Hosting-your-bot]]
|
||||
3. [[Local API Server|Local-Bot-API-Server]]
|
||||
4. [[Type Checking with PTB|Type-Checking]]
|
||||
5. [[Press|Press]]
|
||||
6. [[Notes on GAE|Notes-about-GAE---Google-App-Engine]]
|
||||
7. [[Related Projects|Related-Projects]]
|
||||
8. [[Emoji|Emoji]]
|
||||
|
||||
## Transition Guides
|
||||
- [Version 4](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-4.0)
|
||||
- [Version 5](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-5.0)
|
||||
- [Version 12](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-12.0)
|
||||
- [Version 13](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-13.0)
|
||||
- [[Version 4|Transition-guide-to-Version-4.0]]
|
||||
- [[Version 5|Transition-guide-to-Version-5.0]]
|
||||
- [[Version 12|Transition-guide-to-Version-12.0]]
|
||||
- [[Version 13|Transition-guide-to-Version-13.0]]
|
||||
|
||||
## Administration
|
||||
- [Test Bots](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Internal-test-bots)
|
||||
- [How To Release](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Releasing-a-new-version)
|
||||
- [Bots, Groups & Channels](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Project-Bots,-Groups-and-Channels)
|
||||
- [[Test Bots|Internal-test-bots]]
|
||||
- [[How To Release|Releasing-a-new-version]]
|
||||
- [[Bots, Groups & Channels|Project-Bots,-Groups-and-Channels]]
|
||||
|
|
Loading…
Reference in a new issue