Hello World, I'm Alan, I'm 14 y.o python dev and I created my own framework for Telegram Bot API - Surfgram.
Surfgram is fully async, rust-powered (client for API communications written in Rust), OPP-based framework with CLI.
- First, you need to install
surfgram
:
pip install -U surfgram
- Create your first bot:
surfgram new mybot
- Run your bot:
cd mybot
surfgram run --debug
Whoa! Your bot is running. Now you can read docs or check more examples
For example, you can create new bot command handler with:
from surfgram import APIObject, Bot
from surfgram.types import BotCommand
from typing import Callable, List
class StartCommand(BotCommand):
@property
def __names__(self) -> List[str]:
return ["start"] # target: /start
@property
def __callback__(self) -> Callable:
return self.handle
async def handle(
self,
update: APIObject,
bot: Bot
) -> None:
await bot.send_message(
chat_id=update.message.chat.id,
text="Hello, world!"
)
Thanks you for reading!
Top comments (0)