Simple Telegram Bot API wrapper for MicroPython
Project description
Telemicro
Telemicro is easy to use and asynchronous module for working with Telegram Bot API, written on Micropython.
Example
Simple example of using Telemicro features
import network
import uasyncio
from telemicro.bot import Bot
from telemicro.dispatcher import Dispatcher, Router
from telemicro.requests import Requests
# Connecting to WiFi
nic = network.WLAN(network.STA_IF)
nic.active(True)
nic.connect("SomeNetwork", "SuperSecurePass123")
router = Router()
# Creating some basic filter
class TextFilter:
def __init__(self, text):
self.text = text
def __call__(self, message, data):
if message["text"] == self.text:
return True
return False
async def handler(message, kwargs):
bot_ = kwargs.get("bot")
text = kwargs.get("text")
data = {"chat_id": message["from"]["id"], "text": text}
# sending answer to user, using api request
await bot_.api_request("sendMessage", data)
# Register handler to router using decorator
@router.message(TextFilter("/about"))
async def decorator_handler(message, kwargs):
bot = kwargs["bot"]
text = "Hi! I'm bot made with telemicro, on Micropython"
data = {"chat_id": message["from"]["id"], "text": text}
# sending answer to user, using api request
await bot.api_request("sendMessage", data)
if __name__ == "__main__":
dp = Dispatcher()
bot = Bot("123456789:ABCDEFGHIJK")
# Registering handler to router using function
router.message.register(handler, TextFilter("/start"))
dp.include_router(router)
# passing params via dispatcher
uasyncio.run(dp.start_polling(bot, text="Heeeyya from telemicro!"))
Licences
Telemicro module contains code from other repositories and users, which are included in the file code (dispatcher.py - event observer names & some logic from aiogram, requests.py - requests module by popnotsoda95, ulogging.py - by Youkii-Chen).
These files are required for Telemicro to work properly - so when using Telemicro you are automatically acknowledging these licences
Contributing
We'd love for you to create pull requests from the development branch (develop). Latest releases are created from the main branch.
Contact us
- Alex (GitHub)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telemicro-1.0.0.tar.gz.
File metadata
- Download URL: telemicro-1.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
546e55be05b100f5fa07a49ce35ed0663db1877e4cc06e8a9578e9a3ecc6bb54
|
|
| MD5 |
0f02c03c4abed64be50faff598fffbc6
|
|
| BLAKE2b-256 |
1082a99c7e8a44574d7c4ac1a3a234d6b9a248e1263a71ad37697150744a821c
|
File details
Details for the file telemicro-1.0.0-py3-none-any.whl.
File metadata
- Download URL: telemicro-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
107043ce3c4351c891c1474f5fc0faabf21a4016ee9bda326c12db5e8407cd5e
|
|
| MD5 |
75e10172d420d4e312e3b96e5e77e02a
|
|
| BLAKE2b-256 |
e5c42ea0647d27023b487ebf6d1b0d56e67d92f9720a81ea7e589e1c5b8bbfb0
|