What is telegrambotapiwrapper?
telegrambotapiwrapper is Telegram Bot Api implementation for Python
Requirements
cpython: 3.7, 3.8, 3.9
Installation
pip install telegrambotapiwrapper
Getting started.
Creating a bot
You must create a bot and get a token
Testing your bot's auth token
We use the method getMe:
>>> from telegrambotapiwrapper import Api
>>> first_bot_api = Api(token="<paste your token here>")
>>> me = first_bot_api.get_me()
>>> me
User(id=123456679, is_bot=True, first_name='botbotbot', last_name=None, username='myrudatingposterbot', language_code=None)
Check result type:
>>> from telegrambotapiwrapper.typelib import User
>>> isinstance(me, User)
True
Sending a text message to channel
Preconditions
Before sending a text message to a channel, you must:
Sending to the channel
>>> first_bot_api.send_message(chat_id=-12345678912345, text="sdjfhjsdfbjdbvhj")
Message(message_id=299, date=1558966491, chat=Chat(id=--12345678912345, type='channel', title='FooFoo', username='lalalalalalala', first_name=None, last_name=None, all_members_are_administrators=None, photo=None, description=None, invite_link=None, pinned_message=None, sticker_set_name=None, can_set_sticker_set=None), from_user=None, forward_from=None, forward_from_chat=None, forward_from_message_id=None, forward_signature=None, forward_sender_name=None, forward_date=None, reply_to_message=None, edit_date=None, media_group_id=None, author_signature=None, text='sdjfhjsdfbjdbvhj', entities=None, caption_entities=None, audio=None, document=None, animation=None, game=None, photo=None, sticker=None, video=None, voice=None, video_note=None, caption=None, contact=None, location=None, venue=None, poll=None, new_chat_members=None, left_chat_member=None, new_chat_title=None, new_chat_photo=None, delete_chat_photo=None, group_chat_created=None, supergroup_chat_created=None, channel_chat_created=None, migrate_to_chat_id=None, migrate_from_chat_id=None, pinned_message=None, invoice=None, successful_payment=None, connected_website=None, passport_data=None)
Note that chat_id is negative.
Sending a photo to channel
>>> with open('/home/dzmitry/Pictures/500800998.jpg', 'rb') as image:
... first_bot_api.send_photo(chat_id=-12345678912345, photo=image,
... caption="hello world")
>>>
Note the open file mode.
Method and types
- Implemented all methods Telegram Bot Api
- Implemented all types Telegram Bot Api
- All types of Telegram Bot Api are imported from the
typelibmodule.
License
MIT License Copyright (c) 2020 Dzmitry Maliuzhenets
See LICENSE for details.
Release files for telegrambotapiwrapper 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| telegrambotapiwrapper-0.5.0.tar.gz | 32.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| telegrambotapiwrapper-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:69.1 kB
Release files / telegrambotapiwrapper-0.5.0.tar.gz
| Download URL | telegrambotapiwrapper-0.5.0.tar.gz |
|---|---|
| Size | 32.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26405dd98c85150d8bf8659cf3719a34d841c3fd8316dd0451955679bfa2ca39
|
|
BLAKE2b-256 checksum How to use checksums |
e35ce08b757eea136e2aa90cd9e8c0abe3ce9bd5066f6147b88619682529de1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5
|
Release files / telegrambotapiwrapper-0.5.0-py3-none-any.whl
| Download URL | telegrambotapiwrapper-0.5.0-py3-none-any.whl |
|---|---|
| Size | 36.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a9d4b6669491e82bdc25f49e899cab8686e6c4afa8720e4f2643ea64da0c9bd
|
|
BLAKE2b-256 checksum How to use checksums |
a4c373607f065280d183d52ea1e887ff16da3e043a7257d48382436f62fe8cb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5
|