Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
pytgbot 4.0 is out with all the new API goodness, including but not limited to:
- Telegram Passport (why though?)
- Replacing media
- Bug fixes
Upgrade to the newest version via
pip install pytgbot --upgrade
or clone & install it directly from
https://github.com/luckydonald/pytgbot
#update#pytgbot
Finally found a bit of time to update pytgbot to Bot API v5.0.
Comes with a new async client as well, for those who fancy the speed of asyncio.
#pytgbot#update#v5_0
Updated @YATubeBot to be more clear of errors related to upload size.
Will now handle file size related upload errors more transparent, telling you exactly what's going on, instead of just stopping sending any updates after "Uploading...".
Now it will check file size before uploading, and also handle rare errors raised (in an unspecified way) by telegram.
Technical background:
The telegram API returns a HTML error message instead of the usual json response, which of course isn't mentioned anywere in the API documentation. This broke pytgbot, the library used to interact with the API. The package was fixed to be able to handle that. Now also provides the file size of the file to upload in an easy accessable way, so that the upload size can be checked before uploading.
#update#YATube#pytgbot#TechnicalDetails