PyTelegramBotAPI
Telegram Bot API (unofficial) in Python 3
Install / Use
/learn @sourcesimian/PyTelegramBotAPIREADME
Telegram Bot API (unofficial) in Python 3
An implementation of the Telegram Bot API messages and some simple clients.
Used by:
- aioTelegramBot - An easily customisable bot written in asyncio Python3. ~~* txTelegramBot - An easily customisable bot written in Twisted Python3.~~
Installation
pip3 install TelegramBotAPI
Usage
Requests Client
from TelegramBotAPI.client.requestsclient import RequestsClient
from TelegramBotAPI.types.methods import getUpdates, sendMessage
# setup
client = RequestsClient(_token)
# send_message
msg = sendMessage()
msg.chat_id = _user_id
msg.text = 'hello there'
resp = client.send_method(msg)
print(resp)
# poll updates
msg = getUpdates()
msg.timeout = _timeout
msg.limit = _limit
msg.offset = last_id + 1
updates = client.send_method(msg)
for update in updates:
print(update)
Python asyncio Client
import asyncio
from TelegramBotAPI.client.asyncioclient import AsyncioClient
from TelegramBotAPI.types.methods import getUpdates, sendMessage
@asyncio.coroutine
def main():
client = AsyncioClient(_token)
# send message
msg = sendMessage()
msg.chat_id = _user_id
msg.text = 'hello there'
resp = yield from client.send_method(msg)
print(resp)
# poll updates
msg = getUpdates()
msg.timeout = _timeout
msg.limit = _limit
msg.offset = last_id + 1
updates = yield from client.send_method(msg)
for update in updates:
print(update)
Related Skills
node-connect
341.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
