Skip to main content

Python Telegram Bot Api Wrapper.

Project description

What is telegrambotapiwrapper?

telegrambotapiwrapper is Telegram Bot Api implementation for Python

Requirements

Python 3.7

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.wrapper 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:

  1. create channel
  2. add bot to channel as administrator
  3. get channel id

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_=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 typelib module.

License

MIT License Copyright (c) 2019 Dzmitry Maliuzhenets

See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegrambotapiwrapper-0.1.3.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telegrambotapiwrapper-0.1.3-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file telegrambotapiwrapper-0.1.3.tar.gz.

File metadata

  • Download URL: telegrambotapiwrapper-0.1.3.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for telegrambotapiwrapper-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a6a951a4b66d07ad9a3aa0de1e6442f14c2159004b5684cbed24261e471f9efe
MD5 d3e6b59ff8d4dca6db5f7c354db8ff20
BLAKE2b-256 4f7b73eb63ccd6e292ff6e36054e50b1a217c210a89400967159764e01ac53f7

See more details on using hashes here.

File details

Details for the file telegrambotapiwrapper-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: telegrambotapiwrapper-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 37.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for telegrambotapiwrapper-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e4a0ab3906c4565982d4d4119211bd8ba6e89f5a5a53250bef74568844bf8b29
MD5 7f9c2a3caaab4b28ac8712e568b25a05
BLAKE2b-256 3e4bd482d4cebfe8f64c55fa0a51d37307df1d236a9c867c227ad2a2027d826a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page