- Notifications
You must be signed in to change notification settings - Fork10
Python3 wrapper/library that simplifies telegram bot development. It supports both sync and asyncio methods of programming. Dive in and start making awesome bots!
License
codingsett/telepota
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This project aims to simplify telegram bot development using higher level classes and functions which are easy to understand and implement. I took over development and maintenance fromnickoala who was the author of this beautiful project.
Explore the docs »
Report Bug ·Request Feature
This project only supports python 3+, but for asyncio you are required to have python 3.5+
If you are previous telepot library user please uninstall it in your system before installing telepota. This is to prevent conflicts from happening while using this library.
- You can install this library using pip
pip install telepota --upgrade
- You can install this library using easy install
easy_install telepota --upgrade
- or you can install it from this repository
git clone https://github.com/codingsett/telepotacd telepotpython setup.py install
Lets dive into the code so that you can get a feel of what to expect.
importsysimporttimeimporttelepotfromtelepot.loopimportMessageLoop#Namedtuple module contains different helper classes that help you pass the correct data required#by telegram bot apifromtelepot.namedtupleimportInlineKeyboardMarkup,InlineKeyboardButton#this function catches all 'normal' messages from the bot. There are other helper functions such#on_poll_data that catches all reponses from actions performed on a polldefon_chat_message(msg):#telepot glance method extracts some useful data that you may require in different sections.content_type,chat_type,chat_id=telepot.glance(msg)#keyboard made easily from a constructor class that we imported earlier.keyboard=InlineKeyboardMarkup(inline_keyboard=[ [InlineKeyboardButton(text='Press me',callback_data='press')], ])#This is how we send messagesbot.sendMessage(chat_id,'Use inline keyboard',reply_markup=keyboard)#catches all inline_queries from the bot. Go to the documentation to read more.defon_callback_query(msg):query_id,from_id,query_data=telepot.glance(msg,flavor='callback_query')print('Callback Query:',query_id,from_id,query_data)bot.answerCallbackQuery(query_id,text='Got it')TOKEN=sys.argv[1]# get token from command-line#we pass the token from botfather to the bot instance.bot=telepot.Bot(TOKEN)#Messageloop initiates polling for the bot.MessageLoop(bot, {'chat':on_chat_message,'callback_query':on_callback_query}).run_as_thread()print('Listening ...')#make sure the bot runs forever.while1:time.sleep(10)
For more examples, please refer to theExamples Folder
The following comparison of different libraries is purely subjective after using them for a while.
➖ means am not sure whats going on there because i dont have adequate information.
Framework | Async | Sync | Runtime | Documentation | community | active | beginner-friendly |
---|---|---|---|---|---|---|---|
telepota | ✅ | ✅ | Python3+ | ✅ | small | ✅ | ✅ |
python-telegram-bot | ❌ | ✅ | Python3+ | ✅ | large | ✅ | ❌ |
pyTelegramBotAPI | ❌ | ✅ | Python3+ | ➖ | medium | ➖ | ✅ |
aiogram | ✅ | ❌ | python3.7+ | ✅ | medium | ✅ | ✅ |
- Modify and improve test coverage.
- Include github actions in the workflow.
- Replace urllib with requests maybe.
- Add more examples for new methods included for BOT API.
- Update telepot to latest BOT API version.
All contributions are welcome and appreciated. A few guidelines you need to follow before contributing:
- Document your code(for self documenting code there is no need for unnecessary comments).
- Make sure the tests run properly.
- Create a pull request.
I will update this guide with more details in order to provide a good base structure.
Distributed under the MIT License. SeeLICENSE
for more information.
I would like to thank the original authornickoala for making this framework. I have been using it for 3yrs+ without any changes.