minimalistic telegram bot framework that can be used in AWS Lambda or anywhere
Project description
MiniGram 🤖📬
MiniGram is an ultraminimalistic Python library for building Telegram bots that's perfect for use in restricted environments like AWS Lambdas. Say goodbye to bloated libraries and hello to MiniGram's sleek and efficient design! 🚀✨
Features 🌟
- Lightweight and minimalistic 🍃
- Works in both synchronous and asynchronous modes ⚡️
- Seamless integration with popular web libraries like Starlette/FastAPI and aiohttp 🌐
- Easy to use and understand API 😊
- Perfect for deploying bots in restricted environments like AWS Lambdas 🔒
Installation 📦
To start building your super cool Telegram bot with MiniGram, simply install it using pip:
pip install minigram-py
Usage 🚀
Using MiniGram is as easy as 1-2-3! Here are a few examples to get you started:
Basic Example
from minigram import MiniGram
class MyAwesomeBot(MiniGram):
def incoming(self, msg):
if msg.text == "/start":
return msg.reply("Welcome to my awesome bot! 🎉")
self.send_text(msg.chat_id, "I don't understand that command. 😕")
def edited(self, msg):
return msg.reply("I see you edited the message!")
bot = MyAwesomeBot("YOUR_BOT_TOKEN")
bot.start_polling()
In just a few lines of code, you've created a bot that responds to the "/start" command. How cool is that? 😎
Starlette Integration
from starlette.applications import Starlette
from starlette.routing import Route
from minigram import StarletteMiniGram
class MyStarletteBot(StarletteMiniGram):
async def incoming(self, msg):
if msg.text == "/hello":
return msg.reply("Hello from Starlette! 👋")
bot = MyStarletteBot("YOUR_BOT_TOKEN")
bot.set_webhook("https://yourwebsite.com/webhook")
app = Starlette(debug=True, routes=[
Route("/webhook", bot.starlette_handler, methods=["POST"]),
])
This example shows how seamlessly MiniGram integrates with Starlette, allowing you to create a webhook endpoint for your bot in no time! 🌐
Asynchronous Mode
import asyncio
from minigram import AsyncMiniGram
class MyAsyncBot(AsyncMiniGram):
async def incoming(self, msg):
if msg.text == "/sync":
return msg.reply("I'm a asynchronous bot, for sure! ⚙️")
async def edited(self, msg):
return msg.reply("I see you edited the message!")
async def main():
bot = MyAsyncBot("YOUR_BOT_TOKEN")
await bot.send_text(YOUR_CHAT_ID, "Hello from an asynchronous bot! 🚀")
await bot.start_polling()
if __name__ == "__main__":
asyncio.run(main())
MiniGram works just as well in asynchronous mode, making it easy to integrate with your existing async application. 🎛️
Contributing 🤝
We love contributions! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on our GitHub repository. Let's make MiniGram even better together! 💪
License 📄
MiniGram is released under the MIT License, so feel free to use it in your projects, whether they're open-source or commercial. 😄
Now go forth and build some amazing bots with MiniGram! 🎈🤖
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
Built Distribution
File details
Details for the file minigram_py-0.2.1.tar.gz
.
File metadata
- Download URL: minigram_py-0.2.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb016fb721d05cb5557f15a730aef5e0b8bd2fee6718c38a48264e5d77bffcda |
|
MD5 | 1cc22a9aec2178b6265fa8c905fe7b3a |
|
BLAKE2b-256 | e946080c2e3fab28c922d88d293184f12e4170a38c977ea325dfd51eb1142581 |
File details
Details for the file minigram_py-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: minigram_py-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34807bd1467a45dbd506ea48c89d239c3ca3239401431d95ec760caee344f8f7 |
|
MD5 | 5cda495141705c4ec91f5fbd9e973a6c |
|
BLAKE2b-256 | 6f988cf8cc6867e6568f28fed44fb28dd70e916b49bee12f336c1d3d3a305188 |