Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

NotificationsYou must be signed in to change notification settings

codingsett/telepota

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ContributorsForksStargazersIssuesMIT License


Logo

Telepota - an actively maintained python3 wrapper for the telegram BOT API.

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

Table of Contents

Getting Started

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.

Installation

  1. You can install this library using pip
pip install telepota --upgrade
  1. You can install this library using easy install
easy_install telepota --upgrade
  1. or you can install it from this repository
git clone https://github.com/codingsett/telepotacd telepotpython setup.py install

Usage

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

Comparison

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.

FrameworkAsyncSyncRuntimeDocumentationcommunityactivebeginner-friendly
telepotaPython3+small
python-telegram-botPython3+large
pyTelegramBotAPIPython3+medium
aiogrampython3.7+medium

Roadmap

  • 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.

Contributing

All contributions are welcome and appreciated. A few guidelines you need to follow before contributing:

  1. Document your code(for self documenting code there is no need for unnecessary comments).
  2. Make sure the tests run properly.
  3. Create a pull request.

I will update this guide with more details in order to provide a good base structure.

License

Distributed under the MIT License. SeeLICENSE for more information.

Acknowledgements

I would like to thank the original authornickoala for making this framework. I have been using it for 3yrs+ without any changes.

About

Python3 wrapper/library that simplifies telegram bot development. It supports both sync and asyncio methods of programming. Dive in and start making awesome bots!

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp