A telegram SDK offering clean and simple route decorators.
Project description
Note: This is not the official pyTelegramBotAPI library. This is a lightweight alternative with similar syntax and functionality. If you accidentally install this package instead of pyTelegramBotAPI, don't worry. your basic bot code will still work seamlessly. This package maintains compatibility with common pyTelegramBotAPI patterns while providing additional simplicity and ease of use.
Example Setup
from sounava import telegram
bot = telegram("YOUR_BOT_TOKEN")
@bot.command('/start')
def start_command(update, bot):
bot.reply(update, "Hello World!.")
@bot.message
def echo(update, bot):
bot.reply(update, f"You said: {update['message']['text']}")
bot.start()
p("Name:", get("name")),
p("Age:", get("age")),
if_(
gt(get("age"), 18),
p(get("name"), "is an adult"),
else_=p(get("name"), "is a minor")
)
)
program.run()
**Output:**
```sh
Name: Alice
Age: 25
Alice is an adult
Core Components
Basic Structure:
· src(*nodes) - Main program container
· var(name, value) - Variable declaration
· p(*values) - Print statement
· get(name) - Variable reference
Control Flow:
· if_(condition, then_branch, else_branch) - If statement
· for_(item, iterable, body) - For loop
· while_(condition, body) - While loop
Functions:
· function(name, params, *body) - Function definition
· call(name, args) - Function call
· return_(value) - Return statement
Data Structures:
· list_(*items) - List literal
· dict_(**items) - Dictionary literal
Operations:
· add(a, b), subtract(a, b), multiply(a, b), divide(a, b)
· eq(a, b), neq(a, b), gt(a, b), lt(a, b)
· and_(a, b), or_(a, b), not_(a)
Advanced Examples
Function with Loop
from starexx import *
program = src(
function(
"calculate_sum",
["numbers"],
var("total", 0),
for_("num", get("numbers"), src(
set_("total", add(get("total"), get("num")))
)),
return_(get("total"))
),
var("scores", list_(85, 92, 78, 96)),
var("total_score", call("calculate_sum", [get("scores")])),
p("Scores:", get("scores")),
p("Total:", get("total_score"))
)
program.run()
List Operations
from starexx import *
program = src(
var("fruits", list_("apple", "banana", "orange")),
p("Fruits:", get("fruits")),
p("First fruit:", call("fruits.__getitem__", [0])),
# Add a new fruit
call("fruits.append", ["grape"]),
p("Updated fruits:", get("fruits")),
# List length
p("Number of fruits:", len_(get("fruits")))
)
program.run()
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
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