Skip to main content

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

sounava-0.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sounava-0.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file sounava-0.0.2.tar.gz.

File metadata

  • Download URL: sounava-0.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for sounava-0.0.2.tar.gz
Algorithm Hash digest
SHA256 154fc3b69e3e04faddc5fafcbab0ffa41371a1d43eff2b7242246a820026c811
MD5 a51cd0fea2bb003d5af9d9f00a5d0670
BLAKE2b-256 bab53bfd31e47896b3567a37c74a9e8fac8d47f77858e04cb23aff4a13db5ee5

See more details on using hashes here.

File details

Details for the file sounava-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: sounava-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for sounava-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08361ce904a285d7249f568ba889046a6b32c959cae2033a343cf299944cae30
MD5 fb0477dce88ac0d82f32e073a945499d
BLAKE2b-256 c095d3476a73767af2ad2a2b4fb8ae38d3371fb859df041dc745a59b7e1f0c5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page